Development


12
Dec 11

.GitIgnore for xCode 4 projects.

xCode git support is great, but if your working in a team or on multiple machines you will want to ignore any user/machine specific files.

In my .gitinore I have:

.DS_Store
*.swp
*~.nib
build/
*.pbxuser
*.perspective
*.perspectivev3
xcuserdata/

Seems to work pretty well.


7
Sep 10

Adding touch support to jQueryUI

I needed a quick and dirty way of getting the jQueryUI Slider component to work with the touch events on the iPhone and iPad (iOS) so after a little thinking I started writing a few lines of jQuery that would listed to the touch events and pass them on to the relevant jQuery core classes so that any components based on jQuery would get the events for Free.

 

About 10 minutes in it occured to me that this must have been done before and while i like hacking with touch events, I did a quick Google and found the exact script i was about to write.

If your looking to add  touch support to jQueryUI components look no further than this Google Code project

 


5
Sep 10

iPad Multi-Touch – in Javascript.

ipad_touches_small.jpg

I recently came across a nice article/experiment from Matt Gemmell (@mattgemmell) where he decided to test how many simultaneous touches the iPad Multi Touch display would register, it turns out its 11 and he put together a pretty impressive demo app to prove it (see the Screen Shot).

At first sight you would think its a pretty complex application to achieve this, i mean all the multi touch stuff and the animation seems quite complex, however anybody who knows the iOS SDK will tell you that this stuff is trivial at best, and while Matt has done a great job of pulling it all together its far from complex.

The SDK that wasn’t mean’t to be

This application got me thinking about the iOS SDK and the fact that Apple originally didn’t want us writing native applications and in fact they wanted us to write Browser based applications in Javascript, HTML5 and CSS3.

Now its pretty clear to me that the native apps we see (in abundance) on the app store like Angry Birds, Twitterific, Pulse, Things, Pages, etc… could be written using JS, HTML5 and CSS3 but they would most definitely be poorer for it, come on, the runtime performance, the slick User Experience, simply can’t be replecated to the same level with an app running inside a Browser! (let the flame war begin)

So on that note i decided to replicate Matt’s Multi Touch application in Javascript, HTML5 and CSS3, so with a little digging around in Apples documentation I found all the Javascript events that expose touches (touchstart, touchend and touchmove) and began hacking!

Now let me say right now that this is one hours worth of hacking and the end goal was to build an application that was comparable to Matt’s, I suspect some of the code could be optimised, in fact I really hope that is the case when it comes to the Canvas drawing methods (but that is another story for another post).

multitouchtest.pngNow for some reason I fully expected the JS version to respond to less touches than the native version but in fact its 11 just like Matt’s Version, I also expected the animation to be less “smooth” and jerky when I was moving my fingers around, and I was spot on. The iPad benefits from multithreading and a graphics rendering pipeline, where the Browser that my app is running in does not so any processing I do to draw, calculate or respond to touch events all happens in the same thread as well as the browsers rendering code, this in a nut shell is the reason why these apps will not compete with Naive apps, I may in the near future re visit this topic and look at using HTML5 Web-Workers which in theory would give me the ability to run background threads, but i suspect that even that wouldn’t help too much for applications that are so closely coupled to the rendering engine.

Anyway, here is the application I wrote (visit it on an iOS device) it works almost exactly like the Original albeit its not as smooth. The source code is all inline (for your convenience) so feel free to take a look (lift, steal, optimise, laugh at, etc…) and let me know what you think.

My Conclusion

The iPad really is a “Magical” device, and with Great tools like Sencha Touch web developers are better placed than ever before when it comes to building native-ish applications, but I really believe that these apps will be the poorer relations to their native cousins. So keep learning Obj-C folks!


18
Jun 10

Rails can’t scale!

I’m not sure who coined the phrase “Rails can’t scale”? but its on of those things that amazingly keeps coming up, particularly when you talk to people in the corporate world who for some reason have it as the stock answer to any rails related discussions.

