2012-11-02 Welcome iPad mini

So, finally I bought an iPad (mini).

I should stop spending my money.

20121103-120434.jpg

I’m quite surprised, as I’m using the iPad more than I thought. Painting, writing, reading, web browsing. Now I’m just searching for the right apps.

20121103-120443.jpg

Right now I’m testing Paper. Great interface, great results. I just have to practice a lot.

After trying digital tablets (wacom bamboo), it’s refreshing to draw on the ipad. It could seem a tiny detail, but seeing your hand at the same time than the drawing is a HUGE improvement.

What I miss on Paper (maybe it’s an iPad limitation) is the lack of pressure sensitivity, and the bad precision of the touches while drawing. I hope it can be solvable with practice.

About the iPad mini… It’s the perfect size (at least for me). Interface doesn’t seem small at all, it’s really light (it could be better), and I’m not missing the retina display (as much as in the iPad 2).

New Stage

After all the changes in my life in the late months, I wanted to keep track of what’s going on on my life. Since twitter killed my blog (I’m too lazy), and I’m unable to write on a diary / moleskine / notebook, I’m gonna try using Day One.

20121103-120454.jpg

The implementation of Day One is quite cool, as you already have photos os each day, just write a little comment about one of them. Cool way to remember.

20121103-123855.jpg

If I have many pics from one day, I always can use Diptic to create a composition.

Well, let’s see in a few days if I succeed!

Arrays en PHP

Me encantan los arrays en php, son un saco en el que cabe de todo:

    $datos = array(
        'nombre' => 'Víctor',
        'apellidos' => 'Jiménez',
        'Cero',
        '0' => 'Otro Cero',
        1 => 'uno',
        'dos',
        '1' => 'UUUUNO'
    );

    foreach ($datos as $key => $value) {    ?>
        print "$key : $value \n";
    }

Es curioso cómo se pueden mezclar claves escalares y asociativas en un mismo objeto. Y más curioso es ver cómo convierte ‘0’ a 0. El código anterior muestra:

  nombre: Víctor
  apellidos: Jiménez
  0: Otro Cero
  1: UUUUNO
  2: dos

(25) playing with bash autocompletion

Updated: as Blaxter notes, it’s necessary to open a new terminal after editing the bashrc file for the changes to take effect. Also, I’ve replaced the tail -n+2 with the -ss option. Thanks Baron Schwartz!

One of the things I’ve been doing lately is doing some cleanup on my laptop.

There are two things I’m constantly using on the shell:

  • Open a project folder
  • Connect to a MySQL Database

Bash Functions

I first made a bash function to help me with the projects paths:

function cdp {
case $1 in
  "foo")
    cd /Users/golo/devel/svn/foo/src ;;
  "bar")
    cd /Users/golo/devel/svn/bar/src ;;
  *)
    echo "Options:"
    echo ""
    echo "  foo"
    echo "  bar"
esac
}

I placed that on my /etc/bashrc , so I write:

$ cdp foo

And it takes me to the foo project folder.

But, as I have lot of open projects, I have to remember «foo» and «bar», or worse… ¡¡Write «foo» or «bar»!!

Bash Autocompletion

My Lazyness made me learn how to create bash autocompletions. This case is easy as executing «cdp» without parameters you get a list with all possible values. It’s easy to parse ;).

The autocompletor should be placed on the file /etc/bash_completion.d/cdp with this content:

_cdp_show()
{
        local cur opts

        cur="${COMP_WORDS[COMP_CWORD]}"
        opts=$(cdp | tail -n+2)
        COMPREPLY=( $(compgen -W "${opts}" ${cur}) )
}
complete -F _cdp_show cdp

opts stores all possible options (line per option), and cur stores the text to be autocompleted (not sure). compgen is a helper to create the autocompletion options, and complete is the command that does the autocompletion reading the COMPREPLY variable.

Now I get the following behavior:

$ cdp <tab><tab>
foo    bar
$ cdp f<tab>
$ cdp foo

Oh! Amazin!

MySQL Bash Autocompletion

¿What can be more awesome than that? Let me guess… ¡Autocompletion for mysql command!

The goal is to get autocompletion for the mysql databases. No more writing…

$ mysql information_schema

For that, we need a list of all databases on a parseable format, let’s try with SHOW DATABASES:

$ mysql -e "SHOW DATABASES"
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
$ # Let's put this on a better format:
$ mysql -B -e "SHOW DATABASES"
Database
information_schema
mysql
performance_schema
$ # That's better, let's delete the table header:
$ mysql -B -ss -e "SHOW DATABASES"
information_schema
mysql
performance_schema
$ # We are ready! :D

Disclaimer: I tried mysqlshow but doesn’t accepts the Batch format, also I have the user and password on my /etc/my.cnf so this trick is not suitable for production environments.

Let’s create an autocompletor mixing this command with what we already know. The result is the file /etc/bash_completion.d/mysql:

_mysql_show()
{
        local cur opts

        cur="${COMP_WORDS[COMP_CWORD]}"
        opts=$(mysql -B -ss -e "SHOW DATABASES;" )
        COMPREPLY=( $(compgen -W "${opts}" ${cur}) )
}
complete -F _mysql_show mysql

Now you can use <tab>:

$ mysql i<tab>
$ mysql information_schema

Hope it helps! Improvements are welcomed 😉

(5) Free Merluza

No sabía cuántas cosas tenía pendientes en mi servidor hasta que me he puesto a mirarlo por dentro.

Resulta que con la última actualización de ebox a zentyal, los repositorios de los proyectos dejaron de funcionar, entre otras cosas porque no actualicé la configuración del LDAP. Hoy he estado un buen rato actualizando los tracs y reconfigurando la autenticación.

La configuración de los repositorios subversion la hago a través de apache. Poco ha cambiado desde que escribí Cómo configurar apache para autenticar con el LDAP de Zentyal, sólo he tenido que actualizar la contraseña y los nombres de dominio.

Sin embargo, me ha sido imposible volver a configurar los tracs para que autentiquen correctamente. O yo no conseguía configurar los plugins que existen, o no funcionaban para la última versión de trac.

La solución ha sido sencilla (aunque no muy elegante). Utilizando el AccountManagerPlugin, hay una opción para autenticar mediante una ruta HTTP (HttpAuthStore). Lo que hace el servidor es llamar a una ruta http con el usuario y contraseña que da el usuario. Si la solicitud se lleva a cabo con éxito, el usuario está autenticado.

Perfecto! Como se configurar apache fácilmente para autenticar, puedo usar lo mismo para autenticar los tracs :D.

Wordpress Themes

Lo otro que he hecho hoy es un paso previo a la remodelación del css de esta web. Consiste en liberar todos los temas de wordpress que he hecho hasta la fecha. Utilizar un repositorio subversion me facilitará el actualizarlos, y ya de paso publico el código para quien quiera curiosear.

En fin… mañana más 😀

()

Tras años de estudios, trabajo y mudanzas; mi montaña de proyectos sin acabar ha crecido y empieza a asustar.

Por eso, hoy empiezo un perido de paréntesis. Voy a dedicarme, por cinco semanas, a hacer todo lo que llevo tiempo queriendo hacer.

Proyectos, viajes, experimentos… lo que de tiempo.

Parte de la experiencia consiste en documentar todo lo que haga. Así que estos días habrá bastante movimiento por el blog.

Tengo muchas ganas de empezar, aunque de momento será mejor que recupere el sueño acumulado.