Posted by Jorge Bernal September 07, 2008
I had a sad time this year when I missed the MySQL conference, since I had much fun last year in Santa Clara. I can’t miss it next year.
As a MySQL partner, and after almost 2 years doing MySQL training, I sure have interesting things to tell in the conference, but I’m not sure about what.
I will be thinking about this in the next weeks, but I’d appreciate some help. What topics are you interested in?
Posted in MySQL, Open Source | No Comments »

Loading ...
Posted by Jorge Bernal August 15, 2008
I’ve found this today at the shoes website, and I think it’s not the first time I see someone using the Ubuntu logo or name to refer to a Linux system.
If rms already had a bad time trying to convince people to use GNU/Linux instead of Linux, it seems he is getting more work to do 
Posted in Open Source, Ubuntu | 13 Comments »

Loading ...
Posted by Jorge Bernal August 15, 2008
I’ve been trying to give rebirth to an old internal project at my company, abandoned circa 2006, and this is one of the code pieces I think it could be useful to others.
I wanted to store country information as an ISO code, so here is the plugin to make it work
It’s translated using the translation from the iso-codes package, so I guess it’s as good as it can get by now. If you want to contribute, please do it to the iso-codes package and let me know, so I can update it too.
iso_countries - Store countries using ISO 3166 codes
This rails plugin enables you to store country info only with the country’s ISO-3166 code
Example
class Company < ActiveRecord::Base
iso_country :country
end
c = Company.new :country => "es"
c.country # => "es"
c.country_name # => "Spain"
c.country_name = "France"
c.country # => "fr"
ISO::Countries.set_language "es"
c.country_name # => "Francia"
Download
You can get it from http://github.com/koke/iso_countries/tree/master
Posted in Development, Open Source | No Comments »

Loading ...
Posted by Jorge Bernal July 22, 2008

Since I didn’t have any MySQL public courses planned this summer, I’ve been using my work time from the last week in the new eBox website.
I’m still far away from what I’d like, but I’m proud my design skills have improved considerably.
For those of you who still don’t know what it is, eBox is a server for the easy administration of corporate networks. eBox was included with the last release of Ubuntu. See eBox in Ubuntu
Posted in Open Source, Technology | 2 Comments »

Loading ...
Posted by Jorge Bernal May 21, 2008
Update: I forgot to mention, the source code for the server part is available at flickr-commentr
flickr commentr is a simple tool to allow you post flickr pictures on flickr comments, or any other forum or blog
To install it, drag this bookmarlet to your bookmarks bar
flickr comment
When you are browsing a flickr photo, click the bookmarklet and you’ll see a popup like the following screenshot, where you can select the size and attributes to show, and copy the HTML code to post the picture.

Posted in Open Source | No Comments »

Loading ...
Posted by Jorge Bernal May 13, 2008
Update: I’ve been suffering some ungly and stupid bugs today, so I’ve fixed them and released version 0.2. It also includes a new script wp-update-home.

I’ve just published some scripts that help me manage my personal wordpress installations, and publish some plugins I’m working on.
Warning: these are early versions which I use for small tasks. If you find
a bug or have suggestions, contact me at jbernal@warp.es
Download version 0.1 version 0.2 or browse the wordpress-scripts git repository.
wp-dump
wp-dump helps you to backup your wordpress database. Just tell where is the wordpress directory and where to put the dump file
Syntax
$ wp-dump wordpress-dir outfile
outfile will be a gzipped SQL dump, so you should use the .sql.gz extension
wp-import
wp-import helps you to restore your wordpress database. Just tell where is the wordpress directory and where to read the backup file
wp-import expects the backup to be a gzipped dump
Syntax
$ wp-import wordpress-dir infile
publish.sh
publish.sh is useful if you:
- Manage your plugins with git
- Want to publish versions to a remote server using scp
Syntax
$ publish.sh plugin_name version
publish.sh will replace version numbers in your code (see Requirements), tag
the release with git, create a tarball and upload it to the specified server.
Requirements
First, you need a config file called ~/.wpplugins. An sample way to do this is
$ echo myserver.example.com:public_html/plugins/ > ~/.wpplugins
where myserver.example.com is your server and public_html/plugins/ is the
path (relative from your $HOME) to upload the tarballs
publish.sh can also replace version numbers in your plugin. It will detect these two cases
- Plugin header: Version 0.1
- Version constant: define(plugin_name_version, ‘0.1’);
wp-update-home
When you are syncing wordpress databases, one of the fundamental things to change is the siteurl and home options with the remote URL.
Syntax
$ wp-update-home wordpress-dir myhost.example.com
It’s been a while since I last released some open source project (beyond small patches) and it feels as good as ever 
Posted in Open Source | 1 Comment »

