‘Host key verification failed’ with Capistrano and Git

Published by marco on 2009-10-18

The other day I started getting ‘Host Key verification’ failed error when trying to deploy an application with Capistrano hosted on a Git repository accessed via SSH. At first the problem was a bit scary, but after a bit of thinking I figured out that the solution to the problem was quite simple.

What I had to do was:

1) ssh to the machine where I wanted to deploy the application to

2) ssh to the git repo machine and accept the key

Done.

Install mysql gem on Ruby1.9

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.

Finally a taste of Chromium on the Mac

Published by marco on 2009-05-13

It’s not even an alpha release, or a release of some sort, but we can finally download a buggy but usable version of Google Chrome for the Mac. It’s obviously full of bugs and missing features, but if you are dying to trying it on your Mac (yes, like me) you can download the latest snapshot build from the chromium project server.
The project is under active development, as shown by the fact the I have downloaded it yesterday evening, and at the time of writing I am almost 40 builds behind…
Have fun!

The Yahoo! Hack day is gone. Good stuff guys!

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.

A sample Java test runner using annotations

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);
  }
}

Yahoo! Open Hack Day London 2009

Published by marco on 2009-04-19

Yahoo! logoFinally after 2 years Yahoo! is back with his Open Hack Day event in London! The 24h non stop event will take place in London the 9th and 10th of May, featuring tech talks on Yahoo!’s technologies, games, food, and of course plenty of hacking. If you are planning to join don’t forget to register visiting the official web page.

Here is the map to the venue:


View Larger Map

Adding attribute accessors to a Perl class – rubifying perl

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:

attr_accessor :attr_name

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!

London, the Perl city

Published by marco on 2009-01-31

If you are a Perl developer (or just passionate about this language), then London is definitely the city to live in. The Perl community in the city is quite active, as you can see from the number of free events available every couple of months. Last November I attended the London Perl Workshop, where a former colleague from Yahoo was giving some talks about Moose. The next month, February 19th, I will attend the London.pm technical meeting where, guess what, Moose will be the star again. The event will take place at the BBC’s offices near White City from 7pm to 9pm. If you are in town and you want to join, make sure to register as places are limited.

The power of the press

Published by marco on 2009-01-24

Bored at work? Try this out: O’Reilly Maker. This web app allows you to create your own customized O’Reilly cover.
I gave it a try and this is the result:

Post Summarizer Wordpress plugin

Published by marco on 2009-01-03

UPDATE. The plugin is now hosted in the official Wordpress plugin directory and can be downloaded directly from its page.

In my previous post I talked about the work I carried out for my MSc research project. Here is the Wordpress plugin that implements a simplified version of the summarization system described there.

This plugin creates an automatic excerpt of a post when it is saved or published. The excerpt created is a coherent piece of text containing the most important sentences of the post.
After installing this plugin, every time you write a post and press the save or publish button an excpert is created for that post and stored in the database. This plugin is useful also if you don’t use excerpts in your blog: it’s always useful to have a summary of your post available just to remind yourself what the post is about (it works very well with old and long posts!).
Statistical natural language techniques are used to extract the most important sentences from a document. It’s straightforward to tweak the plugin to give more importance to certain features in your text.
The code of the plugin has been optimized for extensiblity in order to make it easy for contributor developers to implement a summarizer in their own language. At the moment only an English language summarizer is available, and an Italian one is on its way.
After activating the plugin here are simple steps that you might want to follow in order to have a nice excerpt to use in your blog:

1. Write your post
2. Press the save or publish button
3. An excerpt will be created. Now you can review it, modify it and save it as many times as needed
4. If you want the summarizer to create an excerpt again delete the existing one and press save or publish

Note that the plugin creates automatically an excerpt for a post only if there isn’t already an excerpt for that post.

Next Page »
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2010 xterm.it | powered by WordPress based on Barecity