Melbourne Facebook Developer Garage Presentation

February 24th, 2008

On Friday I had the privilege of presenting at the Melbourne Facebook Developer Garage.

I’ve uploaded the slides for my Introduction to Facebook Development talk.  I had to leave early due to some client commitments, but the talks were excellent and I met some very interesting people working in the Facebook space.

There is also a Melbourne Facebook Developer Group - I am keen to get another event organised really soon.

backup_fu: making Amazon S3 backups simple

February 17th, 2008

My favourite new plugin for Ruby on Rails is backup_fu.

backup_fu makes managing Amazon S3 backups really simple.

I have been running my own Rake Task for MySQL Backup to Amazon S3, but I’ve switched my projects over to backup_fu instead because it has much better control over your backups and will even backup stored files.

I’ve also created a patch for backup_fu that allows you to specify the mysqldump options. It should get rolled into an upcoming release, but if you would like it sooner, just contact me at toby@info-architects.net.

CodeIgniter: I Don’t Hate It

February 14th, 2008

The unfortunate tragedy of my life is that I don’t get to develop in Ruby on Rails all the time. No, unfortunately for me, a large number of my clients need work done in PHP.

Which, as already indicated in several previous nuanced discussions, I hate.

I mean, really really HATE.

But that’s not the point of this post.

After being seriously burnt by the twin miseries of CakePHP’s poor documentation and desperately misguided attempt to mimic Rails I went looking for a new PHP MVC framework for a recent project.

Crucial requirements:

  • lack of opinion
  • simplicity
  • good documentation
  • understands PHP is not Ruby

I really wanted something that was pure VC, leaving out the M.

Views, Controllers and Models can go to hell.

PHP’s complete lack of dynamicism (and yes, I know PHP 5 has a crack at it, but whatever) means any attempt at Hibernate or Rails-style ORM is doomed to failure. And after screaming at CakePHP every time a finder returns an array of nested hashes of arrays of hashes and you can never work out how to just iterate through the records I’ve gone back to ADODB. You run a query and are returned a Record Set. I know this just reveals how long I spent in the late 90s hacking ASP, but if any language was still living in the late 90s, it’s PHP. And it’s actually quite good at it.

Where was I?

Right. Clean View/Controller mechanism. No Models.

Enter CodeIgniter.

It’s incredibly simple, the only assumption it makes is that you may never need most of the stuff it includes, so everything is an option, and it has great documentation.

CodeIgniter: I Don’t Hate It.

If you really have to use PHP, it’s worth a look.

Installing Rails, Mongrel on Slicehost with Ubuntu “Gutsy Gibbon”

February 4th, 2008

Links for future reference on Installing Rails, Mongrel on Slicehost with Ubuntu “Gutsy Gibbon”

Slicehost Configuration Guide:

Party like it’s 1999 - Social Networks are for Suckers

January 28th, 2008

It feels to me a lot like 99. Recession on the horizon, and so many people rushing to jump on the NextBigThing, with little thought, planning, insight or vision.

Every other day I quote on another Social Network project. It’s not my idea, I just need to pay the rent.

All of the requests are essentially the same

Like Facebook for X

Where X is a niche market.

Or the ever-popular:

X but with social networking features

Where X is an existing service or product.

My answer is fairly consistent.

I can do this, but it might make sense to develop something using the Facebook API and leverage the existing network and tools.

Despite this advice, many people seem convinced they can play in this space.

The hard part is not the software.

The hard part is building the community in the first place.

You can download any number of free applications that can manage an online community - the technology is not the problem. The real problem is attracting people to your application.

The true value of the Facebook Platform is the network. Facebook have the community already - all you have to do is build an application and participate in the social graph.

It’s still a hard job, but it’s easier than starting from scratch.

To this end, and given that most of my work in recent months has been developing Facebook Applications, I have started my own software company, aimed at doing exactly this - leverage the existing social networks:

FiniteStateMachine - Software Development for Social Networks

If you’re thinking of building a social network or social network features, why not discuss your ideas with us first, we might just be able to help you save time and money with a strategy for Facebook and friends.

Dear PHP and CakePHP

January 11th, 2008

I hate you.

That is all.

Facebook Page and App Launch: Gillette Venus Beach Vote

January 10th, 2008

