Autotest notificaties ala Growls op EEE

Gepubliceerd op: 9.V.2008 08:55 CET
Categorieën: debian, eeepc, testen

Er zijn eigenlijk maar weinig dingen die ik echt mis van m’n MacBook als ik lekker zit te fröbelen op m’n EEE. Wat ik wel jammer vond, was dat ik geen growl notificaties meer had uit autotest. Maar debian zou debian niet zijn als er tussen de bijna 27 duizend packages geen alternatief te vinden zou zijn; aosd-cat.

Nu nog even in ~/.autotest hangen!

Lees verder ››

Registratie balie RubyEnRails2008 geopend!

Gepubliceerd op: 6.V.2008 20:31 CET
Categorieën: events, rails, ruby

Wee! Ik heb m'n EEE!

Gepubliceerd op: 2.V.2008 21:06 CET
Categorieën: cool, debian, eeepc, hardware
Reacties: 3 stuks

Sinds dinsdag ben ik, na weken wachten, de trotse eigenaar van een licht blauwe ASUS EEE PC! Ik heb Xandros er meteen eraf gegooid en heb nu een strakke magere debian installatie pruttelen; dwm, iceweasel, vim en wat interpreters en compilers..

Hulde aan de gemeenschap achter het custom debian EEE PC project. En natuurlijk applaus voor de mensen bij ASUSTeK!

Reageer ››

Safe data migrations

Published at: 9.IV.2008 14:02 CET
Categories: plugin, rails
Comments: 4 pieces
Something ago I wrote about the problems which arise when using models in your Rails migrations. Meanwhile I developed a really simple solution to this problem and today I wrapped it up in to a plugin called SafeDataMigrations. How to use it? Install it in your Rails application:
ruby script/plugin install http://svn.remvee.net/plugins/safe_data_migrations
and apply it in your migration:
class DowncaseUserNames < ActiveRecord::Migration
  models :user

  def self.up
    User.find(:all).each do |user|
      user.update_attributes(:names, user.name.downcase)
    end
  end

Look at the README file for a more elaborate example.

So how does it work? It simply undefines the models your referring to and redefines an empty ActiveRecord class;
Object.send :remove_const, :User rescue nil
class User < ActiveRecord::Base; end
Now you are sure to have a User model available in your migration without any validations which may make data manipulations impossible. The undefining of an already available model also ensures you don’t need to use ActiveRecord::Base.reset_column_information before updating new fields, unless you use your model before altering the table of course.

Update: As coderrr points out you don’t need to clobber the global scope model class because a nested model works fine too. I wrongly assumed introducing a new model class in side (!) a migration class would only reopen my original model class and keep validations intact. To illustrate:

class User; def top; end; end

class Migration
  class User; def nested; end; end

  def self.go
    p User.instance_methods - Object.instance_methods
  end
end

Migration.go

yields ["nested"] and not ["top", "nested"] as I suspected. Apparently I was bitten too hard by a problem which arose when I used an original model class to even try the above. I’ll pull the plugin because it’s pointless.. Bad me, thanks coderrr!

Write a comment ››

Laat je JavaScript zichzelf schrijven

Gepubliceerd op: 20.I.2008 12:46 CET
Categorieën: javascript, programming
Reacties: 3 stuks

Laatst werd me gevraagd wat mooier of beter is:

obj.getItem('Status')
obj.getItem('Status') == 'Completed'

of

obj.getStatus()
obj.isStatusCompleted()

Het laatste voorbeeld is beter omdat het minder foutgevoelig is; een tiepfoutje in het eerste geval kan heel lang blijven sluimeren terwijl in de tweede versie de foutmeldingen meteen om je oren vliegen. Daarbij vind ik de tweede variant ook beter leesbaar.

Drawing Hands, 1948, M.C. Escher De degene die de vraag stelde, gaf me schoorvoetend gelijk. Maar zou dit niet betekenen dat hij deze methoden voor alle 10 statussen uit zou moeten schrijven en is dat dan niet ook weer foutgevoelig? Voorzichtig vroeg ik om welke taal het eigenlijk ging; “JavaScript”. Maar natuurlijk hoef je dat niet helemaal zelf uit te schrijven! JavaScript is, net als Ruby, Lisp en vele andere, een moderne taal en stelt je in staat te meta-programmeren, ofwel programma’s zichzelf te laten schrijven.

Dus geen gedonder met een preprocessor en/of rare annotaties meteen aan de slag met de programmeertaal waar je toch al mee bezig was!

Lees verder ››

amsterdam.rb

Gepubliceerd op: 17.I.2008 19:55 CET
Categorieën: events, rails, ruby
Reacties: 1 stuk

Op maandag 28 januari wordt de eerste amsterdam.rb bijeenkomst georganiseerd. Het idee is onder het genot van kop koffie ontstaan en leek, toen de cafeïne eenmaal uitgewerkt was, nog steeds een goed plan.

Komt allen rond 20u naar de bekeerde suster aan de nieuwmarkt om de geboorte van amsterdam.rb te vieren! Zegt het voort!

EXIFR 0.10.6, security fix

Published at: 15.I.2008 09:13 CET
Categories: english, exifr, ruby, security

A specially crafted JPEG or TIFF image could force EXIFR in an endless loop. The problem is solved in release 0.10.6. If you are using EXIF Reader without having control over the images fed to it, upgrade as soon as possible.

Write a comment ››

EXIF Reader 0.10.5 goes 1.9

Published at: 28.XII.2007 12:21 CET
Categories: english, exifr, ruby

The recent Ruby 1.9 release adds a lot of new stuff but unfortunately some of the changes prevented EXIF Reader from working. A slight case-syntax change (colon being deprecated), String no longer being Enumerable and IO becoming more character aware, broke my code.

The new 0.10.5 release runs on both 1.8 and 1.9.

Write a comment ››

Mongrel handlers

Gepubliceerd op: 24.XII.2007 12:21 CET
Categorieën: mongrel, rails, ruby

Voor rubyenrails.nl heb ik een artikel geschreven over mongrel handlers: Rails MVC aan je laars lappen met Mongrel handlers.

EXIFR 0.10.4

Published at: 4.XI.2007 15:33 CET
Categories: english, exifr, ruby

EXIF Reader includes the ability to read thumbnails from JPEG again. This feature disappeared from EXIFR when in rewrote most of it to support TIFF reading.

Write a comment ››