Running into the following error after your Snow Leopard upgrade?
uninitialized constant MysqlCompat::MysqlRes
Then the following build line for the mysql gem might fix it for you:
ARCHFLAGS="-arch i386 -arch x86_64" gem install --no-rdoc --no-ri mysql -- --with-mysql-dir=/opt/local/lib/mysql5 --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config
Haven’t updated this blog in quite a while. On the other hand I’ve been very active on Twitter. Going to hunt for a WordPress plugin that ‘reblogs’ the microblogging activity
Wow, EngineYard is really stepping up! Have to wonder though what’s going on at Sun, is the whole thing now imploding?! Crazy!
So I decided to pick up the Scala language. Having done Ruby for a couple of years now Scala is one of the few, if not the only language that’s gotten me excited. Being a first class citizen on the JVM has many advantages and I’m really liking LiftWeb.
I also suspect I’ll be doing a bit more Java related stuff in the very near future (stay tuned for that one
) so it’s a good idea to dive into the J world again, and what better way then with Scala!
Problem definition: there is an issue with some XML files which came with a large batch ingest for one of our clients. In short there are a bunch of track elements in the XML which each element having a on_disc and sequence_number (think audio CDs) . However, the sequence_numbers should always be incremented e.g. if you have 2 tracks on disc 1 and 3 tracks on disc 2 the tracks on disc 2 should be have sequence numbers 3,4 and 5 respectively. The XML files we got have reset the sequence_number to 1 whenever a new disc begins.The fix is thus a simple matter of adding the highest sequence number of the previous disc to the sequence number of the current disc. Easy enough.
I tried to implement this in Scala and one of the helper methods calculates the highest sequence number of a given disc. This is the odd part though
// The XML is first parsed to read all tracks
// These are stored in a tuple list
// Note the order of the tuples!
// Tuple values are (on_volume, sequence_number)
val sequence = List((1,2),(1,1),(2,1),(2,2),(2,3))
// Find the max value given a volume
def maxVal(vol: Int): Int = {
var max = 1
for (t <- sequence
if t._1 == vol;
if t._2 > max) max = t._2
max
}
println(maxVal(1))
Now my Ruby brain would expect this to print out 2, however when you run this code the result will be 1! That’s because the filters are actually creating a new list before feeding that to for clause so max is always 1 in the test. I did not expect this
I need to fix a project which uses PostgreSQL. On a fresh Leopard install with postgresql 8.3 installed from ports I ran into this problem:
$ sudo gem install pg
Building native extensions. This could take a while...
ERROR: Error installing ruby-pg:
ERROR: Failed to build gem native extension.
The solution is quite simply. Just make sure pg_config can be found by the gem installer.
$ mdfind pg_config|grep bin|uniq
/opt/local/lib/postgresql83/bin/pg_config
In this case make sure /opt/local/lib/postgresql/bin is available in the path when executing the gem command
$ PATH=/opt/local/lib/postgresql83/bin:$PATH sudo gem install pg
Currently enjoying some vacation in Suriname.
Update: and back again (2009-03-06)