Crayola colors in JSON format

Picture of crayolas I ran into the Wikpedia page for Crayola offical colors.

The list consists of 133 colors, with names and HEX values, so with a little help of Python, it was easy to extract them into a JSON file that we can use:

[
    {
        "hex": "#EFDECD",
        "name": "Almond",
        "rgb": "(239, 222, 205)"
    },
    {
        "hex": "#CD9575",
        "name": "Antique Brass",
        "rgb": "(205, 149, 117)"
    },
    {
        "hex": "#FDD9B5",
        "name": "Apricot",
        "rgb": "(253, 217, 181)"
    },
    {
        "hex": "#78DBE2",
        "name": "Aquamarine",
        "rgb": "(120, 219, 226)"
    },
    {
        "hex": "#87A96B",
        "name": "Asparagus",
        "rgb": "(135, 169, 107)"
    },
    {
        "hex": "#FFA474",
        "name": "Atomic Tangerine",
...

Get the full list of crayola colors in JSON format

Posted in en, javascript | 1 Comment

Usabilidad de las entradas del cine

Ayer fuí a ver Misión Imposible a Cineplanet. Como es de costumbre, hice una breve cola, fuí amáblemente atendido y recibí el ticket de entrada:

Foto de ticket de Cineplanet

Como siempre, confío plenamente que la entrada es para la función que pedí y procedo a memorizar la información que me confirma la chica que atiende por que va a ser imposible encontrar esos datos en la entrada.

Entrada de cine con secciones identificadas

Como se puede ver gran parte de el papel está destinado a llevar información que como cliente no me es importante, y haciendo cálculos aproximadamente sólo el 4.5% del área del papel tiene datos que me interesan.

Por qué no pueden hacer algo más parecido a esto? Incluso en blanco y negro.

Diagrama de entrada de cine

No interesa si adicionalmente me entregan un comprobante de pago y si usan toooda la parte de atrás para poner publicidad y letras pequeñas.

No creería que siguen haciendo lo mismo sólo por que es más difícil de imprimir!

Posted in es | Tagged | 3 Comments

Update on Google reader reading space

This week Google launched its new top bar, which changed Google Reader’s DOM making the userContent rules I explained last month useless.

Well, here’s the fix for the new Topbar. This time it is much easier:

/* userContent.css */
@-moz-document url-prefix(http://www.google.com/reader/) {
    #gb {
    display: none;
    }
}

Now you have more reading space in Google reader.

Screenshot of Google Reader in Firefox

Posted in css, en, firefox, Google, html | Leave a comment

Como agregar un campo a todos los elementos en una collección Mongo

Lo acabo de poner en inglés., pero también lo buscarán en español. Asó que aquí va.

Escribo esto por que encontrar la respuesta me tomó más de lo que esperaba. Finalmente estaba en StackOverflow, pero la pondré acá de nuevo explicando como funciona.

Como las bases de datos Mongo no tienen esquema, no existe comando ALTER TABLE para agregar un nuevo campo a todos los elementos, lo que se hace es actualizar la colección por medio del comando update.

La documentación de Update es muy escasa al respecto y el mapeo de SQL a Mongo tampoco indica nada al respecto.

Así es como se hace una modificación a todos los elementos sin ninguna condición en particular:

db.collection.update( criteria, objNew, upsert, multi )

Queremos actializar todos así que nuestra condición será un objeto vacío.

{}

Queremos añadir un nuevo atributo a todos los objetos, así que usaremos la clave “$set” para hacerlo. El valor que mandemos tendrá la forma de un documento que combinaremos con cada uno de los elementos.

{'$set': {new_key:value}}

No queremos Upsert, asi que vamos a poner False ahí. Si mandaramos True, además de modificar los documentos, agregaríamos un nuevo elemento a al colección con el documento que estamos enviando como dato, y eso no queremos.

En multi, decimos que sí: True, esto es necesario para que se actualice toda la colección y no sólo el primer elemento.

El comando quedaríá así:

db.collection.update( {}, {'$set': {new_key:value}}, false, true)
Posted in es, programacion | Leave a comment

Add a key to all items on a MongoDB collection

Again, I am posting this because it took me more than expected to find this easy answer. I found it on StackOverflow, but I will repost and explain here.

Since Mongo is a schemaless database, there is no “ALTER TABLE“, so what you need to do is update all the items.

The MongoDB documentation on Updates is not very clear on how to do this. And the SQL to Mongo mapping doesn’t explain this either.

So, here’s how you do it. You perform an update with empty criteria

db.collection.update( criteria, objNew, upsert, multi )

We want to update all the elements, so we use empty criteria

{}

We want to add an attribute, so we will $set the key, it will be in the form of a document to be “merged” with each item.

{'$set': {new_key:value}}

We don’t want upsert. So we set that to False, if we set it to true, the update call will add an item to the collection containing the value we wanted to set and nothing more, which is not what we want.

For multi, we will say True, because we want the update to happen on all the collection item’s and not just the first one.

db.collection.update( {}, {'$set': {new_key:value}}, false, true)
Posted in en, programacion | Leave a comment

Sepia images with Django, Python and Sorl-thumbnail

Picture side by side of a toy in color and sepiia

Meet Sorl-sepia, a Sorl engine backend (PIL only so far) to turn your images into sepia tones. See the README file for instructions.

The interesting trick about sepia images is that they are just gray-scale pictures with a different color palette. In this case the sepia color I’m using is #FFF0C0.

Doing this on PIL is quite straight forward (from effbot’s blog):

# You have your PIL Image instance on a 'im' variable

# Convert it to grayscale
im = im.convert('L') # L mode means gray-scale

# Set the sepia palette
im.putpalette(linear_ramp) # will explain this later

# Make RGB again
im = im.convert('RGB')

And there you have it. Now the linear_ramp variable. It is actually a map of 256 blocks indicating what color to use for each of the possible gray-scale values (white to black). You can see the original blog post on how to build the linear_ramp.

If you just want to turn your images to gray-scale instead of sepia, set sorl-sepia SORL_DEFAULT_SEPIA_TONE setting to (0, 0, 0).

Posted in django, en, programacion, Python | Leave a comment

Squeeze more readable space out of Google Reader’s new layout

I am not happy with the removal of Google Reader social features. I really enjoyed discovering new feeds following people.

Anyway, I don’t mind the new look but it leaves too little readable space. A couple of years ago I blogged about how to use Firefox’s userContent.css to optimize the layout.

Here’s how the new layout looks at the moment:

Screenshot of Google Chrome with Google Reader

Here’s what it will look like (Notice the vertical space in the reader area):

Firefox screenshot of Google Reader ew layout

This is what you need to add to your userContent.css file.

@-moz-document url-prefix(http://www.google.com/reader/) {
    #top-bar {
    display: none;
    }
}
/* For some reason I had to take this out of @-moz-document */
body.gecko #lhn-add-subscription-section, body.gecko #viewer-header {
height: 40px !important;
}

