Thursday, 23 May 2013

6 Tips: Getting your Hackathon project into Production

Recently there has been a steady stream of stories about projects that started as a Hackathon idea going into production at some of Silicon Valleys top companies. It's well known that Facebook's 'Like' button started off as a Hackathon project, and Ebay just announced a Hackathon project has led to them using Node.js for the first time in production. So what will give your project a chance of making it out to production for your users to benefit from? The team @ NerdAbility.com are giving you six tips to get things moving when your boss gives you some time to hack away!

1. Share Your Project


So you have made something really cool, maybe on your own or with some other devs. Now is the time to share your Hackathon project and get other people within the company excited! If it's a tool for the dev team why not give a lunch-time talk or send out a note with a quick-start guide. Once people see that you have made something cool and interesting it is surprising how quick it can get added to priority list for more work / release.

2. Don't worry (too much) about the technology


Hackathons are meant to be a chance to try out something new or maybe do something differently, so don't let people tell you your work has to be production ready right away. Often you will do your best work when you are excited and lets face it all of developers love shiny new things! But, once you have the concept nailed and something implemented be prepared to be flexible. Getting a new technology live can often be time consuming, so sometimes you will need to give and take to see your project get the light of day.

3. Be prepared to say 'OK that didn't work'


So you have tried to make something and, well, it didn't quite work out. This is still a valuable project! You will have learnt new things and hopefully take away a few lessons. The most important thing to do is make sure you and your team do another Hackathon! Still share your work with the rest of the team and who knows it may inspire someone else. Next time you can take a fresh idea and see what happens!

4. Upload your project to GitHub


So you have finished your kick ass project and your company decides on a change of direction, your project just isn't needed. Shock horror, this does happen. Why not try to get permission to put your project onto GitHub? This is a great way to share your work and who knows it may be just what another developer / company is looking for. Then instead of your code being in production in one place, it could be used all over the world. Dream big.

5. Work with the business guys


Great things can happen in pairs! Use your technical genius to think up a solution for someone in the business with a problem or idea. If you address a hidden problem or tap into an undiscovered opportunity you will look like hero. The great thing about this is your work will hopefully have business value so you instantly know it will have a better chance getting released. Also working with someone with a different perspective could open your mind to come up with an out of the box solution that will blow the socks off the rest of the dev team!

6. Launch it yourself


If you have built a cool application in your own time, then just launch it yourself! There are plenty of cloud providers offering free basic hosting such as Appfog, AWS and CloudBees amongst many others. Just be careful of any legal complexities that may occur from having users such as data protection and anti-SPAM regulations.

Finally.....


We loved this presentation by Philip Su, Facebook Site Lead London, from back in February this year on Facebook's engineering process and how they use Hackathons as part of their development culture.

Check it out:

Sunday, 12 May 2013

Essential Resources to Become a Life Long Learner (in tech)

Is one of your New Year Resolutions to re-skill? Thinking about re-training for a new career (or even just a new hobby) in tech? Then you're in luck! 

Today, more than ever, the barrier to entry for starting to learn a new technology or programming language is all but nonexistent, all you really need is a computer (or even a mobile device) and a web connection and you are pretty much good to go - just choose your preferred technology, an IDE and get started.  Almost everything is open source or at least free to use for a single developer just out to learn and there is a wealth of blogs, articles and Q'n'A sites ready to help you with tutorials, walk-through's and helpful advice - many of these backed with ready and running code bases on GitHub free for you to play with and generally work out what is going on.