Loading ...
Posted by Jorge Bernal May 09, 2007
I’ve been looking for an open source project to collaborate for some time now, and given the time I’m spending with MySQL lately and the expertise I’m gaining thanks to MySQL training, it looked like an obvious choice.
During the last advanced bootcamp, Tobias found bug #27894, which apparently was a simple fix. Dates in binlog were formatted as 736 instead of 070306 (for 2007-03-06). During the bootcamp I used my lonely nights at the hotel and came up with a patch, and some days later my first contribution was going into the main MySQL code.
The problem
Now I had to find something bigger. One of the things that most annoys me of MySQL is the lack of some way to abort a procedure or trigger: there is no raise method. To generate a custom error you have to do hacks like:
SELECT `
Error: Invalid firmware series for this model
` INTO dummy FROM model;
The solution
There is a SIGNAL command in the SQL:2003 standard which does the job, but it’s not implemented (yet) in MySQL. The syntax, according to the manual is as follows:
SIGNAL signal_value [ SET signal_information_list ]
signal_value:
condition_name
| sqlstate_value
signal_information_list:
[ signal_information_list , ] signal_information_item
signal_information_item:
condition_name = condition_value
condition_name:
CLASS_ORIGIN
| SUBCLASS_ORIGIN
| CONSTRAINT_CATALOG
| CONSTRAINT_SCHEMA
| CONSTRAINT_NAME
| CATALOG_NAME
| SCHEMA_NAME
| TABLE_NAME
| COLUMN_NAME
| CURSOR_NAME
| MESSAGE_TEXT
In this first part I’ll cover the basics: just the SIGNAL command with a fixed generic error, enough to get rid of the dirty hacks.
The implementation
Getting used to foreign code always takes some level of difficulty, but when you have to deal with grammars and parsers it’s all crazy fun. First, we have to add a symbol for our new command
sql/lex.h
In this file, we have a symbols[] array where we have to add SIGNAL. Since it seems to be sorted in alphabetic order, we’ll put our line between SHUTDOWN and SIGNED:
{ "SHUTDOWN", SYM(SHUTDOWN)},
{ "SIGNAL", SYM(SIGNAL_SYM)},
{ "SIGNED", SYM(SIGNED_SYM)},
sql/share/errmsg.txt
Before we get our hands dirty with the parser file, let’s get our custom error prepared. I took a look at the SQLSTATE error messages and I found the 38503 (Exception generated from user-defined function/procedure) enough related to this.
In this file we have a series of error constants with their corresponding error messages in various languages. Since our new error will be related to stored procedures, I decided to put with the rest of SP-related errors:
ER_SP_CASE_NOT_FOUND 20000
eng "Case not found for CASE statement"
ger "Fall für CASE-Anweisung nicht gefunden"
ER_SP_SIGNAL 38503
eng "Exception generated from user-defined function/procedure"
ER_FPARSER_TOO_BIG_FILE
eng "Configuration file '%-.64s' is too big"
ger "Konfigurationsdatei '%-.64s' ist zu groß"
sql/sql_yacc.yy
And finally to the point. Here we have to declare that we’ll be using the SIGNAL_SYM which we defined at sql/lex.h as a token.
%token SHUTDOWN
%token SIGNAL_SYM
%token SIGNED_SYM
Then, in the sp_proc_stmt label (look for sp_proc_stmt: at the beginning of a line), we add sp_proc_stmt_signal as another possibility (we’ll define this in a minute):
| sp_proc_stmt_iterate
| sp_proc_stmt_signal
| sp_proc_stmt_open
And finally, between the sp_proc_stmt_iterate and the sp_proc_stmt_open definition we add our code:
sp_proc_stmt_signal:
SIGNAL_SYM
{
LEX *lex= Lex;
sp_head *sp= lex->sphead;
sp_instr_error *i;
i= new sp_instr_error(sp->instructions(), lex->spcont, ER_SP_SIGNAL);
sp->add_instr(i);
}
This basically tells the parser to expect the SIGNAL_SYM token (SIGNAL) with no arguments, and generate an error with our new error code (ER_SP_SIGNAL). As you might see there’s some extra code which I copied directly from similar definitions, which I’ll refer to as parser magic (anyone willing to explain what sphead and lex variables are will be very welcome)
Conclusion
This one wasn’t so extremely difficult if you had some previous experience with Bison, but the next part can be more interesting, since I guess we’ll have to add some more functions than sp_instr_error to be able to show custom error messages. Also, we’ll have to prepare some test cases to verify our newly created behaviour.
I hope this helps someone trying to contribute to MySQL. If you want to try this at home you can follow the article or apply the patch
Posted in Development, MySQL, Open Source | 6 Comments »

Loading ...
Posted by Jorge Bernal February 26, 2007
Well, not so easy but really close this time. I don’t remember how I got there, but I found a perl script to order pizza from the command line. Bad news is that only works for Domino’s in the US, but I bet it’s a matter of time. Envy is a great motivator (check out Bluetooth Remote for reference).
The site: Pizza Party
[Via: Digg]
Posted in Open Source | No Comments »

Loading ...
Posted by Jorge Bernal September 16, 2005
I’ve just released gnome-torrent 0.2. It has no new features, as it got not much free time from me
but some bugfixes and translations:
- nl: Ramon de Ruiter
- fr: Erwan
- sv: Andreas Eriksson
You can get it at http://www.amedias.org/~koke/gnome-torrent/
BTW, thanks all for the suggestions and bug reports. I hope to discover the way to have days with 27 hours and add the most wanted features
Posted in Development, Open Source | 1 Comment »

Loading ...
Posted by Jorge Bernal July 06, 2005
All this began when I discovered jamendo. Shortly, it’s a website where you can listen CC-licensed albums and download them using BitTorrent or another networks. I found quite interesting albums and I decided to try gnome-btdownload for downloading them.
I found this software quite simple and nice, very much in the gnome style, but I couldn’t help to have X windows opened (one for each download/seed), mostly when X → ∞ (or at least a relatively huge number if you try to be nice and share as much as you get).
So I wanted to start hacking on this code and make it download multiple files at once in only one window and hide it in the system tray. I have finished writing my own code albeit I’ve reused all the BitTorrent part.
It’s my first whole desktop program that works and it’s an incredible feeling… I feel like the child who discovered computers years ago
I’ve setup a small webpage for the interested:
Gnome Torrent

Posted in Development, Open Source | 1 Comment »

Loading ...