EXIFR 1.0.0

Published at: 7.IV.2010 22:11 CEST
Categories: english, exifr, programming, ruby

After 4 years EXIF Reader finally reaches it’s first major-version-day. It has been pretty stable for a while now and the API didn’t change in any painful way since the first release.

So here it is: version 1.0.0.

  gem install exifr

Enjoy!

Thanks to Makoto Kishimoto, Mark Lundquist, Victor Bogado, Forian Munz and other people I forgot to record in the CHANGELOG for sending me patches and test images.

Installing CLSQL on OS X

Published at: 22.XI.2008 09:03 CET
Categories: english, lisp, osx

Here’s my recipe to get CLSQL to work on my OS X development environment. I already had SBCL and MySQL 5 installed using MacPorts.

First you need to get the code:


git clone git://git.b9.com/clsql.git

MacPorts hides the MySQL libraries and headers somewhere in /opt so you need to make some tweaks. Change db-mysql/Makefile, by adding:


-I/opt/local/include/mysql5/mysql

to CFLAGS (first appearance) and:


-L/opt/local/lib/mysql5/mysql/

to LDFLAGS (also first appearance). You’re now ready to build the interface. Run make from the clsql directory:


make

This should finish without errors. Now you can install CLSQL with the rest of you ASDF systems (I prefer to keep them in my home location):


cp -rp clsql ~/.sbcl/site
(cd ~/.sbcl/system; ln -s ../site/clsql/*.asd .)

To allow CLSQL to find the mysqlclient library you need to create /etc/clsql-init.lisp:


echo '(clsql:push-library-path #p"/opt/local/lib/mysql5/mysql/")' > /etc/clsql-init.lisp

Finally you can run the included test suite to see if it all works fine. Run the tests (my mysql root user doesn’t have a password on my development machine) as follows:


mysqladmin5 create clsql-test
echo '((:mysql ("localhost" "clsql-test" "root" "")))' > ~/.clsql-test.config
sbcl << EOF
(require 'asdf)
(asdf:oos 'asdf:test-op :clsql)
EOF

Not as easy as installing it on a Debian system (apt-get install cl-sql) but not very hard either.

Happy MySQL hacking with Common Lisp on OS X!

Safe data migrations

Published at: 9.IV.2008 05:02 CEST
Categories: english, 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!

EXIFR 0.10.4

Published at: 4.XI.2007 06: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.

EXIFR 0.10.3

Published at: 23.X.2007 12:37 CEST
Categories: english, exifr, ruby

I’ve released a new version of EXIF Reader. Just one small change; JPEG and TIFF objects can now be safely loaded and dumped from and to YAML. To get this to work I made a change to the orientation property; it returns an instance of Orientation now instead of a module. The returned object responds to the same methods as the module did so the upgrade should be painless.

ActiveForm plugin

Published at: 24.IX.2007 12:49 CEST
Categories: active_form, english, plugin, rails
Comments: 2 pieces

Last week at RailsConf Europe I met some people who are using my ActiveForm code to make forms in their Rails sites. It’s about time to wrap it up as a plugin, so here it is.

From the README:

This plugin provides a base class for making forms with ActiveRecord validations without having a corresponding database table. You can use ActiveForm for:

  • making forms which don’t needed storage, like simple email forms
  • provide extra validations on existing ActiveRecord models
  • make forms for composite objects

Installation:

script/plugin install http://svn.remvee.net/plugins/active_form

I know, there already is a plugin called active_form but I don’t like it. It doesn’t provide a “real” AR object causing all kinds of things to not work (like ActiveRecordHelper#form and DateHelper#datetime_select for instance), it doesn’t include any tests and my version is a lot simpler (flog score 20 versus 74).

Why not change the name? I like it! If you can come up with something better, please leave a comment.