Older blog entries for lgs (starting at number 24)

Windows tricks

Yes, I'm learning some Windows tricks. Erny is my teacher and Google is my friend:

Autocompletion in the system terminal
Go to the Registry and assign a 9 to the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\ComletionChar . Hint: 9 is the ascii code for the tab character

Autorunning Python programs
What I want is that if I have the file myprogram.py in the current directory and I type "myprogram" it should execute "python myprogram.py". So add ";.py" to the env variable PATHEXT

grep, diff, cat and some other old friends
Yes, we all know the great cygwin project but I want something much more lightweight. Voila!
XML-RPC From Javascript

I've been trying some fresh new concepts lately and it's time to share it with everybody who read this :-)

Sometimes I wish I could reload some part of a website without reloading the whole page. People usually do this by inserting an IFrame and reloading its contents with a Javascript timer or something similar. That's not a bad solution but I was looking for something more flexible.

So I jump into XmlHttpRequest. This is something Microsoft first created for Internet Explorer and then the other browser decided to provide something similar. So, except for the creation code, everything else should be crossbrowser.

So what you can do with XmlHttpRequest? Basically you can open http connections from Javascript so you can assign this kind of functions to onClick events or whatever you want, get some data from a server, and then use that data to update your favourite div. Pretty neat, right?

Well, not everything is so nice. Security issues arise when you want to make PUT request instead of GET ones. Mozilla won't let you make a PUT to a domain different from the domain your page is living on. Please note that http://localhost and http://localhost:8000 are different domains from Mozilla point of view. If you use a url of the form file:/// you just need to give your page some security permissions, but to be honest, file:/// urls are not very useful.

Next point, XML-RPC is cooler than simple HTTP, don't you think so? I was pretty happy to find that Mozilla has a component called nsXmlRpcClient.js (in /usr/lib/[mozilla|firefox]/components) that seemed to do what I wanted. Well, I spent the whole tuesday afternoon trying to make it work with the examples and couldn't make it.

So next day (yesterday) I decided to write my own XML-RPC layer on top of xmlhttprequest and I was pretty succesfull with very simple calls (no arguments). I was very excited to get something useful actually running. Today I just added a lot of sugar to it: multiple arguments calls, autoscrolling debugging console, more descriptive error messages, ...

The last problem was the security one? How do I have an http server (for hosting the pages) and an xml-rpc one at the same port so I can make Mozilla happy with security issues? Well, there are several solutions (Zope, your custom server, ...) but I just write a rewrite rule for Apache so everything that looks like http://localhost/xmlrpc/ is forwarded to my xml-rpc python server which is listening at port 8008. Simple and effective!

For those of you who want something visible I have some demos at http://sexmachine.homelinux.net/test_xmlhttprequest.html . Internet Explorer won't work. muHAHAHAHA

Informat 2004

I had a talk at Informat 2004 where I explained how to get money with Free Software. It seems people liked my words so I'm pretty proud and happy.

Manuel Martin, from La Junta de Andalucia, was also happy to know that our company try to make free software so hopefully we will work together in future projects. A great thing indeed.

Jornadas GNOME Hispano

14:45 end of the talk. 14.50 start driving to Madrid. 19.30 arrive to Madrid. 20.00 start my workshop about Python and GNome. 21.00 end of the workshop and start focusing in dinner. As you can see, a pretty busy friday.

Grex took us to a small bar in Madrid were we drunk a lot of Ribeiro and ate several Sepias, Croquetas and Pulpo. Amazingly it was only 6 euros each one!! Yes, Madrid. After going to some pubs and drinking a little bit more we had the oportunity to see acs and Jordi in some very funny situations.

Fabian, Antonio and me decide to head home and the adventure continued. Looking for Fabian house at 3 o'clock in the morning driving through Madrid citycenter is pretty funny specially if you think you are at the south of the Kio Towers and you are at the north instead. Blame the simetry!

So even if I only was at the end of the meeting I'm very happy I did 400 kilometers to be there because I talked with several interesting people and meet some very nice geeks.


I finished work today and when I left the office suddenly it was night again. Last friday it was still sunny at the same time but it seems the autumm has came already.

Today, it rained a lot. I was driving home, listening to some good rock band. The reworked freeway was being a breeze and everything was making me feel good.

I like winter. I like raining. I like darkness.

A new week starts. Maybe a new life?

12 Oct 2004 (updated 12 Oct 2004 at 10:02 UTC) »
Gazpacho patches

After releasing 0.3.1 last friday just before a small holidays here in Spain, I started to get a bunch of bug reports and patches which makes me *really* happy because: a) People stil have not forgot about Gazpacho and b) There is interest on it. More information on the gazpacho mailing list.

Plone customization

Our LUG is working on a project about a CMS for associations and non profit organizations here in Granada. We are not sure which system to choose but Plone2 is one of the candidates. I played a little bit with it and these are the changes/adaptations I made to it:

  • Skin: Changed colors, logo and portlet frames. Also put the 'You are at ....' bar in the same space as the user actions.
  • Added a Photo gallery plugin
  • Added Epoz as the textarea sustitute

I stil want to add more Products like a Wiki or a Forum system but it seems Plone2 can meet all our request. Next point will be performance (hugh!)

If you want to see my test place check it out at http://sexmachine.homelinux.net:8080/gcubo/

GMail Applet

Some weeks ago I got a gmail account and I realized that they don't have pop3/imap support so you need to log into the webmail to see if you have something new. I understand they want you to see the ads but that's too much for a email compulsive user as me.