Anyway this is my Open Source answer to that statement, so please if anybody asks you “can rails scale” or makes the statement “Rails can’t scale!” please feel free to use this answer…

Applications built in rails are actually as capable of scaling as apps built in any other language (or on top of any other framework), in fact rails out-of-the-box is good enough for 99.9% of the applications you will ever write, and that tiny amount of apps that will have problems would have the same problems in ANY other language or framework. The benefits of Rails as a framework and Ruby as a language (Like Productivity, Maintainability, Developer Engagement, Mapping to an Agile Process) should in every case be considered over any notion of scaling issues. In fact if your app doesn’t have 8 million concurrent users right now, don’t worry about scaling at all, your wasting time that could be better spent getting 8 million users.

Now this answer doesn’t touch the real issue with this question but in my experience it is good enough to satisfy the type of people who ask this question.

The only exception where i wouldn’t use this answer is if the question (or statement) comes from a “Technical Architect” in a large corperate who is paid 6 figures a year to keep a development team of 100+ moving forward, if he says “Rails can’t scale” Punch him between the fucking eyes, because he should know better.

The truth, is of course that, anybody who says this knows f-all about software architecture and in fact shouldn’t be in a position where they have an audience to spout their nonsense.


17
Jun 10

Best Buy – Open Sources IdeaX

Best Buy has received much acclaim for its IdeaX platform over the last year, and rightly so. For anyone who isn’t away of IdeaX its an Idea Gathering application that allows Best Buy to capture ideas and comments from customers and staff members, which can then be voted or commented on buy other customers or staff members. The basic idea is that good ideas will organically rise to the top as votes and comments increase the “score” given to an Idea. Best Buy can then take a “good” idea and make it into a reality.

Idea Gather Applications (also known as Idea Management Apps) are not a new thing, many American corporates have already embraced this concept including Google and Dell, and while each have great apps the Best Buy IdeaX platform stands head and shoulders about the competition.

While browsing Hacker News the other day i noticed a post saying that the Best Buy IdeaX platform has been open sourced! This is a great step for Best Buy, Come on, a big non-tech US corporate releasing an Open Source product!!! its unheard of! Whats more the app is written in Ruby on Rails, which in its self is a massive step for a big corporate who would traditionally have written apps like this in C# or Java.

Check out the project home page for the full story, and be sure to take a look around the code ;-)

The project does take some getting going, you have to me using Postgress and be sure to check out the mad Postgress Specific stuff going on in the migrations. I plan on getting a version of it up and running on EC2 over the next few days (time permitting) so I will issue some instructions in a later post.

All I can say is Hat Tip to Best Buy, Great job!

 

 


20
Oct 09

Automatic Elastic Block snapshots with a cron job

Amazon EC2 really is amazing, and the Elastic Block storage is pretty darn good too, however I wish you could automate the snapshot process form the EC2 console.

It is however pretty easy to do yourself using a simple cron job.

Before you start make sure you have a JRE:

	sudo apt-get install sun-java6-jre

You will also need the EC2 API tools:

	wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip
	unzip ec2-api-tools.zip

At this point you should make a metal note of where you unzipped the api tools to.

Now that you have the prerequisites you need the following simple script:

	#!/bin/bash
 
	export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre/
	export EC2_HOME=/root/ec2-api-tools-1.3-42584
	export EC2_PRIVATE_KEY=/data/misc/pk-Umbongo.pem
	export EC2_CERT=/data/misc/cert-Umbongo.pem 
	export AWS_ACCESS_KEY_ID="Twinkle Twinkle Little star"
	export AWS_SECRET_ACCESS_KEY="If your happy and your know it, clap your hands"
 
 
	$EC2_HOME/bin/ec2-create-snapshot vol-999999

Obviously you need to specify your volume id where i have vol-999999

Once you have modified this file to be executable you are ready to test it.

	chmod +x snapshot.sh
 
	./snapshot.sh

Once your have ran it go to the EC2 Console and verify that the snapshot process has started.

