Freelancing Gods 2009

God
24 Oct 2008

Thinking Sphinx PDF at Peepcode

A quick note to let anyone using (or interested in using) Sphinx and/or Thinking Sphinx that my Peepcode PDF has just been published, and contains a wealth of information on how to mix Sphinx with ActiveRecord (via Rails or Merb).

It’s been great working with Geoffrey Grosenbach to get this written up, and I’m pretty stoked to see the final results – hopefully others will enjoy it as well.

Also, a massive thank you to all the contributors to Thinking Sphinx – it wouldn’t be quite so cool if it wasn’t for all the patches (facilitated by GitHub’s forking).

23 Oct 2008

Developer Ethics

A quick question to fellow coders…

Unsurprisingly, there’s a dearth of Ruby developers in Cambodia. I imagine the situation is pretty similar in other developing nations. PHP and Visual Basic seem to be the common languages in the small tech community here.

I’m currently working on building a website for one of the local NGOs here – and of course, Rails is my preferred framework. But looking forward, I don’t wish to be providing ongoing support for the site – and the client shares that sentiment. So to make it easier for local developers to take over, should I be considering using PHP for the project instead?

I have offered to help the IT guy at this organisation learn Ruby, but he won’t be there forever as well. And they’re a small NGO - they don’t have the cash to throw around hiring super-skilled developers. The project itself is pro-bono.

So, what would you do, given the circumstances?

(And for the record, it’s very likely I’ll stick with Ruby – using the Radiant CMS - but I’m interested in others’ opinions.)

16 Jul 2008

Odds and Ends

A few random items:

  • There’s a Rails Camp happening in Denmark. How awesome is that!?
  • I’ve added an About Me page to this blog – filled with opinions. You have been warned.
  • I’m talking at NYC Ignite – come along and listen to me talk quickly about non-Ruby stuff for five minutes, if you’re near that part of the world.
  • Joss Whedon is awesome.
  • So is Pixar. You must see Wall-E. Easily the best film I’ve seen all year.
12 Jul 2008

Link: Jedlinski.pl devblog » Thinking Sphinx as Windows service

"Thinking Sphinx for Windows - a batch of simple rake tasks dedicated for Windows users."

01 Jul 2008

Rails Camp UK

Following in the steps of the Australian Rails Camps, it’s now time to announce the first UK edition. Running from Friday the 15th to Monday the 18th of August, it will be an extended weekend of hacking, talking, eating, drinking and games, with a bunch of smart and passionate Ruby developers.

Even though the name is “Rails Camp”, previous camps have included talks on topics from Merb to Rack to Extreme Programming – all topics somewhat related to Ruby are welcome.

If you’d like to come along, I’d recommend registering soon, as there’s a very limited number of places.

01 Jul 2008

Link: new controller examples

"refining the examples generated for restful controllers"

28 May 2008

RailsConf 2008

I’ve just started my round-the-world conferences-and-holiday adventure, and the first stop is RailsConf in Portland – so if you’re in town and see me wandering around looking rather cluelessly, please say hi.

Also, in case you’re on the Twitter bandwagon, you’ll find me with the creative nickname of pat.

21 May 2008

Sphinx + Rails + PostgreSQL

In case you’ve not been watching every commit carefully flow through Thinking Sphinx on GitHub – PostgreSQL support has been added. I’ve done a little bit of testing, and I’ve had some excellent support from Björn Andreasson and Tim Riley, so I feel it’s ready for people to start kicking the tires.

I’m no PostgreSQL expert – I definitely fall into the n00b category – so if you think there’s better ways to do what I’m doing, would love to hear them.

13 May 2008

Link: lindsaar.net Tip #4 - Validating an Email Address with Ruby on Rails

"TMail has an “Address” class. It will throw an invalid address exception if given an address it can’t handle (and it has about 2,000 test cases of email addresses it can handle, so you are pretty safe.)"

06 Apr 2008

Link: New in Rails: a request profiler for profiling your app | redemption in a blog

Old news, but I need to remember it's in there

25 Mar 2008

Link: Formtastic Plugin Documentation

"makes it far easier to create beautiful, semantically rich, syntactically awesome, readily stylable and wonderfully accessible HTML forms in your Rails applications."

16 Mar 2008

RailsCamp #3

