2012/04/05

Emacs para desarrollo web

Para no pelearse con los conflictos con los php-mode y html-mode se puede uno instalar Nxhtml que además de resolver ese problema ofrece un montón de comodidades. 

Lo instalé siguiendo estos pasos:

  1. Descargar el fichero: web-vcs.el 
  2. Abrirlo y desde Emacs:
                M-x eval-buffer
  3. Luego:
               M-x web-vcs-nxhtml 
Con esto comienza la instalación... pero finalmente me dió algunos fallos.

Entonces lo que hice fue bajarlo en formato ZIP y seguí las instrucciones del README.

Necesité instalar la sb-html.el en .emacs.d/site-lisp y listo!!
       
   

2011/12/20

Alternativa a PuTTY en windows

Para conectarme mediante ssh/telnet en windows hasta ahora utilizaba el mítico Putty. Cumplía bastante bien su función aunque era incómodo y se volvía un poco loco si trabajaba con editores. Hoy he probado TeraTerm y me encuentro más cómodo. Recomendado! :)
       
   

2011/11/24

Escapar espacios en blanco en variables en Bash

Hoy me he sentido un poco estúpido... la típica chorrada que no te acuerdas ni se te ocurre como solucionar. Lo pongo aquí etiquetado como "humor". :D

En un script para la línea de comandos, tenía que entrar en un directorio con espacios en su nombre.

Pues no era capaz...
> foo="/tmp/foo bar/" 
> cd $foo 
bash: cd: /tmp/foo: No such file or directory 

Intenté todas las combinaciones posible para escapar el espacio y mil trucos.

Solución:
> foo="/tmp/foo bar/" 
> cd "$foo" 


Las comillas!!!!
       
   

2011/11/05

Drivers en PDO de PHP

¿Cómo saber que driver tengo disponibles para acceder a bases de datos con PHP::PDO?
Ejecuta esto en un terminal:

echo "PDO avalable drivers: \n";
foreach(PDO::getAvailableDrivers() as $driver) {
echo '* '.$driver."\n";
}

Y obtendo como salida el siguiente resultado:

PDO avalable drivers:
* mysql
* pgsql
* sqlite
* sqlite2

UPDATE:

Más facil todavia php -m | grep pdo
       
   

2011/06/23

Indentar todo una sección de código python con emacs

Cuando has programado un trozo de código en python y luego es necesario meterlo en un bucle... Arrrgggg... ¿a indentar línea por línea?

Emacs tiene la solución. Marca la sección que quieres desplazar y teclea:

C-c >

Otros comandos (extraídos de python.about.com):

* C-j: Insert a new line with the same indentation level as the current line
* RET: Insert a new line with the same indentation level as the current line
* C-M-a: Go to the beginning of the current function or class
* C-M-e: Go to the end of the current function or class
* C-M-h: Mark the current function or class for copying, etc.
* C-M-x: Execute the current function or class
* C-c C-b: Submit a bug report
* C-c C-c: Execute the buffer (i.e., the file being displayed)
* C-c C-d: Trace the stack of the process being executed
* C-c C-h: Get context-based help
* C-c TAB: Indent a highlighted (or marked) region
* C-c C-k: Mark a block of text. Using this at the head of a class or function definition will mark the entire block.
* C-c C-l: Shift the region to the left. If the cursor is in the middle of a region, the lower half of the region will shift.
* C-c RET: Execute the current file, opening a new window to show the output.
* C-c C-n: Jump to the next statement.
* C-c C-p: Jump to the previous statement.
* C-c C-r: Shift the region to the right. If the cursor is in the middle of a region, the lower half of the region will shift.
* C-c C-s: Execute a Python command.
* C-c C-t: Toggle shells
* C-c C-u: Go up one block
* C-c C-v: List the version of the Python mode
* C-c C-w: Run PyChecker
* C-c !: Open the Python interactive shell
* C-c #: Comment the highlighted (marked) region
* C-c :: Check the indentation off-set
* C-c <: Shift the region to the left
* C-c >: Shift the region to the right
* C-c ?: Show Python mode documentation
* C-c |: Execute the highlighted (marked) part of the current program.

Note that Python mode for Emacs offers more functionality than this, but these are the basics. If you know Emacs from editing other languages, learning your way around the Python mode is a snap.
       
   

2010/12/29

Metrónomo en Ubuntu

Qué lejos queda mi época de técnico de sonido... y de mis estudio casero. Actualmente tengo problemas hasta para sacar sonido por la tarjeta del portatil. Dejando aparte los problemas con rosegarden, qsynth y jack, estuve atascado para poder ejecutar sin problemas GTick un métronomo simple y cómodo que usa GTK+ y OSS (compatible con ALSA).

Pues el caso es que tenía el siguiente error:
Couldn't start metronome.
Please check if specified sound device
and sample file are accessible.
Y "/dev/dsp" que era el dispositivo configurado no existía.

Finalmente encontré con la solución. Ejecutar con el comando:
$ aoss gtick
aoss es un script que permite la compatibilidad de las librerías OSS y ALSA.
       
   

2010/12/27

Máquina virtual en VirtualBox como servidor

Tengo un máquina virtual con Debian servida desde "Windows XP" con VirtualBox 3.2. Quiero tener accesibles servicios lanzados en la máquida huesped (el Debian) que sean sólo desde la máquina windows.

La solución es hacer Port Forwarding como explican aquí. En mi caso particular con jetty, para acceder a servicios en el puerto 8080 hice:

C:\...\Orable\VirtualBox> VBoxManage.exe setextradata "VM Name Here" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/jetty/Protocol" TCP

C:\...\Orable\VirtualBox> VBoxManage.exe setextradata "VM Name Here" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/jetty/GuestPort" 8080

C:\...\Orable\VirtualBox> VBoxManage.exe setextradata "VM Name Here” \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/jetty/HostPort" 9999


Todo esto con la máquina parada. Antes de iniciarla, en la configuración la red tuve que marcar "pcnet" porque sino daba un error relacionado con la obtención de la MAC.