Archive for August, 2007

How not to hire …

Friday, August 31st, 2007

37 Signals has a post about Writing Better Help Wanted Ads, which has some excellent advice and a summary of some ideas from around the blogospehere.

I have had some pretty bad (and sometimes actually rude) encounters recently as a Freelance Developer.

A fairly typical example was this response to my considered, thoughtful and detailed application for an advertised position:

I am looking for freelance web programmers who are proficient in the
following:
-HTML, CSS, JavaScript and Flash up to $20/hour
-with PHP, MySQL and Linux, and willing to learn Ruby on Rails up to
$22/hour
-with Ruby on Rails _experience_ up to $25/hour

I prefer programmers with Ruby on Rails experience, but will consider
you if you have _very_ strong skills in the first two items.

You must be able to work under tight deadlines. I prefer people who are
proactive and have a good design sense. You must be a proficient
programmer. You must be willing to take design direction, and work under
an established set of procedures. Work availability varies.

I read this as:

  1. You must be cheap
  2. You must have lots of experience
  3. You must not value that experience (see points 2 via 1)
  4. You must work really hard and under pressure
  5. You must do what we tell you
  6. You still may not get any actual work

There’s no mention of the types of work, the flavour of the projects, or why I might be interested.

On top of all this, it was instantly evident that the responder hadn’t read my application - I had actually detailed my most recent experience with Rails (and other relevant technologies) on several “real-world” projects.

The fact is:

If you are good at your job, you can choose the work you do.

Finding good people is hard, regardless of industry, but particularly in software development. The employment or negotiation process is as much about the potential employer selling the role as it is about me proving I am good at what I do.

I’m certainly not saying you need to treat me like a God of Code, but perhaps you should actually read my job application …

self.Team

Wednesday, August 29th, 2007

I’ve registered for the RailsRumble as a one-person team called, cunningly: self.Team

See what I did there?

I am going to be building a game - a browser-based, AJAXified wargame loosely based on the Roll Out The Gun Barrels ruleset. I’ll be posting a few design ideas over the next week.

Ready to Rumble

Monday, August 27th, 2007

Rails Rumble has been announced. 48 hours to build an application from scratch.

I am going to enter … as a solo developer. I think I will attempt to build the game I have been occasionally designing for the last couple of months. Or maybe my idea for a Google Adwords Landding Page Manager. I’ve already signed up for the AdWords API …

Rake Task for MySQL Backup to Amazon S3

Saturday, August 25th, 2007

There are a couple of these around, but I rolled my own because I wanted something quite simple.

# S3 Backup Task for MySQL
# Assumes InnoDB tables
# Database User needs the "reload" permission on the database (for --flush-logs in mysqldump)
#
# Stores files in Amazon S3 using the excellent AWS Gem: http://amazon.rubyforge.org/
# For information about Amazon S3: http://aws.amazon.com/s3
#
# Installation
# 1) Install AWS Gem
# 2) Enter your S3 Bucket, access_key_id and secret_access_key in this file
# 3) Run (rake db:backup)
#
# Inspired by code from:
#   http://blog.craigambrose.com/articles/2007/03/01/a-rake-task-for-database-backups
#   http://www.rubyinside.com/advent2006/15-s3rake.html

namespace :db do
  require "aws/s3"

  desc "Backup database to Amazon S3"

  task :backup => :environment do
    BUCKET = "bucket"

    begin
      AWS::S3::Base.establish_connection!(
        :access_key_id     => "access_key_id ",
        :secret_access_key => "secret_access_key "
      )

      db_config = ActiveRecord::Base.configurations[RAILS_ENV]

      backup_path = "db/backup"
      File.makedirs(backup_path)

      datestamp = Time.now.strftime("%Y%m%d%H%M%S")
      file_name = "#{RAILS_ENV}_#{db_config['database']}_#{datestamp}.sql.gz"

      backup_file = File.join(backup_path, file_name)

      sh "mysqldump -u #{db_config['username']} -p#{db_config['password']} --single-transaction --flush-logs --add-drop-table --add-locks --create-options --disable-keys --extended-insert --quick #{db_config['database']} | gzip -c > #{backup_file}"
      puts "Created backup: #{file_name}"

      puts "Storing file in S3: #{BUCKET}"
      AWS::S3::S3Object.store(file_name, open(backup_file), BUCKET)

      puts "Backup Complete"
    rescue AWS::S3::ResponseError => error
      puts error.response.code.to_s + ": " + error.message
    end

  end