If you’re a Ruby developer in or near Australia, I highly recommend attending RailsCamp number 3, which has just opened for registration. The first two were simply amazing, so I’m just a little annoyed that I can’t make it to this one (as I’ll be traveling overseas at the time). I’ve no doubt that this one will be just as fantastic – expect an extended weekend of hacking and talking with a bunch of smart, entertaining and passionate developers, and plenty of drinks and games thrown in for good measure.

You don’t need to be a Rails or Ruby genius to attend – just a desire to discuss, learn, teach and (most importantly) have fun.

Go register now.

14 Mar 2008

Sphinx 0.9.8-rc1 Updates

Another small sphinx-related post.

In line with the first release candidate release of Sphinx 0.9.8 last week, I’ve updated both my API, Riddle, and my plugin, Thinking Sphinx, to support it. Also, for those inclined, you can now get Riddle as a gem.

I’m slowly making progress on some major changes to Thinking Sphinx, so hopefully I’ll have something cool to show people soon. Oh, but some features that aren’t reflected in the documentation: most of Sphinx’s search options can be passed through when you call Model.search – including :group_by, :group_function, :field_weights, :sort_mode, etc. Consider it an exercise for the reader to figure out the details until I get around to improving the docs.

11 Feb 2008

Link: smartbomb I love me some source

"As good as this is, I was really after something with less typing and smarter pants. Well tonight I cracked it and I thought I’d open the source"

22 Jan 2008

Bring Methods Back From The Dead

Tags:

Today was the first time I’d come across Ruby’s undef_method – it’s used in a few places in Rails, particularly with ActiveRecord’s associations. While I see the point of it, there were a few methods I wanted back – and I’ve figured out how to do it – you need to grab the method definition from the superclass. Here’s an example:

class AntiString
  undef_method to_s
end

AntiString.new.to_s
  #=> NameError: undefined method `to_s' for class `AntiString'

AntiString.send(:define_method, :to_s,
  AntiString.superclass.instance_method(:to_s))

AntiString.new.to_s #=> "#<AntiString:0x364ef8>"

Now, the obvious caveat – if the method was originally defined in that class, not the superclass, then I think you’re out of luck. Although I’m guessing you’ll rarely be in a position where you need to resurrect a method like this anyway.

21 Jan 2008

Mixing Merb and MYOB

For one of the contracts I’m working on at the moment, I’ve been using Merb to construct a web service that interacts with MYOB, and can be consumed with ActiveResource.

The connection to MYOB is ugly, using Christian Werner’s ODBC Bindings and the Rails/ActiveRecord ODBC Adapter, the latter of which had to be hacked slightly. However, the Merb side of things was quite clean. I’m really looking forward to seeing how Merb progresses, especially with their plans for merb_core and merb_more.

One of the rare snippets of code from the Merb app that I think is more verbose than the Rails equivalent is how to go about obtaining the query parameters (as opposed to routing parameters) of a request.

The Rails way:

request.query_parameters

The Merb way:

params.except *request.route_params.keys.collect { |key| key.to_s }

Also, in case you’re as stupid as I am and want to generate Merb controllers on the fly, you can’t use Class.new. The only way is by building the class in a string and eval’ing it:

Object.send(:eval, <<-CODE
class ::Object::#{controller_name} < Application
  # actions and such go here
end
CODE
)

It’s not particularly elegant, but at least it works.

17 Jan 2008

Sphinx 0.9.8r1065

Short post, as befitting the importance of the content: Riddle and Thinking Sphinx have both been updated to support the current version of Sphinx, 0.9.8r1065.

07 Jan 2008

Link: Le-Blog-à-Dam - Page Cache Test - Rails Cache Test Plugin

If I get some spare time, this is something that would be nice to adapt to rspec

27 Dec 2007

Updates for Sphinx 0.9.8r985

Another quick Sphinx post – Riddle is updated to support Sphinx’s latest release (0.9.8r985), and Thinking Sphinx now has that new version of Riddle as well.

I’ve not tested any of this with the recently released Ruby 1.9 yet, though (but it’s on my list of things to do).

Also, thank-you to Joost Hietbrink (again) and Jonathan Conway for their patches to Thinking Sphinx – very much appreciated.

05 Dec 2007

Link: Bamboo Blog - Presenters & Conductors on Rails

"the presenter and conductor; the presenter sitting between the controller and view, and the conductor sitting between the model and controller."

05 Dec 2007

Link: Plain Text Stories: Part III

Examples of the new stories/integration testing in rspec

04 Dec 2007

