Taking screen shots on Android devices

There doesn't seem to be an easy way like on the iPhone (pressing both buttons at the same time) to take a screen shot on Android devices - however if you've got the Android SDK installed it's pretty easy.
  1. Connect your device to your computer via USB
  2. On the device (Android 2.1) go to Settings > Applications > Development and enable 'USB Debugging'
  3. In your Android SDK folder run the DDMS app in the tools folder
  4. From the left panel select your device and press CTRL + S
  5. Now find the screen you want to screen shot and click 'Refresh' and then save the image.

My move to Android from iPhone

First up, let me start by saying that my move from Apple's iPhone to Android is nothing to do with the recent events in regards to Adobe Flash - I'm not a big proponent of Flash, I actively block Flash on all my desktops, I'm a registered Apple iPhone developer (from the brief moment that I thought I could learn Objective-C) and this won't be the start of me ditching Apple products. 

So why have I moved to Android?  

I don't see that the iPhone is worth £200 over the cost of another make of handset
 
In preparing this post I realised that that statement is a little strange given I'm a Mac user. I'm more than happy to pay 'over the odds' for Mac hardware - yet I don't see that the iPhone is now worth paying an extra £200 'per contract' for the handset given the competition. I'd expect that when the iPhone 4/HD is released in June it will cost around the £200 mark much like previous versions have on a minimum of £30 a month contract usually over 18 months meaning it carries a minimum cost of £719 over the contract period - plus this cost increases as you increase the storage capacity (SD cards anyone?). Here in the UK, most Android devices are offered 'free' on contract so you don't even have to pay the upfront amount for the handset. 
Enter the HTC Desire running Android 2.1 with HTC Sense. With specs closely matching Google's own Nexus One (and thoughts that the HTC Desire is just the generally available version of the Nexus 1) many are saying that it is one of the first phones to give the iPhone (in it's current guise) a run for it's money. It's being heavily advertised on billboards across the country, most UK operators are reporting low stocks and that they're flying out the doors.
 
Sporting the same 1Ghz SnapDragon processor, 3.7" AMOLED screen (@ 480x800 WVGA - surely Apple will somehow increase the resolution of the next generation handset) the HTC Desire is a snappy little phone plus the screen is sharp and bright. Side by side with my iPhone 3G (running iPhone 4.0) I realise just how slow the iPhone is, yes it's 1 generation old and the 3GS is faster but from what I recall from using a 3GS it's not up to the speed of the Desire.
 
Then there's Android itself. After using an iPhone for over 18 months you're well in the Apple mindset of how they want the iPhone to look and operate. All iPhone's look the same once they're unlocked with the standard 4x4 grid of icons - no wallpaper (although coming in iPhone 4.0) and certainly no desktop widgets or such like (maybe Apple will surprise us in June?) - with Android you get the option to personalize your phone, moving apps that you want quick access to to the desktop and using widgets giving you quick access to the apps you use and the information you want at your fingertips.
 
It's the little things that count...
 
If you're an iPhone user you'll know about the disconnect between your applications. Applications aren't aware of other installed applications to much of an extent (if any) - so when I tapped on an RSS feed in the Android browser and it prompted me what to do with it I felt natural - much like how a normal computer operates, in this case it was a podcast feed and I wanted it opened in Google Listen.
 