However, with all these resources it can sometimes be a bit daunting with so much content. Once you have chosen a language how do you know where to start? Here are some of our favourite sites and resources that we have discovered and found useful in learning new skills:

  • iTunes U - a lesser known category on iTunes is their academic section, iTunes U(niversity) featuring loads of podcasts and lectures from a range of academic organisations, and some of this stuff is serious! Several large universities have uploaded full lecture series there, and by and large they are free to download (yes, you have to install iTunes, which sucks, we know).  Want to take the full term of Stanford university's iOS course? Its up there. Want to learn AI for chess playing from Cambridge uni? Yep, got that too. And for free.
  • MIT OpenWare - MIT have been one of the strongest advocates of open sourced education. A lot of there lecture series are online (can also be found on iTunes, but can be avoided).  Is it just us who thinks its amazing that anyone around the world with a web connection can get educated by the most prestigious academic organisations around?
  • Khan Academy - there is a lot of hype around this one, well funded with some pretty big names supporting it (jQuery creator John Resig is a Dean there), a not-for-profit aiming at providing free education for everyone. The academy provides lots of video based courses as well as interactive challenges and detailed stats on how you are doing.
  • Udacity - this is another recent, well-funded startup trying to tackle free higher education for all. Founded my three robotocists it is slowly building a very respectable catalogue of uni level courses ranging from CS101 to AI for robotics. As with the Khan academy, the lectures are purely for the web so the videos are clear and designed for remote learning (different from the filmed university lectures which are targeting classroom based learning).  We have recently created and Open Sourced the Spring-Social implementation of the Khan Academy API - so if you are working with the JVM and want to have a play with the Khan Academy API then check it out on GitHub
  • CodeAcademy - we have mentioned before we are fans of code academy, code academy is an in-browser development environment that walks you through programming exercises to help you learn with your hands - currently supporting JavaScript, HTML, Ruby and Python
  • Free eBooks - there are loads of great free eBooks available online, so many there is no point listing them, instead I will just point you here. Which leads nicely on to the next point..
  • StackOverflow - what really needs to be said about SO? It is the definitive q'n'a site for tech. If you are just starting learning head over and sign up, the help from the incredibly active community over there will be invaluable (although be sure to read the posting guides, they can be a little unforgiving at times!).
  • Coursera - Another massively popular online learning resource, this one recently generated a lot of interest with its recent Scala course taught by the original creator of the language!  We are currently working on some secret integration with Coursera at NerdAbility, and you will soon be able to integrate your Coursera account and show off which courses you have completed!

Hopefully the above resources help on your path to re-skilling.  In reality, getting your hands dirty with code and trying to solve problems and fix errors is the best way to learn, so don't forget to get stuck in - and maybe when you are more confident try answering questions on StackOverflow!

Of course, with these new found skills you will want to show them off, so we'd recommend heading to NerdAbility and registering (if you haven't as already) and update your skills, add your StackOverflow profile and even add a custom section talking about what you are learning (employers always love to know that candidates are proactive and motivated when it comes to learning new things and keeping up with technology). 

Leave your comments with any other tools and resources you have found useful in your journey of becoming a life long learner.

Tuesday, 19 March 2013

Tech: Building an RSS Reader Android App

This tutorial will walk through building an RSS reader on the Android platform (focusing on 3.0 + as it will be using Fragments). All the code is available as a complete, working Android app that you can fork/download and fire up straight away on a compatible Android device/emulator. So feel free to go grab that from GitHub before continuing.

It is not an unusual requirement for mobile apps these days to be able to consume an RSS feed from another site (or many) to aggregate the content -  Or maybe you just want to build your own Android app now that Google has announced it will be retiring Reader.

Those of you who have worked with RSS in other JVM languages will know that there are plenty of libraries available that can handle parsing RSS - however, because the android platform doesn't actually contain all the core java classes, almost all of the RSS libraries have not been supported.

Fear not though, as Java's SAX parser is available, so with a bit of code we can get a custom RSS parser up and running in no time!

This walk through will cover off the basics of getting an RSS reader app up and running quickly and will also cover some details of Android's fragment system for tablet optimization as well as some things to watch out for (such as changes in the platform that mean network operations cannot be run in the main thread, which requires some tweaking if you have worked on earlier versions).

All the code for the app is also available on our GitHub so feel free to fork that and try loading it up on your Android device/emulator.

Parsing an RSS Feed:


So to get started we will look at parsing the feed - if you have any experience parsing XML using SAX in Java then you will know how easy this is. All we need to do is to tell the parser which XML nodes we care about, and what to do with them.

If  you have never implemented a SAX parser before, there are three primary methods that we will override: 
  • startElement() - This is called by the parser every time a new XML node is found
  • endElement() - This is called by the parser every time an XML node is closed (e.g. </.. )
  • chars() - this is called when characters are found between nodes



