Archive for August, 2007

Repeat after me: Javascript is not Python

Wednesday, August 29th, 2007

I guess I’m too used to the Python programming language that whenever I have to write simple Javascript functions I keep making the same mistakes. I tend to write as much functionality as possible in the server side (Python :) ) but in order to create rich user interfaces I have to use the client side (Javascript :( ) and things like this happens:

function addTopic(topic) {
    var input_attrs = {
        type: "checkbox",
        checked: "checked",
        name: "topics",
        value: topic,
    };
    var li = Builder.node('li', [Builder.node('label', [Builder.node('input', input_attrs), topic.title])]);
    $("topic_list").appendChild(li);
}

For those of you who are curious, yes I’m using Script.aculo.us and Prototype libraries here but here is the point: There is a syntax error in the previous code, one that Firefox (and thus Firebug) won’t catch but one that Internet Explorer will. The funny thing is the Internet Explorer error message:

Error: Expected identifier, string or number

So, anybody can answer me: is the trailing comma a real Javascript syntax error or just another Internet Explorer flaw?

The display:inline vs whitespace battle

Tuesday, August 28th, 2007

Yesterday I spent quite a lot of time debugging an annoying CSS issue. I wanted to make an horizontal navigation bar so I started using this markup:


<ul>
<li><a href="/section1/">Section 1</a></li>
<li><a href="/section2/">Section 2</a></li>
<li><a href="/section3/">Section 3</a></li>
<li><a href="/section4/">Section 4</a></li>
</ul>

In order to make the list horizontal there are two CSS techniques you can use: 1) float everything or 2) use display: inline. I decided to use option 2) since it is less intrusive and I didn’t want to change the rest of the page layout.

So this is how the CSS looks like:


ul { display: inline; }
li { display: inline; border: 1px solid black; }

My problem was that there was some unwanted space between the list elements that made them difficult to stylish properly. After trying everything on earth to fix it I google for a while until I found the offending thing.

As you make the elements inline whitespace matters and the new line characters in the markup are the ones making the little margin between the list elements. You can fix this problem putting all the elements in a single line but that’s not very readable and it’s quite ugly. So this is how I fix it:

<ul>
<li><a href="/section1/">Section 1</a></li
><li><a href="/section2/">Section 2</a></li
><li><a href="/section3/">Section 3</a></li
><li><a href="/section4/">Section 4</a></li>
</ul>

A creative job offer

Sunday, August 12th, 2007

Today I got a pretty creative email from the Zope3-Users mailing list. It seems they are hiring super heroes. I can’t expect less from a company with such a name….

Running Maemo scratchbox on Fedora 7

Tuesday, August 7th, 2007

The Maemo SDK runs on top of Scratchbox, which has some problems with Fedora kernels and memory managers. If you see an error like this when trying to log in in your scratchbox environment:


Inconsistency detected by ld.so: rtld.c: 1192: dl_main: Assertion `(void *) ph->p_vaddr == _rtld_local._dl_sysinfo_dso' failed!

Then you can try this:


# su -
# echo 0 > /proc/sys/vm/vdso_enabled

Note that the maemo-sdk-install_3.1.sh script will fail if you don’t disable the vdso kernel feature as above.

La red de casa

Saturday, August 4th, 2007

El otro día hice inventario del cacharreo que tengo en casa y tengo que admitir que me sorprendí al darme cuenta de que tenía más máquinas conectadas en red de las que en principio creía:

red-casa

Un breve comentario sobre cada una:

  • El cable modem Motorola es el segundo que uso en mi conexión a Internet y me lo dieron los de Supercable, luego Auna, y ahora Ono. El primero murió en una subida de tensión.
  • El router wifi neutro Linksys WRT54Gv5 también es el segundo que tengo ya que el primero, un WRT54Gv2 también murió por las mismas causas que el cable modem. Me gustaba más el primero ya que tenía Linux dentro y estaba bien entrar por ssh y ajustar las iptables a mano. Con el que tengo ahora me tengo que limitar a la interfaz web.
  • El PC Clónico lo compré el año pasado y es un AMD64 de doble núcleo con 2 Gigas de RAM. Bastante bien para programar a diario e incluso para jugar a juegos como el Doom III. En verano hace un ruido bastante feo así que este año le he comprado una fuente sin ventilador y algo se ha notado.
  • El ordenador negro pequeñito (en vertical mide meno que un boli) tiene dentro mi placa EPIAM1000, una gran compra que hice hace ya casi 4 años. Antes la tenía en un tupperware pero el año pasado decidí darle el alojamiento que merece. Tiene 256 MB de RAM y un disco IDE de 120 Gigas. Ahora mismo sirve mi blog y algunas cosillas más sin problemas.
  • El portatil me lo compró la empresa estas navidades y tras muchos problemas con los repartidores de DELL (UPS) conseguí que llegará a casa. Es un Dell XPS 1210 y estoy muy contento con lo poco que pesa, lo poco que ocupa y lo rápido que va.
  • El Internet Tablet PC (así lo llaman los de Nokia) N800 es una pijada muy útil cuando quieres ver cualquier cosa de Internet y tienes los ordenadores apagados. O cuando quieres leerte ese PDF tan chulo que has encontrado desde tu cama. O para ver un episodio de la serie de turno también desde tu cama. Este N800 no fue gratis como el anterior N770 pero me dieron un descuento por desarrollador y me salió muy baratico.
  • Y por último la Wii, mi adquisición más polémica de estas navidades pero de la que más contento estoy. Recientemente me he pasado el Resident Evil 4 y he de decir que desde pequeño había querido tener una consola y esta es la primera que tengo. Todo un acierto y si no, preguntad al que pasa por mi casa y se echa un tenis en pista cubierta.

Y ahora algunas curiosidades sobre estas máquinas:

  • Tres de ellas usan Fedora Linux, una de ellas la versión Core 6 y las otras dos la versión 7.
  • Nota freak: estos son los nombres de algunas: nyarlathotep, sub-nigurath, yog-sothoth. Me falta por bautizar otras tres.
  • Dentro de poco la familia se ampliará con el PC de Ana, su Nintendo DS y su N770. Veremos a ver si me sale más rentable montar un cluster.
  • La red Wifi la tenía abierta para el uso y disfrute comunal hasta hace poco pero la tuve que proteger con WPA cuando los vecinos no supieron distinguir entre ver su correo/navegar por páginas web y bajarse la serie completa de Bola de Dragón del eMule.
  • En el dibujo, las lineas azules denotan conexiones cableadas y las lineas naranjas conexiones inalámbricas

Los nuevos leones de la Alhambra

Thursday, August 2nd, 2007

Desde que voy a trabajar a la Alhambra dos días por semana veo cosas muy interesantes. Lo último ha sido estar presente ante la renovación de los leones del Patio de los Leones:

el nuevo león de la Alhambra

gatos escaladores