Published by marco on 2009-06-02
This should sound like a very easy task, but it took me a while to sort this out, so I thought I’d share it. If you want to install the mysql gem with Ruby1.9 try this:
sudo gem1.9 install kwatch-mysql-ruby
--source=http://gems.github.com/
-- with-mysql-config=/usr/local/mysql/bin/mysql_config
Where in the –with-mysql-config option you have to specify the path to mysql_config in the bin directory in your mysql installation path.
In Mobile Interactive Technology we are trying to make our new applications compatible with Rails 2.3 and Ruby1.9. Not an easy task though. An invaluable source of info on compatibility of gems with Ruby1.9 is isitruby19.com.
Published by admin on 2009-05-12
I went to the Yahoo! Open Hack day London last Saturday. I waited for quite a long time this event, and I’m pleased to say that all my expectations were fully met. A big number of Yahoo enthusiasts (and a guy with a Google T-shirt) arrived at the Congress Center early in the morning for a 24h session of hacking and fun events.
I was very happy to meet my ex Yahoo colleagues, seeing that they’re doing great even during hard times for the company.
I enjoyed mostly the talks about geo technologies and yql. I got so many ideas to implement in my iphone application:)
In particular YQL is a very interesting technology that allows an application to query a number of Yahoo and external databases by means of restful requests.

Check some pictures on Flickr.
Published by marco on 2009-04-19
I have found this toy code on java.sun.com that describes how Java annotations could be used to write a simple Test runner. This script gets as argument the name of a class and tries to execute all the methods of that class that are annotated as @Test.
The interesting aspect of this code is that is shows clearly how annotations can be used to execute/manipulate source code.
import java.lang.reflect.*;
public class RunTests {
public static void main(String[] args) throws Exception {
int passed = 0, failed = 0;
for (Method m : Class.forName(args[0]).getMethods()) {
if (m.isAnnotationPresent(Test.class)) {
try {
m.invoke(null);
passed++;
} catch (Throwable ex) {
System.out.printf(
"Test %s failed: %s %n",
m,
ex.getCause()
);
failed++;
}
}
}
System.out.printf("Passed: %d, Failed %d%n", passed, failed);
}
}
Published by marco on 2009-02-03
This small hack adds attribute accessors to a Perl class. The idea is to add to a Perl package behavior similar to a Ruby class, when you can specify attribute accessors (getters and setters) like this:
Here is the code we have written. Basically all you need to do is add the sub attr_accessor to your Perl class, and then call this method with the attribute you want the getter and setter for.
package MyPackage;
sub new {
my $class = shift;
bless {}, $class;
}
sub attr_accessor {
$attr = shift;
eval <<ATT;
sub $attr {
my \$self = shift;
my \$value = shift;
if( \$value ) {
my \$old_value = \$self->{ $attr };
\$self->{ $attr } = \$value;
return \$old_value;
} else {
return \$self->{ $attr };
}
}
ATT
}
attr_accessor 'name';
In the code above we have added accessors methods for the attribute ‘name’. We can then set and get the ‘name’ attribute as in the following code:
my $t = new MyPackage;
$t->name('marco'); # setter method
print $t->name # this will get and print 'marco'
Enjoy!