Because we only really care about capturing data from the leaf nodes, our startElement() method is left empty. The chars() element has to be watched, as there is no guarantee when it will be called (e.g. in a node like hello world  this method might be called several times between the start and end) so every time we will just append the contents to a StringBuffer - that way we can be sure that we will have captured all the data in the node.  By the time the endElement() method is called, we know that we have the contents of the node itself, and we just have to store the data.  At this point, we just quickly knocked up a POJO with the attributes that we wanted to capture - the Strings that we match on are the node names from the ATOM RSS feed (that Blogger uses) - if you are using another feed, just have a quick look at the feed and update the node names appropriately.

Using our Feed in an Android App

So, that was easy right? Once that parser has run through (and you could use that code standalone in any java app really) then you will have a list of Java objects that have the core details about the latest blog posts on the feed (title, author, datecreated, content, etc) - So now lets look at using it in an Android app.

We will assume a basic understanding of the Android SDK and the concept of Fragments, so won't go back to basics with that stuff.

What we will do, is create a basic ListFragment and an RSSService class that we will use to populate the list. In our ListFragment we will simply tell our RSS service to populate the list:



Simple right?

Let's take a look at what our helpful RSS service is doing for us.



The first thing to note is that this class is extending Android's AsyncTask- The reason for this is that since Android 3.0, you are no longer able to perform network operations in the main application thread, so being as our class is going to have to fetch some RSS feeds we are going to have to spin off a new thread.

As you can see, the constructor just sets some context info that we will use later on, and then builds a progress dialogue - this is then displayed in the onPreExecute() method - This lets us show a "loading" spinning disk whilst we fetch the data.

Android's AsyncTask's primary method that handles the actual work that you want to do asynchronously is called "doInBackground()" - In our case, this is simple - we just invoke our SAX RSS parser and fetch our feed data:



Finally, we will override the "onPostExecute()" method of the async class to use our newly fetched list to populate our ListFragment.  You note how when we overrode the doInBackground() method earlier we set the return to List of Articles (where Article is my simple POJO containing my RSS blog post info) - well this must correspond to the argument of the "onPostExecute()" method, which looks like this:



Actually, all we really needed to do in this method would be pass our new List or articles to the ListFragment and notify it of the change as below:



However, in our application we have added a bit more sugar on the app - and we have actually backed the app with a simple DB that records the unique IDs of the posts and tracks whether or not they have been read to provide a nicer highlighting of listed blog posts.

So that's it - there's plenty more you can add to your RSS reader app, such as storing posts for reading later, and supporting multiple feeds/feed types - but feel free to fork the code on GitHub, or just download on to your android device to enjoy all our NerdAbility updates!

Application running in Andriod emulator
RSS application running in an Andriod  tablet emulator




Thursday, 31 January 2013

Tech: A Rough Guide to Atmosphere with Spring, Tomcat & Jersey: Avoiding the Pitfalls

Welcome to the second  installment of the NerdAbility tech guide series. This post looks at the Atmosphere framework! Enjoy....

Edit: I Previously forgot to include the  project sources and people have rightly asked in the comments about it. I couldn't find the example I wrote this blog post from, but I found a similar example on my github. You can find it here

More and more it's becoming a common requirement to support some sort of bi-directional (asynchronous) channel in modern web applications. Atmosphere is a great library which does much of the heavy lifting if you're running on a Java, servlet based stack. It offers support for WebSockets, Server Side Events (SSE), Long-Polling, HTTP Streaming (Forever frame) and JSONP. There are, however, some pitfalls and, if you've not got a lot of experience in the area, it can be frustrating trying to work out whats going wrong.

Having run through the process once I thought it'd be nice to cover my implementation in some detail. Maybe you'll see something which can help you with your own configuration or implementation problems.

Overview of the stack