I’ve just completed development of another Facebook Application for a major promotional campaign for Gillette.

The Venus Beach Vote application manages a voting competition inside Facebook and  is tightly integrated with the Gillette Venus Beach Facebook Page. It was developed in CakePHP with PHP 5, MySQL 5 and uses FBML for the presentation layer.

The new Facebook Page functionality expands the possibilites for marketing inside Facebook considerably - brands can create a page and then allow applications to interact with both the page and user profiles.

Venus Beach Vote is my largest Facebook Development Project to date and developed in a very short time frame to hit a hard deadline. I am even going to take a day off this weekend, I think I’ve earned it.

Why Rails is better than whatever it is you use: ToDo List in 5 Lines

December 18th, 2007

Rob Mayhew prepared this ToDo List Tutorial

  1. rails todo
  2. cd todo
  3. rake db:create:all
  4. script/generate scaffold Todo title:string body:text done:boolean due:datetime
  5. rake db:migrate

Update: This code pretty much also provides you with a REST API.

Amazon SimpleDB: death of the database?

December 15th, 2007

With the announcement of Amazon SimpleDB Scoble has asked if Amazon Web Services are going to kill MySQL and Oracle.

I think the short answer is no, but the game is changing rapidly, and Amazon is at the vanguard.

SimpleDB basically acts like a big structured bucket.
The Model is represented by Domains. A Domain can have Attributes. Attributes are key/value pairs.

There is no schema attached to Domains, you can PUT any combination of attribute-values in the domain:
PUT (item, 123), (description, sweater), (color, blue), (color, red)
PUT (item, 456), (description, dress shirt), (color, white), (color, blue)
PUT (item, 789), (description, shoes), (color, black), (material, leather)

The real issue here is that developers are strongly tied to the RDBMS. Frameworks assume you are running on top of a relational database, so there is an instant barrier to entry. However, I suspect it won’t be long before the first set of libraries and drivers for SimpleDB are developed.

The much bigger issues are in the features that SimpleDB doesn’t have:

  • No ACID
  • No transactions (see ACID, above)
  • No relationships
  • No data integrity
  • No SQL
  • Latency

SQL is actually pretty incredible - it makes accessing structured data very simple. If you’ve ever played with other types of data store you miss SQL almost instantly (Prevayler, anyone?).

All of that said, Amazon continues to lead the way with Web Services. Consider SimpleDB a warning shot to the database incumbents.

Facebook How-To: scheduling profile updates

December 10th, 2007

Several of the Facebook Applications I have developed have required scheduling updates to Facebook User Profiles.

The process for scheduling updates is a little involved, but basically involves using a Session Key to push data to each User’s Profile.

  • Store the user’s Session Key.
  • Schedule an update with Cron
  • User the User ID and Session Key to create a Facebook Client Object make a Facebook API call.

The following samples are from a CakePHP project I recently completed and use the Facebook PHP Library. I’ve expanded the SQL so you have a better idea of what is happening behind the scenes.

Store the Session Key:

function beforeFilter() {
$this->facebook_user_id = $this->facebook->require_login();
$this->sessionKey = $this->facebook->api_client->session_key;
$this->Settings->query("UPDATE settings SET sessionKey = '{$this->sessionKey}' WHERE id = '{$this->facebook_user_id}'");
}

Each time the user hits the application I generally refresh the Session Key in my normal login/authentication process.

Make the API Call:

$data = $this->Settings->query("SELECT * FROM settings WHERE lastUpdated <= DATE_SUB( NOW(), INTERVAL 1 DAY) ORDER BY lastUpdated ASC LIMIT 1");
$id = $data[0]["settings"]["id"];
$sessionKey = $data[0]["settings"]["sessionKey"];
$this->facebook = new Facebook(FB_API_KEY, FB_SECRET);
$this->facebook->set_user($id, $sessionKey);
$this->facebook_user_id = $id;
$this->facebook->api_client->profile_setFBML($fbml);

This code grabs the first Faccbook User from the database who last updated a day ago and then creates a Facebook Client using the Facebook User Id and Session Key to make an API Call.

Note: When scheduling updates I generally use Cron to call a URL on my application with wget or Curl. Using this technique you can leverage the existing logic of your app and don’t have to write a standalone script.