Archive for October, 2007


Plugins to Help your Rails Controllers REST Easy

Update 2007-11-02: Fixed reference to Mephisto author. Thanks Luigi!

Update 2007-11-01: Nathan commented on this post and said m_r will soon support polymorphic routes.


One of the nice features in Ruby on Rails is its support for REST-style controllers. This feature is fledgling in Rails 1.2.3, so if you head down this path you will doubtless find yourself writing a lot of similar-yet-faintly-different code again and again. A number of generous people have written plugins to ease the pain. I did a test run with two lately — make_resourceful and resource_controller — and investigated several others along the way. This is a summary of what I found.

make_resourceful comes from Hampton Catlin (Toronto), Jeff Hardy, and Nathan Weizenbaum, the same crew that does the very cool HAML and SASS plugins. m_r has a pretty syntax, great documentation, and a fairly active google group where Hampton and Nathan engage in discussions. I took it for a test run and quite liked how my code ended up after transmogrification. On the down side, I needed a feature called “polymorphic routes” — e.g. \people\bob\posts or \forums\13\posts — which this plugin doesn’t have built in, but Jonathan Linowes has patched. Alas, I found the combination of the patch and plugin unwieldy: it took me way too long to get it all working for my specific requirements, and the resulting code was, shall we say, Frankensteinesque.

resource_controller is written by Montrealler James Golick, who is buddies with the make_resourceful  team members. James’ plugin is quite similar to m_r — the syntax is much the same — and happily for me has built-in support for polymorphic routes. I tried it out and liked the basics, but then found myself stymied by difficulty supporting some custom route formats. I asked James for help, and he was incredibly responsive; he resurfaced just one day later with a new revision that let me customize to my heart’s content. He also made some design changes so that r_c can be instantiated either using inheritance (the original design: your app controller inherits from ResourceController::Base) or as a mixin. These changes are now available in revision 83 of his SVN trunk.  James also fired up a google group just recently and takes questions on his blog. 

I also looked at:

  • resources_controller - from Ian White, who has written several other plugins.  (Yes, this plugin has almost the same name as James Golick’s resource_controller. Ian was first.) His plugin looks very functional but I avoided it because I found the syntax unappealing.
  • restful_exposure - Luke Redpath. This one didn’t meet my requirements.
  • define_crud - SonicIQ. No docs = no soup for you.

Bottom line: I recommend you check out both resource_controller and make_resourceful.  I am going with resource_controller for now, since it meets all my requirements and James clearly has a ton of energy around improving it further in the directions I care about. make_resourceful also impressed me a great deal, so if you don’t need polymorphic routes it might be a better solution for you.

FolderShare is Good… Except for the Ghosts

FolderShare has done a bang-up job for a few years synchronizing my files amongst several computers. Recently I used it to collaborate with relatives to collect photos for my brother-in-law’s wedding. At home it does a lot of heavy lifting every day to synch (and, effectively, back up) work files, music and pictures between Katrin and myself. It does have a few pesky limitations, like a 10,000 file per folder limit in the basic version, but you can work around those fairly easily. 

Today, though, I ran into an interesting hurdle: Foldershare has a ‘trash’ directory where it stuffs little ghost copies of every file you delete from a foldershare’d directory. This is a feature: you can always retrieve a deleted file if you want to. But it has a down side, too: so far, nobody has invented an infinitely large disk drive.

This morning, my 60GB C: drive, which has been hovering at fairly low disk space for the past few months, finally hit rock bottom. Windows Media complaining that it had no library space, Firefox crashing during security updates, dogs and cats living together - mass hysteria.  So I hauled out my super-disk-space-radar-gun — SpaceMonger — to find out who was hogging all the space. The nefarious culprit: FolderShare’s trash folder, clocking in at a massive 5.3 GB.

Yikes.

Gulp.

DELETE!

Hopefully Microsoft will release an update some time and add a feature to automatically limit the trash folder size.

I still heartily recommend FolderShare as a great solution for continuous file synch, but do keep this devilish little flaw in mind.

 

If you must know more:

2007 Ontario Election Roundup

Ontario’s 2007 election and referendum results are mostly in, with 98% of polls reporting. In a nutshell:

  • Little changed in terms of seats allocated to political parties
  • The MMP proposal got approval from 37% of voters; 60% was needed to pass
  • The Green party won zero seats, but received 8.2% of the popular vote
  • Voter turnout was a record low, under 50%

The table below shows the results, and what they would have been, were the MMP system in place.

If you do the math you’ll see that MMP approval — 37% of the popular vote — exceeds the total percentage of Green Party and NDP votes (8.2% + 16.8%) by a further 12%. That means a lot of people who voted for the PC or Liberal party also voted in favor of MMP. This despite the confusion, uncertainty and doubt reported by the major media.

The huge gain by the Green party is also significant: it indicates far more environmental concern now than in ‘03 when the Green Party received only 3% of the popular vote. We should expect (and demand) that mainstream party agendas become more green in the years ahead.