So I hacked up a 50 lines gnome systray icon to alert me when you have mail:

#!/bin/env python

import pygtk pygtk.require('2.0') import gtk import gnome import eggtrayicon

import libgmail

ACCOUNT = 'your.name@gmail.com' PASSWORD = 'yourpassword' REFRESH_INTERVAL = 1000 * 60 * 5 # this is in milliseconds (5 minutes)

class GMailApplet(object): def __init__(self): gnome.program_init('gmail-applet', '0.0.1') self.applet_window = eggtrayicon.create_window('gmail-applet') self.applet_window.connect('destroy', gtk.main_quit)

self.event_box = gtk.EventBox() self.image_widget = gtk.Image() self.image_widget.set_from_file('gmail.png') self.event_box.add(self.image_widget)

self.image_widget.show() self.applet_window.add(self.event_box) self.applet_window.show_all()

self.account = libgmail.GmailAccount(ACCOUNT, PASSWORD) self.account.login() gtk.timeout_add(REFRESH_INTERVAL, self.refresh_handler) def run(self): gtk.main()

def refresh_handler(self): # handle gtk events while gtk.events_pending(): gtk.main_iteration(gtk.FALSE)

unreadMsgCount = self.account.getUnreadMsgCount()

if unreadMsgCount > 0: self.image_widget.set_from_file('gmail_notice.png') else: self.image_widget.set_from_file('gmail.png') return gtk.TRUE if __name__ == '__main__': g = GMailApplet() g.run()

You need libgmail and eggtrayicon.

There are some screenshots

System V init scripts

I got tired of editing my /etc/hosts by hand to adapt my network configuration depending on if I'm at home or at the office. So I decided to hack something on the initscripts:

  1. Edit /boot/grub/menu.lst and duplicate some entries adding a LOCATION={home|office} parameter:
    title Fedora Core (2.6.8-1.521) Office
            root (hd0,0)
            kernel /boot/vmlinuz-2.6.8-1.521 ro root=LABEL=/ rhgb quiet LOCATION=office
            initrd /boot/initrd-2.6.8-1.521.img

    title Fedora Core (2.6.8-1.521) Home root (hd0,0) kernel /boot/vmlinuz-2.6.8-1.521 ro root=LABEL=/ rhgb quiet LOCATION=home initrd /boot/initrd-2.6.8-1.521.img

  2. Write a System V script (actually copying an existing one and adapting) called location which copies the right /etc/hosts. Note the chkconfig lines at the beginning of the file:
    # chkconfig: 2345 90 10
    # description: little script to configure some stuff depending if the laptop \
    #              is at the office or at home

    # source function library . /etc/init.d/functions

    start () { echo $"$LOCATION" if [ -e /etc/hosts.$LOCATION ]; then cp /etc/hosts.$LOCATION /etc/hosts else echo $"localized hosts file not found" fi }

    stop () { echo "Have a good day" }

    case "$1" in start) start ;; stop) stop ;; restart|reload) stop start ;; *) echo $"Usage: $0 {start|stop|restart}" exit 1 esac

    exit 0

  3. Install the location script with chkconfig:
    [root@i8100] chkconfig location on

  4. Write /etc/hosts.home and /etc/home.office

That's all. Next time I reboot I will have my right network configuration just by selecting one grub menu item. :-)

Email mistery

Last weekend I was quite happy as I didn't receive almost any spam message and this is quite uncommon for me as I still haven't got the time to set up a spam message filter. Then I sent something to a mailing list and didn't get it (I'm suscribed to that mailing list). Then my cousing told me she had sent me something the day before. Then I started to feel I was loosing emails.

First step, don't panic. Next step, log in into the mail server and check some logs. It seemed that the mails were being accepted by the mailserver but never came to my inbox. I started to blame my new Evolution 2.0 since I just installed last weekend and so I enter in the #evolution irc channel.

I was pretty amazed on how fast these guys told me what the problem was: something in my ~/.procmailrc was wrong. First of all I'll describe the problem. It seemed that some of the mail I got (the one being lost) wast getting stored in a very strange file called & (yes, an ampersand) in the ~/Maildir/ folder. I open the .procmailrc and saw the offending line:

* ^(From|Cc|to).*desktop-devel-list@gnome.org

Obviously the & should be replaced by :0: . Everything has a logic explanation after all.

Python circular module dependencies

Or the Python Holy Grial, as I like to call it. You have a file called a.py and then a file called b.py and you need something in a.py from b.py and viceversa. Isn't it quite common? Well, with Python this is a gotcha, one of the very few I have managed to find after a few years programming in this language.

Decent gcubogotchi

This weekend I did some icons for my friends just to include them on Evolution contacts and I also made a decent one for myself

There is also another version of the whole body

/gnome stuff

Finally I realized that the easiest way to get the last piece of bit of every program I usually need is to install them all in a alternate prefix, like /gnome. And forget about your distro packages and dependencies. Yes, we all know apt and yum are great but then you go back to use jhbuild or garnome to get the last gnome build. What if you want other programs (e.g. Gaim) integrated with it?

After quite a while without posting I come back again thanks to the preasure somebody is doing these days.

Let's start with something simple: small hack to display a rotated pango text. I just copied the idea from pygtk mailing list but I didn't want to wait until I have my widgets realized to draw the rotated label.

So here you have the code and a small demonstration of the concept.

Thanks to jamesh for his nice explanation about colors, visuals, depth, and all those internal X concepts we all love.

15 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!