Programacion


16
Sep 09

gettext tag for Webgen (quick and dirty)

If you are generating sites with webgen, when you need to add i18n to them, you have to make copies of the pages for each language. I want it something more like gettext. So I end up writing a new tag in webgen to use gettext. It’s working for me, YMMV. I’ve used webgen 0.5.10.

Continue reading →


27
Jun 09

Density map of anonymous Wikipedia edits

I’ve made a video showing anonymous edits on Wikipedia as a density map grouped by day.


Direct link to the video on Flickr: http://www.flickr.com/photos/xrm0/3654611676/

Continue reading →


5
Jun 09

Torneos automaticos en elbruto.es

Para automatizar la inscripcion de tu personaje a los torneos de elbruto.es podes usar este script:
Continue reading →


28
Jan 09

flickraw proxy support

I made a small patch to use proxies with flickraw (0.5.1). It uses the environment variable http_proxy or HTTP_PROXY (in that order) to get the proxy settings.
You can see the changes at flickraw-proxy@github.


27
Oct 08

Prototype ajax gotcha

If you are one of those who leave the docs as a last resort, you may find that when doing ajax requests with Prototype all requests except get and post are emulated using post and adding a _method parameter.

The code doing this is in ajax.js:

if (!['get', 'post'].include(this.method)) {
// simulate other verbs over post
params['_method'] = this.method;
this.method = 'post';
}

The documentation about this is here: http://www.prototypejs.org/api/ajax/options

The reason for using _method is because not all browsers support delete / put, according to ticket 289, which is a request to change this behaviour.


22
Oct 08

Inconsistencies with array length in Javascript

What you’d say is the size of [1,2,] in Javascript?
Until last day I’d say 2 without much thinking. But under IE, the size is 3, because of the last comma.
Now, it’s valid to define arrays like this [,,1], [1,,2] or even [1,,]. All of them having 3 elements. But what about this particular case when having a single comma after the last element?.

The definition of the correct behaviour is stated in ECMA-262, section 11.1.4 Array Initialiser, which I didn’t bother to read as I’ve already made my mind and decided this is another IE bug.

The reasons for thinking this is a bug are:

  • It’s simpler to generate js code from another language without the need to check if it’s the last element or not and add a comma when needed.
  • When leaving a comma after the last element in another languages, for example Ruby, Python or Java, that last comma does not add another ‘undefined’ element to the array (ok, I don’t know how much valid is to compare other languages to js in this aspect, but I like this feature).

Tested on: IE 7, Firefox 3 (linux/win)


17
Oct 07

File Binary Search

I’ve created a small ruby gem for doing binary searches on a file. The gem is named (not surprisingly) BinarySearch RecordSearch

After announcing the gem on Ruby Talk (here is the announcement), I’ve been told there is already a project with the same name (http://raa.ruby-lang.org/project/ruby-bsearch/), so I renamed it as RecordSearch.