.

Ruby Idiom

I saw this in the RSpec code while I was writing tests today:


[self.errors.on(attribute)].flatten.compact

It struck me as a very concise way to handle the case where it is either a scalar or an array (assuming you don’t care if the returned array is nested). It might get you out of some gymnastics trying to account for both cases.


Gnome autotest Notifications

I’ve been watching some Peepcode stuff this weekend and I’m officially jealous of the Growl support. It turns out I’m not the only one. After surfing around for a while I found this :

ikhono.net: Gnome autotest Notifications

I had to update the regex to handle a change in the output of Rspec – but otherwise it works like a charm. (I also modified it to change the tray icon to the same icon it displays on the status update).

Here are my changes:

Autotest.add_hook :initialize do |at|
@notify = Notification.new
end

Autotest.add_hook :ran_command do |at|
results = at.results.flatten.join("\n")

unless results.nil?
output = results.match(/(\d+)\sexample[s]?,\s(\d+)\sfailure[s]?,\s(\d+)\spending/)
unless output
output = results.match(/(\d+)\sexample[s]?,\s(\d+)\sfailure[s]?/)
end

failures = 0
pending = 0
test_results = ""
if output
test_results = output[0]
failures = output[2].to_i
if output[3]
pending = output[3].to_i
end
end

if failures > 0
@notify.failed("Tests Failed", test_results)
elsif pending > 0
@notify.pending("Tests Pending", output)
else
unless at.tainted
@notify.passed("All Tests Passed", test_results)
else
@notify.passed("Tests Passed", test_results)
end
end
end
end


Paul Graham Time Machine

Paul Graham:

To the extent there is any discomfort about the language you used, you can often use the pointy-haired bosses’ mistaken ideas against them. If they take as an axiom that “all languages are equivalent,” (if this is true, btw, we’re all wasting our time talking about language design on this list) they’ll easily believe that it will be a trivial matter to port your code to some more boss-friendly language, and that the language your software is written in is thus no serious barrier to acquisition.

Re: Y Store now C++


Reloadable Plugins

I been spending a lot of time lately in the land of plugins for Rails. I’m in the process of overhauling a bunch of GUI helpers I wrote a long time ago. One thing that was slowly driving me crazy is that every time I make a change I had to restart the web server to get it to reload everything in development. My old tricks for reloadability just didn’t seem to work.

I had looked for a solution before but came up empty handed. This time I hit pay dirt. Turns out you have to add some small bit of code to you environment.rb and you get reloadability back. Now I can get down to some business.

spotstory » Upgrading to Rails 1.2

Ok. I need to reload my plugins. Bleh. Further, this has to happen in environment.rb, not in environments/development.rb. Bleh.

# Array of plugins with Application model dependencies.
reloadable_plugins = ["acts_as_commentable"]
# Force these plugins to reload, avoiding stale object references.
reloadable_plugins.each do |plugin_name|
reloadable_path = RAILS_ROOT "/vendor/plugins/#{plugin_name}/lib"
Dependencies.load_once_paths.delete(reloadable_path)
end


Ruby-prof

looks like they’ve overhauled the ruby profiler. There is even a short guide to using it to profile Rails code.

Seems like perfect timing since I’ve been struggling lately with some Ruby based scripts that are used to move data around taking forever and a day….

How to Profile Your Rails Application


RailsConf 2007

It has been a bit of a zoo lately so I forgot to post about this. They added a new track to RailsConf and my presentation got accepted. You can see me speak on May 18.

RailsConf 2007 • May 17, 2007 – May 20, 2007 • Portland, Oregon


Drip – IE Leak Detector

Main Page – Drip IE Leak Detector from the article

This is very interesting – it is a tool that actually lets you monitor for memory leaks in IE causes by Javascript.


Erlectricity

This is not how it was supposed to be!

I wasn’t supposed to be able to buy a Prag book on Erlang!

Now they’ve given me access to Ruby from Erlang….

Educate. Liberate. – Erlectricity: Hi Ruby, I’m Erlang.

Armageddon is coming!


Seven JavaScript Techniques You Should Be Using Today

JavaScript has some really neat features as a language – which are of course mostly over looked because of the incredible mountain of code out there that is written at first grade level. Here’s an interesting article that actually points out some ways to use JavaScript a little smarter.

Digital Web Magazine – Seven JavaScript Techniques You Should Be Using Today

The not operators (!!) simply perform a Boolean conversion. The first operator changes the type of the object on the right to a Boolean, and then the second will just reverse whatever the first returned. Nifty trick, eh?


Dr Nic » “Reads -> slaves, writes -> master” plugin

Dr Nic » “Reads -> slaves, writes -> master” plugin

I’m excited this is one of those features that I thought I would end up having to cobble together. Now by the time the project I’m working on needs this kind of scaling the kinks should be worked out.


    Stuff I want to read

    Shelfari: Book reviews on your book blog

    Stuff I've Read

    Shelfari: Book reviews on your book blog
    You are currently browsing the Economy Size Geek weblog archives for the 'Programming' category.
    Categories
    Archives

    .