Switching to full screen F plus Sift + U sort of does the trick as well, but I don’t like having the whole screen’s width to read as lines become too long.

Posted in css, en, firefox, geek, tech | Tagged , , | 1 Comment

Install PIL with Jpeg support on Ubuntu Oneiric 64bit

I am posting this because it took me ages to figure out how to solve this one.

I could not get PIL to compile with JPEG, Zlib or freetype support on my virtualenv. I am using Ubuntu Oneiric Beta1 on a Lenovo Thinkpad X220. That is a 64bit installation.

As read in every blog post out there, you first need to install the system libraries so PIL can find them.

$ sudo apt-get install libjpeg libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev

After that, your regular pip install PIL should work under most situations. In my case I was still seeing this summary after the installation:

    ---------------------------------------------------------------
    *** TKINTER support not available
    --- JPEG support not available
    --- ZLIB (PNG/ZIP) support not available
    --- FREETYPE2 support not available
    *** LITTLECMS support not available
    ---------------------------------------------------------------

After a lot of googling around, I found this solution on Ubuntu forums.
It turns out that the APT installations put the libraries under /usr/lib/x86_64-linux-gnu and PIL will search for them in /usr/lib/. So you have to create symlinks for PIL to see them.

# ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
# ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
# ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib

Now proceed and reinstal PiL, pip install -U PIL:

    ---------------------------------------------------------------
    *** TKINTER support not available
    --- JPEG support available
    --- ZLIB (PNG/ZIP) support available
    --- FREETYPE2 support available
    *** LITTLECMS support not available
    ---------------------------------------------------------------

tada :D !

Posted in en, geek, programacion, Python | Tagged , , , | 13 Comments

Show http:// protocol in URL bar for Firefox 7+

Firefox 7 beta was just rolled out yesterday to users on the Beta channel (that would include me).

One of the various improvements and changes is that now Firefox follows Opera and Chrome in hiding the http:// protocol prefix from URLs.

I like my http, luckily you can switch to the old behavior from our good old friend about:config. To enable them back set this pref to ‘false

browser.urlbar.trimURLs = false

You’ll see the change immediately :)

Posted in en, firefox, geek | Tagged , | 15 Comments

Programación con Azucar

La semana pasada en el Barcamp dí por primera vez la charla de Programación con Azucar que hace tiempo quería hacer.

Programación con Azucar es un nombre a algo que ya venimos haciendo, que es preparar nuestros programas para que al usarlos causen placer en los usuarios. Esto normalmente va más allá de cumplir especificaciones o casos de uso (El usuario debe poder agregar X, Se mostrará el listado de YY, etc).

Van a disculpar la presentación pero tuve que hacerla 15m antes que me toque salir :P

  • No programar para 0 y n únicamente, existen otros números (Joel Spolsky)
  • Programa un escenario completo para la primera experiencia/Usuario nuevo
  • Te va a demorar más
  • Tu usuario es una persona con una vida y cosas más importantes
  • Interactúa con tus usuarios, respóndeles. Son MUY importantes!
  • Que sepan que hay una persona de tu lado
  • Hazlos sonreir

Espero poder mejorar la charla en el futuro y tener una presentación más preparada visualmente con ejemplos más claros y una lista de tips más concisa :)

Posted in Forgot to categorize | 1 Comment