validates_uniqueness_of_set

Rails code snippet for the day: validates_uniqueness_of_set. Useful for making sure each specific combination of the specified attributes is unique. Example from the pastie:

validates_uniqueness_of_set :first_name, :last_name

Just like the options it accepts, the code is very similar to validates_uniqueness_of – and the few tests I’ve thrown at it are handled without any problems.

03 Dec 2007

Link: :: GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS :: save bang your head, active record will drive you mad

"exceptions should not be expected"

26 Nov 2007

Link: Eli Miller: Proper cache expiry with after_commit

Can use this for any actions after transactions are committed - ie: Thinking Sphinx's delta indexing

26 Nov 2007

RailsCamp Wrap-up

RailsCamp 2.0 finished earlier today – and I think it’s safe to declare it a fantastic success (even given my bias).

Massive thanks to Ben and Karen for their hard work getting everyone fed and co-ordinating people in the kitchen (and the RailsCamp bus from Melbourne to Sunnystones). Thanks too to everyone who helped at various points – both in the organising and over the weekend.

Finally, thank you to everyone who came along – these camps are so much fun because of the calibre of people who attend, and their willingness to share ideas, code and laughs.

Will be posting a version of my talk at some point soon… once I’ve recovered from the weekend.

14 Nov 2007

Link: David Heinemeier Hansson from 37 Signals (hatchthat.com)

Tags:

".. making a difference. Yeah, yeah, I too hear fuzzy teddy bears dancing to the tune of harps saying that, but none the less."

14 Nov 2007

Sphinx's Riddle

Built out of the work I’ve done for Thinking Sphinx (which has just got basic support for delta indexes, attributes and sorting – although the documentation doesn’t reflect that), I’ve extracted a new Ruby client that communicates with Sphinx, which I’ve named Riddle.

I’m not going to delve into the code here – because I’m not expecting it to be that useful to many people (and I just wrote examples in the documentation – go read that instead!) – but I’m very happy with how it’s ended up, and it’s got some level of specs to give it a thorough test. It’s also compatible with the most recent release of Sphinx (0.9.8 r871). Should you wish to poke around with it, just check it out from subversion:

svn co
  http://rails-oceania.googlecode.com/svn/patallan/riddle/trunk riddle

It’s also being used in Evan Weaver’s UltraSphinx plugin, which I’m pretty pleased about.

05 Nov 2007

Aliasing Actions in Rails

Tags:

Code snippet for application.rb that makes life just a little easier if multiple actions are doing exactly the same thing (both in the controller and the view):

def self.alias_action(existing, aliased)
  define_method(aliased.to_sym) do
    send(existing.to_sym)
    render :action => existing.to_s
  end
end

And then in the appropriate controller (where edit is an existing action, and show needs to be exactly the same):

alias_action :edit, :show

I know this is a specialised use – but perhaps someone else out there is doing something similar.

30 Oct 2007

RailsCamp Reminder

In case the few readers of this blog are not aware, there’s a RailsCamp happening just outside of Melbourne, from the 23rd-26th November (not far away at all). It will be a weekend of hacking, chatting, food & drink, and very likely some gaming (along the lines of GuitarHero and WiiSports), taking a similar approach to barcamps. The first one, back in June near Sydney, was a fantastic success, and judging by the current list of attendees, I’m expecting it to be much the same.

We’re edging closer and closer to being sold out, so if you’re considering coming along, I recommend signing up as soon as possible. Day passes for the Saturday and Sunday are also available.

23 Oct 2007

Request for Caching Questions

The monthly Melbourne Ruby meeting is happening this Thursday, and I’ll be presenting about Rails’ caching (of the page, action and fragment varieties). Just wondering if any of the few readers of this blog had either suggestions for content, or, especially, questions they’d like to see addressed in such a talk?

Slides will, of course, be posted after the meeting.

RssSubscribe to the RSS feed

About Freelancing Gods

Freelancing Gods is written by , who works on the web as a web developer in Melbourne, Australia, specialising in Ruby on Rails.

In case you're wondering what the likely content here will be about (besides code), keep in mind that Pat is passionate about the internet, music, politics, comedy, bringing people together, and making a difference. And pancakes.

His ego isn't as bad as you may think. Honest.

Here's more than you ever wanted to know.

Ruby on Rails Projects

Other Sites

Creative Commons Logo All original content on this site is available through a Creative Commons by-nc-sa licence.