Archive for the ‘ Misc ’ Category

Ruby, MySQL and Snow Leopard

It should have been a simple excercise. I just wanted to set up a dev environment for a Ruby on Rails app that uses MySQL on my Snow Leopard Macbook 5.5 – easy, right? I wish… after much trial-and-error, and many encounters with the dreaded error message:

"uninitialized constant MysqlCompat::MysqlRes"

… I finally got everything to work using the following steps:

  1. Installing the 64-bit version of MySQL 5.5.14 using the .dmg installer.
  2. removing all possibly pre-existing versions of the mysql gem:
    sudo gem uninstall mysql
  3. Installing the correct gem with the following line:
    sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
  4. This trick is missing from most howto’s: I needed to set the linker path.
    export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

After this, you can verify your installation is working with irb:

Motoko:project-rails karsten$ irb
>> require 'rubygems'
=> false
>> require 'mysql_api'
=> true
>> Mysql.get_client_info
=> "5.5.14"

Having done this, the rake db creation and migration tasks went smoothly.

Find of the day: cmd.exe’s REPLACE

Here’s a surprisingly tough little problem: imagine you have a directory with ca. 90.000 image files, in  my case a frame stack of a video sequence. A selection of these has been processed, and the edited files now reside in a different directory. Now I want to re-build the updated frame stack by copying the files from the old directory to the new one without prompting and without overwriting.

Seems easy, right? It would be, if Explorer wouldn’t crash when trying to copy such a massive amount of files. On the command line, it seems that copy, xcopy and robocopy are not built for this purpose. You can make them overwrite without prompting, but not not overwrite without prompting

Enter replace. I’d never heard of the command until today,  but

replace <source> <destination> /a

does the trick…

new Website!

It’s about time I replaced that shoddy old Website with something new. With great frameworks like WordPress available, there’s really no excuse for not having a pretty web presence! And yes, the timing of this move is not quite unrelated to the fact that I’m looking for a new job… :)