Made in Heaven

1 June 2009 61 comments

Josep Guardiola - Portada de El Periódico de Catalunya

The dessert

27 May 2009 2 comments

FC Barcelona vs Manchester United - Champions League Final : Messi, Iniesta and Henry

The main course

23 May 2009 2 comments

Liga 2008/2009 FC Barcelona - Barça

The starter

13 May 2009 1527 comments

Copa del Rey

Rome, here we go

6 May 2009 1 comment

This is a chorreo

2 May 2009 21783 comments

Chorreo Madrid Barcelona

phpredis, 2 Fast 2 Furious

21 April 2009 23804 comments

phpredisRedis (REmote DIctionary Server) is a persistent key-value database with built-in net interface written in ANSI-C for Posix systems. Whilst it may at first seem like the wheel is being reinvented here, the need for something beyond a simple key-value database is pretty clear. It’s possible to use Redis like a replacement of memcached, with the main difference being the dataset is stored persistently – not volatile data – and Redis introduces new data structures such as list and sets. Furthermore, it implements atomic operations in order to interoperate with these data structures.

I released a PHP extension called phpredis a couple of weeks ago, which works as a PHP client API for Redis. The project is hosted at Google Code at the moment, and you can get the code directly from the SVN repository: http://phpredis.googlecode.com/svn/trunk/.

Despite a vanilla PHP client library already exists, I felt the need to write it since a PHP extension normally performs better and I wanted to make the most of Redis potential.

Let’s see a snippet of how to make a simple operation to Redis using the PHP client:

    $redis = new Redis();
    $redis->connect(‘127.0.0.1’, 6379);

$redis->set(‘key’, 27); echo $redis->get(‘key’); // it should print 27 $redis->incrby(‘key’, 3); echo $redis->get(‘key’); // it should print 30

The code above was quite obvious, it stored a value associate to key and it increments its value by 3. Let’s see another snippet a bit more complex, for example using a list:

    $redis = new Redis();
    $redis->connect(‘127.0.0.1’, 6379);

$redis->lPush(‘list’, ‘val’); $redis->lPush(‘list’, ‘val2’); $redis->lPush(‘list’, ‘val3’, 1); echo $redis->lPop(‘list’, 1); // it should print val3 echo $redis->lPop(‘list’); // it should print val2 echo $this->lPop(‘list’); //it should print val

Notice that depending on the last optional parameter (0 by default) it’s possible to append/extract an element to/from the tail or to/from the head of the list.

There is a list including all the available methods. At the moment, I’m working on the implementation of more new Redis commands and on the support for complex data structures such as arrays and PHP objects.

Apart from phpredis, there are more client API for languages as Perl, Python, Ruby and Erlang. You can find this and more at the Redis project homepage. Redis has been written by Salvatore Sanfilippo who I’m chuffed to bits with.

Essential Java resources

27 January 2009 0 comments

Ted Neward, a consultant with ThoughtWorks and the principal of Neward & Associates, has published a list of libraries, tools and other resources - such as books, conferences or weblogs - any up-and-coming Java developer should have. The Java platform will be celebrating its 14th birthday soon, and it’s time to revise the story of one of most extended languages.

Java Coffee

Link | Essential Java resources

PHP.JS, PHP functions in Javascript

10 January 2009 2 comments

PHP.JSPHP.JS is a project with the purpose of porting standard PHP functions over to Javascript. The project was taken up by Kevin van Zonneveld, a dutch developer who had developed a small JS library of PHP functions for his job. Kevin shared the library on his blog and came into Open Source. Then many developers made contributions with new PHP functions written in JS and this is how the spark caught flame.

It offers added functionality on top of JS with functions like md5(), file_get_contents(), and utf8_encode().

Official site | PHP.JS

Disclaimer: I’ve contributed to the project with a couple of functions

Bash tricks

10 January 2009 0 comments
th3j0ker@alexandra:~$ echo hello
hello
th3j0ker@alexandra:~$ ^hello^bye^
echo bye
bye
Alfonso Jiménez 2004 - 2009 | Creative Commons Attribution | Powered by Lightpress2