end

Managing Amazon S3 on Mac OS X

Friday, August 24th, 2007

While we’re talking Amazon S3, I found the Mac OS X S3 Browser, it works really well for managing your S3 account.

Speaking at Melbourne Ruby User Group

Friday, August 24th, 2007

I’m speaking at the Melbourne Ruby User Group next week. Either on using Amazon Web Services. or hacking with Prototype (probably focussed on the new 1.6.0 features).

Lineup & Location

ThoughtWorks
Level 11, 155 Queen St

  • Pete Yandell - SpiffyAttributes
  • Clifford Heath - HAML
  • Mike Bailey - Jester
  • Ben Schwarz  - JS Hacking
  • Toby Hede - Amazon AWS and/or Prototype Hacking
  • Marty Andrews - Logging and/or the Rails Plugin Architecture

Snippets: dynamic CSS classes

Tuesday, August 14th, 2007

I found myself over the weekend needing to create CSS classes dynamically. Not just add a class to a DOM element, which is easy, but actually building a CSS class based on user input and attaching it to selected elements.

Proved to be harder than it sounds.

  var green = {
    color: "#00FF00"
  };

  Object.extend(Element.Methods, {
    setClass:function(element, className) {
      element = $(element);
      element.addClassName(className);
      klass = eval(className);
      for (var property in klass) {
        element.style[property] = klass[property];
      }
    }
  });
  Element.addMethods();

  function changeClass() {
    elements = document.getElementsByClassName("red");
    elements.each(function(e) {
      e.setClass("green");
    });
  }

This code lets you specify a “CSS Class” as a Javascript object. Then you can use the Element.setClass to add the properties to the element style. The changeClass() function finds all the “red” elements and sets them to use the “green” Virtual CSS class. I use addClassName to add the new class name, which may cause conflicts with existing CSS classes.

The name is added because I was thinking that I would need a way to remove the class. At the moment I don’t, but it wouldn’t be all that hard to implement. You would store the element’s original properties and remove the class name, and reset all the overridden styles. The disadvantage of what I am doing is overriding the styles at the element level - these will take precedence in CSS.

I am positive there is an easier way of doing this with Prototype and Scriptaculous, so let me know if find one. I looked at interacting with the styles directly using the DOM, but it’s pretty messy.

REST: I don’t quite get it

Friday, August 10th, 2007

I’ve been playing with RESTful Rails on one of my projects. I must admit to being a bit perplexed.

You have to bend your code to get REST working properly, which smells to me.

For example, when editing a model, you need to push a hidden element into your form to spoof a HTTP PUT method. Rails automates some of this, but … why?  What do you gain by forcing the system to only accept puts for particular actions, particuarly when browsers need to be tricked into playing nicely?  What is lost by having an update action accept POSTs?

Anyway, I will keep playing …

2 things I most loved about Ruby on Rails this week

Thursday, August 9th, 2007
  1. attachment_fu
    From install to an Image Upload with Amazon S3 storage in about 10 minutes. See the attachment_fu tutorial.

  2. RESTful rails
    An XML API for nothing? Why thanks, Rails.

The REST stuff is really fun to play with … I am finding it breaks a little in the real-world with non-trivial use-cases. Start adding auto-completes and other AJAX elements to your page and you start bending the RESTful model a little. I am figuring it’s best to have the core REST architecture and build on it, rather than bend my code to adhere mindlessly to some REST ideal.

I {heart} Rails.

Amazon Flexible Payment Services

Tuesday, August 7th, 2007

Amazon continues to lead the way into a service-driven future with the release of the Amazon Flexible Payments Service:

Amazon Flexible Payments Service (Amazon FPS) is the first payments service designed from the ground up specifically for developers. The set of web services APIs allows the movement of money between any two entities, humans or computers. It is built on top of Amazon’s reliable and scalable payment infrastructure.

FPS supports micro-payments and the fees look very competitive.

Payments are the last piece of the service puzzle and with the release Amazon now has a complete Operating System for services.