That leads me on to syncing. With the iPhone my daily routine just before bed consisted of plugging my iPhone in to sync podcasts to remove ones I've listened to and to add news ones for the next days commute. No more! There's no connecting to a computer or anything, Google Listen (Google's own podcasting app) syncs wirelessly (you can configure to only do it if on charge, wifi etc) at preset intervals - this is pretty big for me, the only downside I have is that there's no playback speed control backed into Android, but I can live with that!
 
The Android MarketPlace is an area of much discussion and often the thorn in Android's side - but it is definitely getting better and what with third party stores cropping up and sites like AppBrain Android apps are definitely improving and with the new handsets with some real horsepower we're beginning to see apps that compete with their iPhone equivalents. One thing I really like about the Android store is that you get a 24 hour grace period for purchased apps, should you no longer need it or find it doesn't do what you want you can uninstall and get a refund for the app! Google is also expected to release Froyo (next Android release) at Google I/O later this month which is expected to move much of the Android Core into MarketPlace updateable apps so that the fragmentation that Android is suffering from can be lessened.
 
Google Navigator??? Need I say more on that, who needs to spend £60 on TomTom now that Google provide turn by turn directions app for free!
 
So what in the past 7 days have I missed from my iPhone? Actually, nothing. Gaming was very 'casual' for me, in the office we'd get the weekly game of the week buzz, like Flight Control or Angry Birds but then the interest dies off (as Apple has shown) and purchased games were seldom revisited. Everything I could do on my iPhone I can still do on my Android phone, faster and usually better than the iPhone way. Who knows, maybe come June I'll regret jumping but at the moment I'm really enjoying Android!
 
Next time, some apps I've found pretty useful...

Time for a blog reboot here too...

17 blog postings in almost a year - that's pretty poor if I do say so
myself so even though I've done this before it's time for another
reboot.

For my 2010 reboot I'm ditching WordPress, yep - ditching WordPress,
ditching MediaTemple and moving to Posterous.com - an entirely new
paradigm on blogging, infact I'm writing this post in my email
client...more on Posterous in another post. I used to spend far too
much time picking WordPress themes, gone are those days - I'm just
going to worry about content now.

So where do I want my blog to go, well there have been many other
changes in the past year from moving entirely to a Mac, ditching my
iPhone and having a baby...

My first OSX failure and my new backup routine

Last week I suffered my first OSX failure on my 2 year old iMac. This machine is on 24x7 with a bit of 'sleep' here and there. It's my primary machine at home used for iTunes syncing along with the occasional browser session, nothing too strenuous.

I came home from work on Monday and noticed it was just showing a background wallpaper, no mouse response or such like so I resorted to a hard reboot. On rebooting I was presented with the grey boot background and an image of a flash folder - uh oh! My first Mac boot failure. Now I wouldn't have been concerned as I use Mozy an online backup tool (a bargain at $4.95 for unlimited backup) but in this case I'd just added a load of videos from my wedding and honeymoon and knew that it was taking a while to backup - one downside of online backup. I also make heavy use of DropBox with symbolic linking so important stuff like bash customisations, ssh keys etc are shared between my machine as well as various project directories so I knew these were all safe. I booted from the Snow Leopard CD (holding down the C key) to run the disk utility but a verify/repair didn't work and kept returning 'Invalid Node Structure' message. Uh oh! Then I remembered about 'Target Disk Mode' using a Firewire cable between two Macs and holding down the 'T' key on boot - all this let me connect to was my Vista boot camp partition - ah, so I could browse that but not the OSX partition. I figured out that if it were a hardware problem the Vista partition wouldn't have booted, but it did. Still getting nowhere I did a bit of Googling and eventually found software that enabled me to see the contents of the OSX partition so I hurried out and got myself an external 1Tb drive so I could copy the data off resound to the fact I'd be rebuilding this machine - which again wasn't really a problem since this Mac was originally Tiger, then upgraded to Leopard and subsequently Snow Leopard. After rebuilding the machine the drive I'd previously purchased was immediately enabled as a Time Machine backup volume, moved the data back from the disk to where it should be on the computer and reinstalled Mozy (after contacting technical support to find out what it would do since it would already have the data backed up and I haven't restored it from them). So now reflecting back on this scenario I've come to a number of conclusions. Firstly, backup, backup, backup.

  • Online backup tools like Mozy, Carbonite are great to get your most important and valuable data (I'm thinking primarily Photos and Videos) out of your house but are severely limited by upload speeds and presumably download speed if you've got a lot of data stored to retrieve.
  • DropBox is great for smaller content, documents, code repositories (my Rails projects using GIT are in a DropBox folder, no need to remote sync to locations like GitHub)
  • Local backup is still essential, getting data out of your house covers you if your house burns down or such like but hardware failure is much more likely - if you're not already get yourself an external drive to use as a Time Machine vault. I noticed that you can restore a machine from Time Machine backup during the rebuild process - this would have saved me significant time and effort had I already been using Time Machine.
  • Lastly, OSX isn't as rock solid as I thought. There are plenty of 'Invalid Node Structure' results on Google but I couldn't find any definitive answer/solution to the problem.

Hope that helps someone...

UK Broadband Tax - WTF?

So there's two things in life that are certain - death and taxes. The Chancellor of the UK has in his wisdom today announced/confirmed in his pre-budget announcements that a new 'Broadband Tax' will be introduced that will be used to;

....fund the installation of "super-fast" broadband to 90% of the population by 2017.

It will be £6 a year and everyone in the UK with a land line will have to pay the tax. WTF? That's pretty much 99% of the population I'd imagine aiming to raise around £150m a year to fund the roll out. So, let me get this straight - The government is taxing me to pay a private company (British Telecom) to roll out fast broadband to the population???? I already have fast broadband thanks, I saw the light and left BT's crappy antiquated copper crap and went to Virgin Media where I really do enjoy 10Mb of speed and can wind it up to 50Mb if I so choose. It's also to fund roll out of broadband to 'rural areas' - does the government not think that perhaps people move to rural areas to get away from modern tech? Broadband has been rolling out quite steadily over the past years and yes, maybe the UK is behind the rest of the world in speeds but haven't we got more pressing issues to worry ourselves with like the mess the bankers got this country in and the massive bailouts I'm we are already paying for!! The good news is the conservatives say they would scrap this 'legislation' if they got into power - Labour your days are numbered!

Gotcha using cfscript queryservice with in clause

Here's one that had me stumpted for a little while. We have all our CFCs implemented using CFSCRIPT as CF9 has provided us the ability to do and we had a situation where we needed to perform a SQL query with an IN clause. In tags that's a pretty routine query but in script we kept getting errors.
queryservice.setName("users");
queryservice.setdatasource(get('datasourcename'));
queryservice.addParam(name="usergroups",value=params.usergroups,list="yes");
result = queryservice.execute(sql="select email from users where user_group_id in (:usergroups) ");
writeDump(result.getResult());
Seems pretty straightforward right? We knew that params.usergroups may be a list so we'd accounted for that in the addparam - it's a series of checkboxes for the user to select using this syntax we got the error message returned; Named Sql parameter 'usergroups)' used in the query not found in the queryparams Well, after some more head scratch we found the problem - when you're using named parameters using a notation similar to symbols in Ruby with brackets in the SQL statement they need to have a space AFTER the name of the parameter! So (:usergroups) becomes (:usergroups ) - notice the extra space. Hope that helps someone!

Storing your assets on Amazon S3

Amazon S3 makes it really simple to get your assets, aka your stylesheets, images etc off your webserver. There are numerous advantages for this - not only can it save you money in bandwidth it also has an affect on your website performance. Most browsers (if they comply with the RFC) will open a maximum of 4 HTTP connections to a single URL, that is to say that it is able to load 4 assets simultaneously from a URL - this behaviour is easy to see if you use the Net panel of Firebug, you see the assets 'stair stepping' as they load. Now the easiest way to boost your page load time is to create (assuming you have the necessary access to the server) a new virtual server pointing at your assets folder and have it setup with host headers like assets0.yourdomain.com, assets1.yourdomain.com and then ensure that your assets load from http://assets0.yourdomain.com etc...but this still means that it's coming from the same server. Enter Amazon S3. It's marketed as 'storage for the internet'. It's cheap storage with cheap access rates which can be public or private - to give you some idea of price I store about 25Gb of photos up there and my last bill was about $3 - granted those photos are not accessed so I'm not paying for GET requests since I'm not requesting the data but I sleep soundly knowing all my photos are safely backed up out of my house (I use JungleDisk on my Mac/PC to perform this backup for me!) Anyhow, I digress. Amazon S3 can be accessed in a variety of ways - the simplest is to use the S3FOX plugin for Firefox. With S3 you start off creating a 'bucket'. Whilst you can name a bucket anything, it's best to keep it globally unique using a FQDN, such as assets0.mydomain.com. Amazon will let you create a none globally unique bucket name but behind the scenes it would have been made unique. There are infact different rules for buckets stored in the EU, these must be DNS compatible Buckets by default are private along with anything you place in the bucket - to allow the assets to be public you need to edit the ACL for the bucket and allow 'Everyone' read access and apply this to the subfolders too. Assuming you've done that then your assets would now be accessible via http://s3.amazonaws.com/assets0.mydomain.com/ and also via http://assets0.mydomain.com.s3.amazonaws.com/. But it doesn't stop there - assuming you've setup a FQDN name for your bucket, eg assets0.mydomain.com then you can create a CNAME record in your own DNS for your domain named assets0.mydomain.com and set the value to assets0.mydomain.com.s3.amazonaws.com and then load the assets directly from http://assets0.mydomain.com. For a more detailed instruction set on Amazon S3 consult the Amazon documentation.

Importing data into a Rails application

There will come a time when you need to import data into your Rails application. Our time was now. We needed to move some data from a PHP based forum into a shiney new Rails application using Eldorado for it's forums (this fortunately followed a very similar schema) - which means nice shiney ActiveRecord models. We were provided a mySQL backup of the existing forums so off we went. So where to start - well at first glance it seemed like it was going to be troublesome but it turns out it's not that bad thanks to ActiveRecord. First up, we need to create a connection to a mySQL server - we'll do this via database.yml (fortunately you can have multiple db connections per application); [sourcecode language='ruby'] # database.yml legacy: adapter: mysql database: host: 127.0.0.1 username: password: [/sourcecode] Then we essentially needed to 'ActiveRecord-ify' the legacy models coming from the mySQL database - fortunately ActiveRecord makes this super simple. So we created a Legacy:Base class which extended ActiveRecord base classes; [sourcecode language='ruby'] # legacy.rb class Legacy::Base By extending the legacy base class which extended ActiveRecord our legacy models get full ActiveRecord support rolled into them - so it's then super simple to iterate over the data and create a new model object for use in the new application, populate the object and then save it. And of course, since it's ActiveRecord we don't care what the target database is. In the end, we created a rake task to create a repeatable process for importing the users from the DB - which also allowed us to handle any situations where the data we were trying to insert into our new models was failing validation.

Monitoring servers with Server Density

 Serverdensity.com is a new UK based, hosted server monitoring solution. Think Nagios, but given a Web 2.0 makeover but not quite as many features and certainly not as complicated to configure. I'm not sure where I heard about them from, but I'm glad I did.

Monitoring is done via an agent (written in python) installed on the server to give access to various standard metrics as well as stats exposed by mod_status on Apache. At the moment it's only supported on Linux/OSX but they are working on a Windows agent. Server Density provides both a web based dashboard as well as an iPhone application (free). The dashboard displays summary data as well as various graphs which reveal what's going on on your server. Alerts can be configured against metrics and delivered via email, sms as well as iPhone notifications! My first iPhone application which uses notifications! Woohoo!

You're able to trial the full service for 30 days, after which you can continue to monitor a single server but without the pleasure of the iPhone app, limited alerts and data is only retained for 1 month. After the trial period is over it's going to cost you £10/$15 a month per server - a tad pricey I think though. I've been using it for a few days now and already have caught 2 instances where my server was overloaded and using overly high amounts of resources - no real bother since I'm running on the Rackspace Cloud so just allocated more resources to my server. The team behind it also have an excellent blog at http://blog.boxedice.com which has some *REALLY* insightful posts into how they outgrew Virtual Servers, moving from a relational DB to a non relational DB (MongoDB) and how they implemented iPhone push notifications - it's well worth subscribing too! If you're in the market for server monitoring then it's worth taking a look at!

My new password management technique

So we're all guilty of it - we have one favorite password (or hopefully a selection of passwords) that we use around various sites for our  email, IM clients, twitter, facebook etc etc. If we're not guilty of this crime - our wives, girlfriends, partners, family members, friends certainly will be! I've never been comfortable with this method - sure it's convenient but in these times we need to be ever more aware of protecting our online identity.

As a result of this weeks FLOSS which had Eric Jung author of FoxyProxy on the show, he also spoke about his other tool PasswordMaker which really attracted my attention. PasswordMaker does exactly what it says on the tin, makes passwords. It exists in a variety of formats, a Firefox extension, an OSX desktop widget, an online version (with code available as download) and many more! But where PasswordMaker differs is that it will generate you a complex password for each site/resource you visit and you don't need to store them anywhere - you only need to remember one password - "One password to rule them all!" It works by taking your master password along with the address of a website (usually just the domain bit or any other string) and generating you a complex password using a one way hash - it will generate the same password every time if you enter the same master password, account settings and address/text string so you don't ever need to store the generated passwords, you simply regenerate them each time - and with the multitude of methods available to generate passwords it's made really simple. There are many different encryption algorithms to choose from, password lengths, password characters so provided you use the same settings whenever you want to retrieve your password then you'll always get the same password returned. The Firefox extension makes it really simple - on clicking the icon you are presented with a screen to enter your master password, the 'using text' field will have been prefilled with the domain of the site (configurable to use subdomain, query string etc too via options) you are visiting. Once you enter your master password, the extension will generate a password which you can copy to the clipboard and use it from there - it even clears it after a set amount of time. Should you need to generate a password for say MSN, then you can override the address with a simple string of text say 'msnmessenger' which will then be used to produce a password for you - equally server logins, FTP accounts, DB connections - provided you have a master password and a memorable unique identifier for the thing being secured then it will work for you - provided you can accept a minor inconvenience to have to enter your master password each time you need to use it. It's really worth checking out! Why not try it on a few sites and set how you get on...surely being safer on the internet is worth a little inconvenience? ps If you have room for another podcast then add FLOSS to your pod catcher - it stands for Free Libre Open Source Software.