And thats it, the first time you run this script the snapshot will take a while to complete but the next one will be much quicker as the snapshot process is incremental, so only the changes since the last snapshot will be read.

Oh, don’t forget to create a cron job for this (*/5 * * * * /path/snapshot/sh) ;-)


20
Oct 09

How to respond to the IPhone Shake Gesture

The IPhone 3.0 SDK includes support for detecting when a user “Shakes” the IPhone, this is intended to be a usability feature allowing app developers to implement Refresh or Read All functions on shake, wow those crazy guys at Apple really do know how to innovate!

It’s pretty easy to implement all you need to do is register your view controller as the first responder and listen for the motion event.

-(void) viewDidAppear:(BOOL)animated{
	[super viewDidAppear:animated];
	[self becomeFirstResponder];
}

Once your controller is the First Responder you can receive the motion event like so:

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
	if (motion == UIEventSubtypeMotionShake)
	{
		refresh;
	}
}

This will work beautifully but you will however notice that any views you present over this one will not respond to all touch events, for instance the keyboard will not show when you touch a text field, this is because you need to resign the First Responder before you present the view like so:

- (IBAction)showMyCustomView {    
	[self resignFirstResponder];	
	[self presentModalViewController:myCustomViewController animated:YES];
}

As you can see this is all pretty easy and the only gotcha is the First Responder stuff, which also is pretty trivial.

Enjoy and please people, Shake Responsibly!


24
Aug 08

Fixing the little things.

When your developing, enhancing, evolving your software you will introduce bugs which range from trivial UI issues to “Show Stopping” issue in business logic that will drive your customers away.

Its pretty easy to prioritize these bugs as tasks for your development team by making the “Show Stoppers” #1 priority and so on… and this list of priorities is often geared around the customer, we make sure the issues that the customer will react to the most are sorted out first and then we get to the other “trivial” issues later (if ever).

While this method of prioritization works well in theory I have observed that developers who are not allowed to fix bugs that annoy them or are “easy” to fix, often loose motivation and interest in fixing those bugs that are not so easy to fix.

I have myself worked on projects where the PM has taken exception to me spending an hour to fix and test a bug because I felt that it was worth doing even thought the “Plan” didn’t express this.

Its so important to let your development team cherry pick issues to fix as well as prioritizing the “Show Stoppers”.

Pragmatic Programmer

Why?

Developers love marking tasks as “Dev Complete”, it gives us a sense of achievement that motivates us to crack on with the next task at hand.

“Wasting” (if your a PM) an hour on a task that isn’t the most pressing one at the time can have a profound impact on your teams productivity, letting the developers mould the shape of the product by picking the issues, tasks to work on gives them a sense of ownership which brings with it a sense of determination to deliver.

I liken this to the Broken Window (Tip 4) theory expressed in The Pragmatic Programmer by Andrew Hunt and David Thomas.


24
Aug 08

Profound #1

An Investment in knowledge always pays the best interest.

Benjamin Franklin


20
Aug 08

Exception Notifier in Rails 2.1

If you have recenlty or are about to Upgrade an existing Rails application to Rails 2.1 (and why wouldn’t you), be aware that your implementation of Exception Notifier might not work due to a scope change in Rails where:

@controller.filter_parameters

Is now protected, therefore the code in Exception Notifier that called it needs to be change as follows :

1
2
   #exclude_raw_post_parameters? ? @controller.filter_parameters(parameters) : parameters
   exclude_raw_post_parameters? ? @controller.send!(:filter_parameters, parameters) : parameters

Utilizing the send method allows you to call the protected method.

Fortunately the Exception Notifier plugin on GitHut has already been updated to accommodate this fix and can be installed by :

1
	./script/plugin install git://github.com/rails/exception_notification.git

NOTE
Exception Notifier (like most plugins) comes with a suite of tests that you should run as part of your build or at the very least whenever you change something as fundamental as the Rails version your using… BTW I did neither of these things and found out the hard way :-/