This is what I had in place before integrating atmosphere.
  • Application server: Tomcat 7.0.32 (Must be greater than 7.0.30 for atmosphere to work correctly).
  • Container: Spring 3.2 RC1 ( though anything post 3 is fine )
  • Build Enginer/ Dependency Manager: Maven3
  • Front-End: Javascript / JQuery

    Include the Dependencies

    You'll want to add the following entries to your POM :

    Properties:

    Dependencies:

    Just a quick note about the cors-filter dependancy, you'll only need it if you want Cross-Origin-Resource-Sharing support. I thought about covering it in this article, but maybe i'll write it up as a follow up

    The web.xml

    If you're not using servlet 3 already, time to upgrade. Change your web-app config to look like this:

    The next step is to include the standard spring dispatcher etc to your configuration. You will probably you'll already have this anyway.


    The Atmosphere Controller 

    Using The Atmosphere Servlet

    I fully accept that everyone has their own pet way of setting up servlets, this is just one possible mutation. You want to add the following to your web.xml:

    Pitfall 1: The broadcasterLifeCyclePolicy tells atmosphere to destroy any connections that been closed by the client, enabling it will prevent OOM (Out of Memory) issues in your application.
    Pitfall 2: The recoverFromDestroyedBroadcaster prevents an exception being thrown when you try to reuse a broadcaster that you have recently destroyed ( useful if you want your client to subscribe using its own personal channel ).
    So now you're able to use spring MVC alongside your atmosphere code without them stepping on each others' toes. Lets move on.

    The Controller Class

    Mine was simple enough. It basically passes off the broadcasters that it creates to another service which whatever listeners you have configured ( Mine was RabbitMQ ) will call when they have an appropriate message.

    
    @Configurable: Using @Configurable is a great way to use aop classweaving to inject spring dependencies into non-managed spring classes. There is extensive documentation on how to set this up in spring 

    Pitfall 3: Make sure you set the suspend period, or you're going to be dealing with a java.net.SocketException: Too many open files in pretty much no time.

    The Service Class

    Also very simple. Using a map to store the in use channel ids -> broadcasters, the service is simply responsible for looping through the registered broadcasters and broadcasting a generic message.

    The Async Class

    Probably you'll have some asynchronous process which is waiting for messages, there are many possible implementations that this may take so i'll just show one of the popular ones RabbitMQ.
    You'll need to make sure you add the following dependency to your pom:

    RabbitMQ has a pretty clean java integration which is nice and quick to set up. The first component is a context configuration file where you bind your queues, connection factory, admin, exchanges and listeners.


    Notice the reference to broadcastQueueConsumer we used there ? Lets write that now.

    I've omitted the declaration of the Simple Message Converter in the context file but please dont forget about it. Once you're done you've got a pretty clean implementation of the serverside and should be ready to move onto the frontend.

    JQuery frontend implementation

    Really its quite simple to build a small subscription handler. I've added an example of mine below :
    Pitfall 4: Make sure you set enableXDR to true if you want to support cross domain requests.

    Pitfall 5: To send custom request params it seems like you need to pass via url (maybe jfrancard has fixed now but not sure)

    Thanks for reading, and feel free to ask any questions via a comment below or our twitter @nerd_ability

    Wednesday, 16 January 2013

    Tech: How to Fix 'SSLPeerUnverifiedException: peer not authenticated' Exception in Groovy / Java

    This is the first in a series of tech posts on the NerdAbility blog. We are aiming to blog any useful tips / gotchas we come across when developing with various technologies. We will still be posting tech recruitment insights and NerdAbility news, so stay tuned!

    How to Fix 'SSLPeerUnverifiedException: peer not authenticated' Exception in Java / Groovy


    When developing with web services in Java you may come across the need to connect to a HTTPS URL, for example when creating a REST client. In some cases there will be an issue with the type of certificate the web server is using, resulting in a SSLPeerUnverifiedException.

    To solve this you could previously export the servers SSL certificate via firefox / chrome and load this directly into the cacerts keystore (jvm's default trusted keystore). In recent versions of firefox / chrome this feature seems to have disappeared.  In this post we will show you how to grab the certificate using command line tools and then load it into the cacerts keystore. Finally we give an example of connecting to a HTTPS URL with Groovy using RESTClient.

    Please note this guide is for Linux / Mac users. Windows users may be able to follow along using cygwin, but we have not tested this. If you are using an alternative trusted keystore in your application, use this instead of cacerts in the examples.

    Prerequisites: Before loading any key into your cacerts keystore, please verify you are happy with the certificate and its authenticity, and issuer. You can do this by using a tool like this one.

    Disclaimer: Follow this guide at your own risk, we can not be held liable / accountable for any damage or issues caused to you or your systems.

    Step 1: Download and Store the Certificate


    To download and store the certificate run the following command, changing $ADDRESS for the sites address. For example https://www.facebook.com would become facebook.com:

    echo -n | openssl s_client -connect $ADDRESS:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/$ADDRESS.cert

    To check the certificate was grabbed, you can run:

    cat /tmp/$ADDRESS.cert

    This will output the certificate and you should see something like:

    -----BEGIN CERTIFICATE-----
    *DATA*
    -----END CERTIFICATE-----


    Step 2: Load this into the default keystore for the JVM CACERTS


    First of all you need to locate the cacerts keystore for the JRE you are using. To find out the version of java run the following command:

    java -version

    This should give you something similar to:

    java version "1.6.0_11" Java(TM) SE Runtime Environment (build 1.6.0_11-b03) Java HotSpot(TM) 64-Bit Server VM (build 11.0-b16, mixed mode)

    Next take the Java version number from the previous output, in this case 1.6.0_11 and use locate to find the cacerts keystore for this Java install:

    locate cacerts | grep "1.6.0_11"

    The output should give you something similar to:

    /usr/lib/jvm/jre1.6.0_11/lib/security/cacerts

    Now you have enough information to import the key into the keystore. Run the following command, replacing the $ADDRESS with the address variable you used earlier, the $ALIAS with a name for the certificate i.e. facebook. Replace the $PATH variable with the path to the cacert (the output from the locate command we just ran). Also we have added the -storepass argument, passing the default password for the cacerts keystore. You will want to change this, if you have not already, and should be prompted to do so.

    sudo keytool -importcert -alias "$ALIAS" -file /tmp/$ADDRESS.cert -keystore $PATH/cacerts -storepass changeit

    Once you run this you will be shown the certificate and prompted to confirm you want to import the certificate:

    Trust this certificate? [no]:  yes
    Certificate was added to keystore

    Now you should have the certificate ready for use in your application, providing it is configured to use the default keystore and runs on the JVM we configured the certificate for!

    Step 3: Test It!


    Here is some example Groovy code using RESTClient:



    Thursday, 10 January 2013

    TechBritain Launch Interactive UK Tech Startup Community Map

    Tech Britain has just launched an interactive map of the UK tech startup community! This great service allows you to explore the tech startup scene around you, including hangouts, investors, companies and communities. 

    Tech Britain Interactive Map
    TechBritain.com UK Interactive Startup Map
    If you are working in a startup why not explore who is around you, or where you can grab a coffee and meet up with other startup folk? Maybe you are looking to move to a startup or just get involved, you will find all this and more!

    Tech Britain is also taking submissions for anything that they have missed, so if your company isn't featured you can sign up and submit a listing here.

    Remember if you are wanting to get involved with the UK tech startup scene also come check out NerdAbility.com and create a free profile to show how awesome you are!

    Wednesday, 9 January 2013

    2013: A Programmer's Resolutions

    This time last year an article did the rounds that featured 12 month-long resolutions aimed at developers - it was very interesting and insightful with some good ideas and it generated a lot of discussion and interest around the web.

    So this year I thought it would be fun to set out some NerdAbility New Year Resolutions, I hope you find them interesting/inspiring and feel free to adopt as few or many as suits you! (and of course, the month names are there for fun, they can be done in any month/time period you like)  

    (I have intentionally not gone back and re-read last years list, as they were good points that would probably just get stuck in my head and would result in this list being a clone of those ideas - but don't shout if there is still some overlap!)

    Get Real
    Month 1 - January
    2012 was very much the year of the Raspberry Pi, at just ~£25 it has made working with the physical a very real possibility for many developers previously used to working purely with software. Step away from the software for a month and make something real. Even if it's just a cat toy that sends tweets, or a home made spice rack, making something physical will give you a different perspective, a different set of challenges to building software, and will likely help you tackle software problems with a different mindset.

    Get Healthy
    Month 2 - February
    This is probably an obvious one, and probably one that should last for more than a month. As professional developers we spend a lot of time sitting down, and when you spend some of your free-time programming as well it leaves little time for physical exercise. More and more reports show these days that sitting down more than 8 hours a day is detrimental to your health, so we all really need to keep on top of this one! Livestrong.com is a great resource for health and fitness and you can get most of the information for free. If you are new to fitness try following a program like this one which can be done at home just using your body weight.

    Get Aesthetic
    Month 3 - March
    For some of us, this will come natural (the designers among us anyhow), but for lots of developers aesthetics and visual designs are not something that need to be considered. However, understanding aesthetics and good UI design can be good on the CV but can also help developers understand customer rational, User Experience (UX) and the more visual elements of building an effective product. Plus with more and more developers building mobile apps, it is often down to them to make them visually pleasing and to ensure a good UX. If you are gunning for a job in a small startup then design skills (or at least understanding of design issues) are an enviable string to your bow!

    Get Involved
    Month 4 - April
    There are loads of active technology communities these days, both online and in the real world. Get involved in a community! Whether this be an online forum or q'n'a site (you know we are always preaching the many benefits of Stack Overflow) or in the real world in the form of a local meetup (not heard of any local meetups? head over to meetup.com - you'll be surprised how many you find!).  Being active in any kind of community can be beneficial in so many ways - you can help junior members in a mentor role, you can learn from more experienced, you can network, you can find out about new jobs and you can make friends!

    Get Introspective
    Month 5 - May
    How long have you been at your current job? are you happy there? even if you are, it is always to be aware of what the job market is like, what roles you might be able to do, what you might like to do. Even if it is just thinking about your career plan and where you see yourself in a few years (even if its still at your current company). The tech job market in the UK is really busy and its a really great time to be a developer right now, so its good to know your options.

    Get Creative
    Month 6 - June
    Create something! Start a personal project, put it up on GitHub and spend a month working on it. Whether it be something you work on alone or with friends, get it started and see where it takes you! Personal projects are great for your CV (demonstrates actual ability and lets employers see your code plus shows you to be pro-active and motivated in learning and working on projects), they also let you brush up on your skills and maybe use technologies you wouldn't otherwise get the chance to play with (stuck using Java5 in work because of policies? Your personal project can be Java7, latest Spring nightly builds, Groovy 2.x, anything you want!).  If at the end of the month its not going anywhere, then at least you have brushed up your skills, have a great piece for your CV and spent time well.

    Get Trendy
    Month 7 - July
    In tech one thing you can always bank on and that is trends and fads, there is always something in trend in tech, and it inevitably later starts getting a hard time (see the stick MongoDb got after shooting to fame). But whilst some tech trends may be a flash in the pan, many of them do see out the time to become established technology - The current trend for Javascript being a great example with the likes of NodeJS offering complete JS solutions. So why not spend a month learning what they are about? If nothing else you will be able to contribute something more to the latest water fountain banter.

    Get Mobile
    Month 8 - August
    Its fairly safe to say that mobile isn't going away, and with iPads outselling Windows laptops this last year, its also safe to say that if you start learning to develop apps for iOS or Android you are in a pretty stable market place. Get involved and write an app for your phone. Android is free to do, with awesome SDK and plugins for several (free) IDEs, go ahead and get involved. Another great demonstrable piece for the CV and presents different challenges such as catering for reduced power/memory, different device sizes, UI design, etc.

    Get Wordy
    Month 9 - September
    Start a blog. Blogging can be quite therapeutic and is also a great way to give back to the tech community with insights or tutorials of how you solved a problem. With free platforms like Google's Blogger and WordPress.com its so easy to get up and blogging in seconds. But don't feel as though just because you work in tech you have to blog about tech - write about anything you ate passionate or opinionated about, be it movies, food, art, comics, or home decor. It will improve your writing skills and another way to show off your skills, knowledge and passion on your CV.

    Get Out
    Month 10 - October
    So yeah. Get outside. Spend some time to things you love (other than tech stuff), go to the cinema, go on holiday, visit interesting places you've never been, go to the pub. Just have some fun. After a month spent in the pub or on holiday, maybe skip to Decembers activity? It sure sounds good to us!

    Get Schooled
    Month 11 - November
    Learn something new, take a new course, learn a language, take a cake decorating course. Expand your mind. We will be doing a post soon about becoming a life long learner and sharing some awesome resources for continual learning. There's loads of interesting stuff out there to learn about.

    If you are interested in picking up some new coding skills there are plenty of cool courses at codeschool.com or codeacademy.com!

    Get Lazy
    Month 12 - December
    The cynical among you may think this is just because we ran out of ideas. Or just couldn't be bothered ourselves. But really, take some time off, spend it with family, friends etc. After all, that's what life is all about.