Party

Percentage of popular vote

Seats under current system

Riding seats under MMP

Total seats under MMP

Liberals

42%

71

60

60

Progressive Conservatives

31.7%

25

21

39

NDP

16.8%

11

9

20

Green Party

8.2%

0

0

10

(Source: Globe and Mail)

I’m hoping for better preparation next time around. Flavors of proportional representation are used successfully today in New Zealand, Venezuela, Hungary, Scotland’s parliament, Wales’ national assembly, and every European country except Britain. We can do at least as well as them, and certainly better than First Past the Post.

Rewarding Good Behavior

Pretty much every modern online community that hosts end user content has various systems in place to encourage good (”desirable”) behavior and deter naughty acts. I’ve been polling various friends with online community experience about this recently, to glean their experience on what they thought worked best. Their advice:

Rewarding the Good Stuff:

1) Public recognition goes a long way. Give glory for good deeds done.

2) Increased access to community resources can be a much-desired reward for good behavior. See how Slashdot uses karma, for instance.

3) Point systems / artificial currencies work wonderfully in some environments, and fail miserably in others. There was no consensus opinion on this… it seems to be partially an issue of design (does the notion of currency suit a given app, for instance), and partially an issue of customer culture.

4) Never reward people with money, unless they’re your employees. A.K.A. “money can’t buy love”.  It sounds obvious, but… it has to be said.

Deterring the Bad Stuff:

1) Moderation is effective in correcting bad behavior once it has occurred. It’s not generally effective at preventing bad behavior in the first place (like jails, with crime). Moderation can be costly to scale up due to people-intensity.  See Craigslist and Slashdot for examples of moderation systems that work by employing the user community. Slashdot’s is particularly intricate.. see How does moderation work and How did the moderation system develop in the Slashdot FAQ.

2) You need monitoring systems in place so you can lock out user accounts and/or IP addresses of really naughty people. Increasingly, laws in various countries are requiring that you build in this capability.

3) Reserve lawsuits for the wickedest of them all. But you really don’t want to go there unless you absolutely have to.

 

Technorati Tags: , ,

Vote Mixed-Member Proportional on October 10

Wednesday Oct 10 is Ontario’s next provincial election. This is a particularly important vote, since it includes a referendum on the newly proposed MMP (mixed-member proportional) system.

I believe MMP has the potential to make our electoral system a great deal healthier. The old system forces you to compromise between the quality of your local candidate and the party who you believe will do the best job for the province, because you can only have one vote. The newly proposed MMP allows you to separate those judgements by voting for a candidate and then also voting for the party you believe in. MMP should lead to more diversity in our political representatives, and it promises every citizen an equal chance to be heard and to change the status quo.

You can read more about it on wikipedia, on the official MMP website, or on voteforMMP.ca

The referendum needs a 60% majority to pass, so high voter turnout is particularly important. British Columbia recently had a similar referendum and fell just short with 58% approval. So pass on the word, and get out and vote!

Scaling up Cheaply with Computing Utility Services

I’ve been thinking lately about how to scale up software services on the web in a cheap and incremental way. Every web startup faces this problem. In the bad old days (1993?) your only choice was to go buy a bunch of machines and build out your own server farm. The next wave was the ability to lease resources within a web hoster’s web farm, likely starting with shared machines and then stepping up to dedicated servers. The third wave is what I call “computing as a utility”. Microsoft, Google and Amazon are all working on this, and so far Amazon seems to have the most interesting capabilities: web services that let you outsource computing and storage in a very incremental way: Mechanical Turk (human task outsourcing), S3 (storage), Elastic Compute Cloud, aka EC2 (computing), and several others related to payment and commerce.

Computing utilities are a significant innovation. They provide a way to incrementally tap into computing power, network capability, storage, and all the expertise and staffing it takes to build out and manage a heavy duty server farm with worldwide reach.  From a financial standpoint you are shifting from big chunks of up-front capital expenses (and commensurate fund-raising) to smaller chunks of pay-as-you-go operational expense. From a staffing standpoint you are leasing expert help on operations, which is great, because you can then focus more of your staff and energy on building a great customer experience.

In theory, you can bootstrap a startup much more cheaply this way. It’s the moral equivalent of tapping into the electricity grid versus buying and wiring up your own generator or building a power source from scratch.

I’m really eager to see services like this mature, and curious to see how they get wired into developer tools and business models.

More reading:

(1) There are several slide shows now that tell the stories of various startup companies experiences with S3 and EC2. These are quick reads: http://www.slideshare.net/group/the-startup-project-aws and http://www.slideshare.net/group/webapps-scalability.

(2) In CNet last week Elinor Mills described her efforts to make money via Mechanical Turk. It sounds like it’s still hard to make significant cash there. 

(3) About a year ago I mused about the Mechanical Turk and things people can do better than computers.