Floyd’s Thoughts…

Because Everything is Interesting!!!

Archive for the ‘Development’ Category

Automatic Elastic Block snapshots with a cron job

without comments

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) ;-)

Written by Floyd Price

October 20th, 2009 at 11:01 pm

How to respond to the IPhone Shake Gesture

with one comment

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!

Written by Floyd Price

October 20th, 2009 at 8:48 pm

JRuby.com

without comments

For as long as the JRuby project has been going the jruby.com domain has been owned by a nasty little Domain Squatter, but recently the Company I Work For purchased the domain off the before mentioned toe-rag for a small fortune.

Today the domain is being send to it’s rightful resting place, that is, we are giving it to the JRuby project.

Hip Hip Hooray!

Written by Floyd Price

October 14th, 2009 at 12:36 am

Fixing the little things.

without comments

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.

Written by Floyd Price

August 24th, 2008 at 10:19 pm

Profound #1

without comments

An Investment in knowledge always pays the best interest.

Benjamin Franklin

Written by Floyd Price

August 24th, 2008 at 9:57 pm

Exception Notifier in Rails 2.1

with one comment

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 :-/

Written by Floyd Price

August 20th, 2008 at 6:29 pm

Posted in Coding, Development, Rails, Ruby

Rails in the Enterprise

without comments

I love Rails and use it all the time, fortunately the company i work for builds web products that lend them selves to the Rails way, however we also do consultancy work for larger Enterprise companies where Rails doesn’t lend itself so well.

I’d love to see Rails include features that would ease its adoption within the enterprise, here are a few things that i’d like to see:

Better support for Windows
Now it hurts me to say this as everybody here loves OS X and our products are built for OS X or linux deployment but many (i’m inclined to think most) enterprises use Windows for deployment of internal intranet apps.

With the release of Mod_rails, deploying ruby apps into production is now only easy its reliable, Enterprises organizations need both of these things, but i think they need them on windows too.

Support for Stored Procs
Now i now its pretty easy to add this support (and i will get to that later) but having Stored Procs support baked into Rails would make using Rails in a enterprise environment so much easier.

We have been to many large companies to build large internal intranet applications and in every one of them we have had to interface with legacy systems via APIs that are exposed by stored procs.

Telling a client that you are going to use Rails in this environment consistently produces a look of horror from the clients technical guys and follows with a Rails can only do Object Relational Mapping discussion.

Any (that i have met) technical architect in the corporate work will dismiss rails for its (perceived) lack of Stored Proc support.

I’d like to see this functionality baked in to rails and advertised as a “Feature”.

Integrated Development Environment
Right now i can think of at least 6 IDE’s that support rails and thats not including TextMate (which i use).

Of all the IDE’s that i have tried NetBeans is the best, it has good all round support for rails but even still, its miles away from what a corporate developer would consider a good IDE for rails development.

Developers need refactoring tools in any language but the need for good refactoring is greater with dynamic languages, netbeans has one refactoring option enable when using rails “Rename” and even that doesn’t safely rename.

Now i’m not suggesting we need Resharper for rails before corporate developers adopt rails but somewhere in between resharper and what we have now would be a good start.

Address the Scaffolding Myths.
Every rails developer knows that scaffolding was (pre rails v2.x) pretty useless but served a good purpose in helping to increase the Buzz around rails with the promise of one click application stubs.

In rails 2.0 scaffolding is Slightly more useful in that it creates nice Restful controllers and some pages to help you get going with the first few resources in your application however, the Rails community needs to address the perception thats rails is all about scaffolding.

So many times i have had conversations with Tech Leads, Development Managers, Developers, etc about rails being more than scaffolding, usually they are amazed to hear that most rails developers don’t even use scaffolding in there apps.

Its as if this great little feature of rails is holding it back in the minds of “serious” corporate developers, who don’t see scaffolding for what it is.

Database Support
Active Resource is an amazing piece of work, I often go through the Code Base to see how certain things are done and find myself gushing over the code in there its amazing…

However, since Rails v1.2.6 the core team seem to have lost interest in Databases other than sqlite and mysql, which is all good and well for the the Web 2.0 community, however corporate guys need Oracle and/or Microsoft SQL Server support out of the box, and it seems that using either of these engines now requires extra gems and some hacking around. I have had many conversations with devs who “tried” to use rails but couldn’t get it to connect to Oracle. After looking around the web they often got frustrated by the contradicting and out of dat solutions to this problem and gave up.

If rails is living on its promise to give database independence and Rapid development thought active records object relational mapping magic it can’t force corporate developers down a wild goose chasing for gems, it need to work – Out of the box.

The Solution…
Well rails is young and i’m certain that these issues will be resolved given time, however i think its the responsability of all rails developers to increase its presence in the Corporate world when and where ever we can.

As such I’m going to start a Rails in the Enterprise site where issues such as the ones i have highlighted can be discussed, resolved and communicated to the corperate world.

I’m like to see this site become a one stop resource for corporate developers who are trying to use rails.

Written by Floyd Price

August 17th, 2008 at 12:20 pm

Using jQuery in Rails apps

without comments

jQuery is an alternative to the Prototype JavaScript library that is gaining some real traction these days.

jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. jQuery is designed to change the way that you write JavaScript.

jQuery also sports an elegant model of method chaining where almost all methods return an instance of the object they are called on, this means you do do stuff like:

	$("p.surprise").addClass("ohmy").show("slow");

The only problem is I love using Rails which has many helper methods that make using Ajax really easy which use the Prototype JS library, so ncluding jQuery as well as Prototype is not only a pain it also means i’m doubling the amount of javascript i ship with each page.

Fortunatly the problem has been solved via a cool rails plugin called jrails.

jrails is easy to install (script/plugin install http://ennerchi.googlecode.com/svn/trunk/plugins/jrails) and replaces all the calls to Prototype with calls to jQeury allowing you to remove prototype from your application without loosing any of the rails magic.

Written by Floyd Price

August 16th, 2008 at 11:03 pm

Estimating – I love estimating.

without comments

Estimating is one of those tasks that really takes it out of the whole team, hours or even days of reviewing stories and estimating the effort is hard work.

The temptation is to crack on and keep going until the task is done however I can’t stress enough the importance of taking time away from this process to recharge and re-engage with the subject mater.

Some techniques for making the process less onerous (if thats possible):

Story Rotation
Often teams will follow a story list as it define by the BA, which in my opinion can lead to less informed estimates, having discussed the attributes of one story only to be presented with another similar story can often lead to dismissive estimations where in isolation the story may reveal more detail.

Take Breaks
Accept that a fresh mind is better at dealing with problems, taking a break is one of the most productive things you can do.

Give everyone a stage to express their opinion
So often the dev lead will take up most of the air space while more “junior” members of a team will sit nodding (or nodding off). Give your whole team a chance to engage in this process after all you will expect them to work in this project right?

Have Fun
Enjoy the process by making it fun! Use novel gestures for estimating or high five when you all agree, whatever it is you guys do that is fun, do it and do it more often, having a laugh will make the most onerous of tasks less so.

Estimating has to be one of the tasks i “enjoy” the least however, its value is without question.

Written by Floyd Price

August 14th, 2008 at 10:45 pm

Posted in Agile, Coding, Development, Team

Get Adobe Flash playerPlugin by wpburn.com wordpress themes