July 21st, 2008
Been very quiet, but I have been working a lot, among other things.
I am happy to announce the launch of my latest Facebook Application: Telstra HeroMessage. You can read all about it at the Telstra HeroMessage® Facebook Application About Page.
I am pretty excited about it, a massive national media campaign is already underway.
Share This
Posted in Facebook, FiniteStateMachine | No Comments »
July 19th, 2008
Is all I think about
Share This
Posted in Uncategorized | No Comments »
April 19th, 2008
I’ve just released the first pass of a Ruby on Rails Plugin called Acts As Scheduled.
acts_as_scheduled allows you to manage scheduled events for your models.
A good example of this is scheduling the update of RSS Feeds in a background process using Cron or BackgroundRB.
With acts_as_scheduled your schedule manager can simply call “Model.find_next_scheduled()” to grab the next item from the database.
At the moment it assumes you are working with MySQL.
All you need to get started is to add two extra columns to your table:
t.integer frequency
t.datetime last_scheduled
frequency is the number of seconds for your schedule.
last_scheduled is the date and time the record was last processed.
Ruby on Rails is real smart with times, so you don’t have to worry too much about calculating frequency values:
model.frequency = 1.day
model.frequency = 1.minute
model.frequency = 10.second
In your model class your simply declare “acts_as_scheduled” and you now have two extra methods find_next_scheduled and schedule_complete.
find_next_scheduled
Returns the next scheduled record from the table.
The next scheduled record is calculated as “the record who’s last_scheduled value is less than the current time minus the specified frequency in seconds”.
Which is the complex way of saying “if freqency is 1 minute, return the record if it was last_scheduled more than 1 minute ago”
If there is more than one record, records scheduled to occur more frequently will be handled first (so records with minute schedules are returned before records with daily schedules.
schedule_complete
Sets the record’s last_scheduled value to Time.now
Example
class ScheduledItem < ActiveRecord::Base
acts_as_scheduled
end
schedule_minute = ScheduledItem.new(:frequency => 1.minute, :last_scheduled => 2.seconds.ago)
schedule_minute.save
schedule_day = ScheduledItem.new(:name =>”day”, :frequency => 1.day, :last_scheduled => 25.hours.ago)
schedule_day.save
#returns thing_day because it was last_scheduled 25 hours ago
schedule_day = ScheduledItem.find_next_scheduled
schedule_day.do_some_stuff
schedule_day.schedule_complete
schedule_day.save
Share This
Posted in Plugins, Ruby, Ruby on Rails | No Comments »
April 15th, 2008
The final piece in the EC2 web-hosting puzzle has been announced:
This new feature provides reliable, persistent storage volumes, for use with Amazon EC2 instances. These volumes exist independently from any Amazon EC2 instances, and will behave like raw, unformatted hard drives or block devices, which may then be formatted and configured based on the needs of your application. The volumes will be significantly more durable than the local disks within an Amazon EC2 instance. Additionally, our persistent storage feature will enable you to automatically create snapshots of your volumes and back them up to Amazon S3 for even greater reliability.
Until now the only way to get real MySQL storage has been to jump through some hoops with multiple EC2 instances or back the database onto S3 (with subsequent latency overhead). With 100GB of outbound data transfer the smallest ECV2 image will cost you about $90/month for 1.7GB of memory and a dedicated CPU core. The price just cannot be beat.
Share This
Posted in Amazon EC2, Amazon Web Services | No Comments »
April 2nd, 2008
For various reasons I need to be able to be able to accept some script input from the client.
The basic requirement is to be able to accept some Ruby code from the client in order to allow customisation of the HTML output from an RSS feed.
This is obviously a rather dangerous thing. I essentially need to allow arbitrary Ruby to be executed with an eval
However, in Ruby, we can run code in SAFE mode.
At Level 4:
Ruby effectively partitions the running program in two. Nontainted objects may not be modified. Typically, this will be used to create a sandbox: the program sets up an environment using a lower $SAFE level, then resets $SAFE to 4 to prevent subsequent changes to that environment
The core of my approach is to create a new Thread, set the SAVE level to 4 and call a method.
feed = FeedNormalizer::FeedNormalizer.parse(open(self.url))
thread = Thread.start {
$SAFE = 4
html = safe_method(feed, script)}
}
thread.join #wait for the thread to finish
The safe_method itself does a sanity check on the safe level. The method takes a feed object and a script - the script is processed using eval and because the feed object is in the context, the script has access to it. However, the safe level prevents any malicious code from attempting to use Ruby magic and meta-programming to gain access to variables outside the thread or any globals
def safe_method(feed,script)
if ( $SAFE < 4 )
raise “SecurityException: attempting to execute UNSAFE script”
end
html = “”
eval(script)
return html
end
The user can then pass in code that looks like:
html << “<h2>#{feed.title}</h2>”
html << “<ul>”
feed.entries.each do |entry|
html << “<li><a href=\”#{entry.urls.first}\”>#{entry.title}</a></li>”
end
html << “</ul>”
And the feed is processed without (too much) risk.
Share This
Posted in Code, Programming, Ruby, Ruby on Rails | 3 Comments »
March 11th, 2008
It’s been a while since I regularly read Jakob Nielsen’s Alertbox: Current Issues in Web Usability. Imagine my surprise when I find no RSS … the largest change to web use since the browser itself, and all we can get access to is email alerts.
Share This
Posted in Interface Design, Usability, User-experience | No Comments »
March 10th, 2008
I used to have a lot more time for blogging. Now it’s all steam ahead with the actual paying work. I’ve actually had to turn down some projects recently.
My latest project is live and generating a lot of traffic. I built the promotional site for the latest Gillette product - The Gillette Fusion Power Phantom. Very tight deadline, but I made it on time and under budget.
I’ve also been involved with some work on Hotel.com.au, which is actually old-school MS Access and Visual Basic. I am quite enjoying it. Sure beats the hell out of PHP.
Share This
Posted in Development, Freelance, Programming, Software Engineering | No Comments »
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.
Share This
Posted in Development, Facebook, Facebook API, FiniteStateMachine, Melbourne Facebook Developers Group, Programming | No Comments »
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.
Share This
Posted in Amazon S3, MySQL, Ruby, Ruby on Rails, Software Engineering | No Comments »