<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>Jam Blog - Isla de Margarita - Venezuela</title>
 <link href="http://blog.jam.net.ve/atom.xml" rel="self"/>
 <link href="http://blog.jam.net.ve/"/>
 <updated>2015-01-07T16:00:21-04:30</updated>
 <id>http://blog.jam.net.ve/</id>
 <author>
   <name>Jesus Marin</name>
   <email>jam@jam.net.ve</email>
 </author>

 
 <entry>
   <title>Crea tu propia nube con Syncthing, alternativa a BTSync y AeroFS</title>
   <link href="http://blog.jam.net.ve/2015/01/07/crea-tu-propia-nube-con-syncthing"/>
   <updated>2015-01-07T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2015/01/07/crea-tu-propia-nube-con-syncthing</id>
   <content type="html">&lt;p&gt;Syncthing es una aplicacion opensource de sincronizacion de archivos escrita en Golang
la cual implementa su propio protocolo de Block Exchange.&lt;/p&gt;

&lt;p&gt;Syncthing es de codigo abierto y viene a ser una alternativa a BittorrentSync
 y AeroFS, la cual son dos conocidas aplicaciones para sincronizar archivos usando 
 el protocolo P2P y conectando los nodos (PC, Laptop, Servidor) de forma directa,
 sin usar ningun servidor como intermediario y encriptando todas las comunicaciones
 entre ellos.&lt;/p&gt;

&lt;p&gt;Con Syncthing tu eres propietario de tu propia &lt;strong&gt;nube&lt;/strong&gt; y de tus datos, tu ideas
la infrastructura a usar y como la vas a usar, tu decides que se va a respaldar
y cuantas replicas quieres tener ademas de decidir que tanto espacio de almacenamiento
quieres o necesitas. Esta aplicacion es tambien multiplataforma por lo que puedes
correr un nodo en Linux, BSD, Windows y mac.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;h1 id=&quot;instalacion&quot;&gt;Instalacion:&lt;/h1&gt;

&lt;p&gt;En el Servidor uno descargamos los binarios de Syncthing desde su repositorio 
&lt;a href=&quot;https://github.com/syncthing/syncthing/releases&quot;&gt;Github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Para el momento de escribir este articulo la ultima version es la &lt;code&gt;v0.10.18&lt;/code&gt;.
En mi caso descargo la version de 32bits para Linux, pero en la misma pagina 
puede descargarse las versiones 64bits y las versiones para plataformas como
BSD, Windows y mac.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;wget https://github.com/syncthing/syncthing/releases/download/v0.10.18/syncthing-linux-386-v0.10.18.tar.gz&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Descomprimir el paquete de binarios&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;tar xzvf syncthing-linux-386-v0.10.18.tar.gz&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y luego copiamos el binario &lt;strong&gt;syncthing&lt;/strong&gt; ubicado en la carpeta que se crea al
descomprimir el paquete al directorio &lt;code&gt;/usr/local/bin/&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo cp syncthing-linux-386-v0.10.18/syncthing /usr/local/bin/&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;una vez copiado el binario podemos eliminar la carpeta extraida pues ya no
la necesitamos.&lt;/p&gt;

&lt;h1 id=&quot;servicio-upstart-para-debianubuntu&quot;&gt;Servicio upstart para Debian/Ubuntu:&lt;/h1&gt;

&lt;p&gt;Con esto tenemos Syncthing instalado y listo para usar, pero seria un poco
incomodo ejecutarlo pues tendriamos que iniciarlo desde esa carpeta, en este caso
usaremos un script upstart para poder arrancar y detener syncthing mas facil.&lt;/p&gt;

&lt;p&gt;Creamos un archivo en &lt;code&gt;/etc/init/&lt;/code&gt; con el nombre &lt;code&gt;syncthing.conf&lt;/code&gt; y colocamos
el siguiente contenido:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;description &lt;span class=&quot;s2&quot;&gt;&amp;quot;Syncthing P2P sync service&amp;quot;&lt;/span&gt;

start on &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;local&lt;/span&gt;-filesystems and net-device-up IFACE!&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;lo&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
  stop on runlevel &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;!2345&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;

  env &lt;span class=&quot;nv&quot;&gt;STNORESTART&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;yes
  env &lt;span class=&quot;nv&quot;&gt;HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/home/tu_usuario
  setuid &lt;span class=&quot;s2&quot;&gt;&amp;quot;tu_usuario&amp;quot;&lt;/span&gt;
  setgid &lt;span class=&quot;s2&quot;&gt;&amp;quot;tu_grupo&amp;quot;&lt;/span&gt;

  &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; /usr/local/bin/syncthing

  respawn&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Notese que se ajusta el directorio &lt;code&gt;HOME&lt;/code&gt; de tu usuario y se agrega tu nombre de
usuario y grupo en &lt;code&gt;setuid&lt;/code&gt; y &lt;code&gt;setgid&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Con esto ya podemos arrancar el servicio de Syncthing con un simple:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo initctl start syncthing&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;o con un simple:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo service syncthing start&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1 id=&quot;configuracion-basica-en-servidores&quot;&gt;Configuracion basica en servidores:&lt;/h1&gt;

&lt;p&gt;Ya en este punto deberiamos tener corriendo syncthing, por default la interfaz web
escucha en el puerto &lt;code&gt;8080&lt;/code&gt; y como medida de seguridad lo hace solo en localhost,
lo que quiere decir que por defecto no puedes acceder de forma remota.&lt;/p&gt;

&lt;p&gt;Syncthing en el primer arranque crea un archivo &lt;code&gt;config.xml&lt;/code&gt; de Configuracion en 
la ruta &lt;code&gt;~/.config/syncthing/&lt;/code&gt;. Si abrimos este archivo en un editor podemos
editarlo para que pueda recibir conexiones desde el exterior y poder administrar
Syncthing de forma remota.&lt;/p&gt;

&lt;p&gt;Buscamos las siguientes lineas:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;gui&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;enabled=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;tls=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;false&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;address&amp;gt;&lt;/span&gt;127.0.0.1:8080&lt;span class=&quot;nt&quot;&gt;&amp;lt;/address&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/gui&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y reemplazamos la IP &lt;code&gt;127.0.0.1&lt;/code&gt; por &lt;code&gt;0.0.0.0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTA:&lt;/strong&gt; De seguro estas utilizando un &lt;strong&gt;Firewall&lt;/strong&gt; en tu servidor, por lo que es
necesario que abras el puerto &lt;code&gt;8080&lt;/code&gt; para poder recibir conexiones entrantes.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw allow 8080
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw allow 22000&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Syncthing usa por defecto el puerto &lt;code&gt;22000&lt;/code&gt; para el protocolo de sincronizacion
por lo que este tambien debe abrirse para conexiones entrantes.&lt;/p&gt;

&lt;p&gt;Con esto ya puedes acceder a tu servidor desde el navegador y configurar Syncthing
desde la interfaz web incluida. &lt;code&gt;http://servidor.tld:8080&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;En la parte superior derecha podemos ver un engranaje desee el cual podemos acceder
a la seccion de configuracion:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/tSCQSir.png&quot; alt=&quot;Syncthing Config&quot; title=&quot;Configuracion Syncthing&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Como se puede notar, es posible configurar el nombre del dispositivo (nodo), la
ip y puerto de escucha para la interfaz web, y lo mas importante, la asignacion de
un nombre de usuario y clave para proteger el acceso a interfaz web, asi como el 
uso de &lt;code&gt;HTTPS&lt;/code&gt; para proteger la comunicacion en dicha interfaz.&lt;/p&gt;

&lt;p&gt;De esta misma forma es posible instalar y configurar multiples servidores (nodos)
en internet para sincronizacion y respaldo de archivos.&lt;/p&gt;

&lt;h1 id=&quot;conexion-entre-dos-nodos-y-comparticion-de-archivos&quot;&gt;Conexion entre dos nodos y comparticion de archivos:&lt;/h1&gt;

&lt;p&gt;La forma en la que Syncthing se comunica entre los demas nodos es usando un &lt;strong&gt;ID&lt;/strong&gt;
unico. En el primer arranque, Syncthing genera este ID para identificar el nodo.&lt;/p&gt;

&lt;p&gt;Un ID identificador de nodo es similar a esto:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/isdQLam.png&quot; alt=&quot;Node ID&quot; /&gt;&lt;/p&gt;

&lt;p&gt;y es posible obtenerlo desde el boton de engranaje antes mencionado, haciendo click
en &lt;strong&gt;“Mostrar ID”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Notese que tambien se visualiza un codigo QR, esto es debido a que esta en desarrollo
una version para telefonos celulares en la que podemos agregar los nodos de 
sincronizacion usando su codigo QR.&lt;/p&gt;

&lt;p&gt;Para agregar un nodo al cual nuestro servidor puede comunicarse para sincronizar
archivos y carpetas basta con hacer click en &lt;strong&gt;“Agregar Dispositivo”&lt;/strong&gt; en la pagina
principal de la interfaz web, a continuacion nos aparece un formulario en donde nos
solicita unicamente el &lt;strong&gt;ID&lt;/strong&gt; del nodo y el nombre del mismo.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/Qm3ZExA.png&quot; alt=&quot;New Node&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Tambien nos permite elegir que carpetas queremos sincronizar con ese nodo en 
especifico.&lt;/p&gt;

&lt;p&gt;Esta tarea se debe hacer de la misma forma en el nodo receptor, en el cual se debe
crear y compartir la carpeta con el mismo nombre que en el nodo de origen.&lt;/p&gt;

&lt;h1 id=&quot;creando-repositorios-carpetas&quot;&gt;Creando Repositorios (carpetas):&lt;/h1&gt;

&lt;p&gt;En Syncthing los repositorios son simples carpetas las cuales contienen los archivos
a sincronizar y compartir con los nodos que tu elijas. Para crear una tan solo
has click en el boton &lt;strong&gt;“Agregar Repositorio”&lt;/strong&gt; y acontinuacion aparecera una 
ventana como esta:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/o6vSZob.png&quot; alt=&quot;New repo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;En dicho formulario se puede colocar el &lt;strong&gt;ID del repositorio&lt;/strong&gt; el cual sera el nombre
unico que tendra la carpeta en el nodo actual. Tambien es posible indicar la ruta
del repositorio o carpeta, si esta no existe en el servidor syncthing la creara
de forma automatica.&lt;/p&gt;

&lt;p&gt;De igual forma puedes indicar aqui con cuales nodos deseas compartir dicho repositorio.&lt;/p&gt;

&lt;p&gt;Nuevamente: si deseas compartir y sincronizar este reporitorio con otro nodo, el
repositorio debe ser creado con el mismo ID y nombre de carpeta en el nodo receptor&lt;/p&gt;

&lt;p&gt;Con todo esto en mente tenemos el conocimiento necesario para armasr nuestra propia
&lt;strong&gt;Nube&lt;/strong&gt; privada, solo tu tienes acceso a ella, solo tu la controlas y decides que 
tanto espacio de almacenamiento quieres que esta tenga. Al mismo tiempo tienes la 
capacidad de agregar mas nodos a esta &lt;strong&gt;Nube&lt;/strong&gt; a modo de replicas de seguridad.&lt;/p&gt;

&lt;p&gt;Syncthing es una herramienta que a pesar de estar todavia en desarrollo se comporta
de una manera muy estable y nos brinda un gran potencial para proteger nuestros
datos mas preciados.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Configuracion basica de Fail2Ban en Linux.</title>
   <link href="http://blog.jam.net.ve/2014/12/21/configuracion-fail2ban-linux-ssh"/>
   <updated>2014-12-21T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2014/12/21/configuracion-fail2ban-linux-ssh</id>
   <content type="html">&lt;p&gt;Segun la Wikipedia:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Fail2ban es una aplicación escrita en Python para la prevención de intrusos 
en un sistema, que actúa penalizando o bloqueando las conexiones remotas que 
intentan accesos por fuerza bruta.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Fail2ban&lt;/strong&gt; nos sirve de ayuda para proteger servidores y vps contra ataques de fuerza
bruta sobre determinados servicios que estos ofrescan, la manera en que trabaja es
analizando los archivos de logs que los diversos servicios generan, y busca en ellos
registros de comportamientos no tipicos (por lo general basado en alguna regla ya
    especificada) para luego determinar la ip del origen del ataque y proceder a 
&lt;strong&gt;banearla&lt;/strong&gt; o &lt;strong&gt;bloquearla&lt;/strong&gt; mediante el Firewall o algun sistema de control de paquetes.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;h1 id=&quot;instalacion-de-fail2ban&quot;&gt;Instalacion de Fail2ban:&lt;/h1&gt;

&lt;p&gt;Para instalar Fail2ban basta con teclear en una terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo apt-get install fail2ban iptables-persistent&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Aqui el paquete iptables-persistent lo instalamos para que las reglas de baneo
agregadas al firewall iptables esten disponibles y sean persistentes luego de un
reinicio.&lt;/p&gt;

&lt;h1 id=&quot;configuracion-basica-de-fail2ban&quot;&gt;Configuracion basica de Fail2ban:&lt;/h1&gt;

&lt;p&gt;Una vez instalado, procedemos a realizar alguna configuracion basica requerida 
para comenzar a proteger ciertos servicios en el servidor, en este caso se pasa a
configurar fail2ban para proteger el servicio &lt;strong&gt;SSH&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Fail2ban viene con un archivo de configuracion &lt;code&gt;jail.conf&lt;/code&gt; que nos sirve de ejemplo
y que por lo general en las actualizaciones puede cambiar, por lo que es recomendable
copiarlo y renombrarlo a &lt;code&gt;jail.local&lt;/code&gt; para luego alli editar y colocar las configuraciones
a nuestro gusto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;una vez copiado el archivo, podemos proceder a configurarlo de acuerdo a nuestras
necesidades:&lt;/p&gt;

&lt;h3 id=&quot;bantime&quot;&gt;bantime:&lt;/h3&gt;

&lt;p&gt;Al abrir el archivo &lt;code&gt;jail.local&lt;/code&gt; una de las primeras cosas que podemos editar es
la linea referente al &lt;code&gt;bantime&lt;/code&gt; el cual hace referencia al tiempo (en segundos) 
  en la que una IP sera baneada o bloqueada. Por lo general viene con un tiempo
  algo corto como &lt;code&gt;600&lt;/code&gt; segundos, que seria algo asi como 10 minutos.&lt;/p&gt;

&lt;p&gt;Este valor podriamos cambiarlo a por ejemplo a &lt;code&gt;3600&lt;/code&gt; que seria algo asi como 1 hora.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;bantime&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 3600&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id=&quot;maxretry&quot;&gt;maxretry:&lt;/h3&gt;

&lt;p&gt;La cantidad maxima de intentos fallidos que se pueden permitir se especifica con
&lt;code&gt;maxretry&lt;/code&gt;, si una IP alcanza este numero, pasara a ser baneada o bloqueada.
Por lo general viene configurada a 3, pero podriamos ser super exigentes y cambiarlo
a 2.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;maxretry&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 2&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id=&quot;findtime&quot;&gt;findtime:&lt;/h3&gt;

&lt;p&gt;Una IP puede alcanzar el limite de intentos fallidos (especificado con maxretry)
  de forma muy rapida, o puede que haga los intentos en ciclos de varios minutos o horas,
  ese tiempo limite podriamos especificarlo con &lt;code&gt;findtime&lt;/code&gt;, si una IP alcanza
  los intentos fallidos dentro de ese periodo de tiempo, pasara a ser baneada.&lt;/p&gt;

&lt;p&gt;Por lo general viene con un valor bajo como &lt;code&gt;600&lt;/code&gt; segundos, pero podemos cambiarlo
  a nuestro gusto por un valor mas alto.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;findtime&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 1000&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id=&quot;destemail&quot;&gt;destemail:&lt;/h3&gt;

&lt;p&gt;Fail2ban nos permite especificar una direccion de correos para que este nos envie
notificaciones con informacion sobre una IP recientemente bloqueada. Con 
&lt;code&gt;destemail&lt;/code&gt; espeficificamos ese correo.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;destemail&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; correo@dominio.tld&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id=&quot;mta&quot;&gt;mta:&lt;/h3&gt;

&lt;p&gt;Fail2ban es capaz de usar algun agente de transferencia de correos instalado en
el servidor para el envio de notificaciones, por default viene configurado para usar
&lt;code&gt;sendmail&lt;/code&gt;, pero podriamos cambiarlo a &lt;code&gt;mail&lt;/code&gt; para luego usar servicios como Postfix
para que este realice el envio de los correos.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;mta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; mail&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id=&quot;action&quot;&gt;action:&lt;/h3&gt;

&lt;p&gt;Con esto configuramos la accion que fail2ban tomara para realizar un baneo,
    estas acciones estan tambien especificadas en el archivo, nosotros solo tendremos
    que elegir una:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;action&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; %&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;action_mwl&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;s&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1 id=&quot;configuraciones-de-baneo-por-servicios&quot;&gt;Configuraciones de baneo por servicios:&lt;/h1&gt;

&lt;p&gt;Fail2ban viene con un conjunto de reglas de bloqueo predefinida de acuerdo a determinados
servicios, culminando en archivo &lt;code&gt;jail.local&lt;/code&gt; podemos ver algunas de estas reglas,
muchas de ellas estan desactivadas, por lo que tan solo debemos buscar la que necesitamos 
y activarla:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;ssh&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;enabled&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;port&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; ssh
&lt;span class=&quot;nv&quot;&gt;filter&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; sshd
&lt;span class=&quot;nv&quot;&gt;logpath&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; /var/log/auth.log
&lt;span class=&quot;nv&quot;&gt;maxretry&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 3&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Esta regla arriba nos permite proteger el servicio SSH contra ataques de fuerza bruta
 y demas intentos de acceso, notese que se especifica con &lt;code&gt;logpath&lt;/code&gt; la ruta del
 archivo log de dicho servicio, este archivo es el que Fail2ban analizara en busqueda
 de potenciales atacantes para ser bloqueados.&lt;/p&gt;

&lt;p&gt;Notese tambien que podemos espeficicar el puerto con &lt;code&gt;port&lt;/code&gt; el cual usa dicho servicio,
si por ejemplo hemos cambiado el puerto de escucha para SSH a &lt;code&gt;2222&lt;/code&gt; o similar, debemos
indicarlo tambien alli.&lt;/p&gt;

&lt;p&gt;Tambien podemos ver que se especifica tambien el &lt;code&gt;maxretry&lt;/code&gt; esto nos permite ajustar 
el maximo numero de intento fallidos para cada regla o servicio.&lt;/p&gt;

&lt;p&gt;Una vez realizada la configuracion basica, ya tenemos listo fail2ban para comenzar
a trabajar y proteger, para aplicar las reglas tan solo necesitamos reiniciarlo:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo service fail2ban stop
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo service fail2ban start&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ya con esto podemos estar un poco mas tranquilos de haber agregado una capa mas 
de seguridad a nuestra PC o servidor. Logicamente es posible activar mas reglas 
o agregar nuestras propias reglas personalizadas, ademas de completar la configuracion
para el envio de notificaciones por correos.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Configuracion basica de UFW Firewall en Linux.</title>
   <link href="http://blog.jam.net.ve/2014/12/17/instalacion-configuracion-firewall-ufw-linux"/>
   <updated>2014-12-17T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2014/12/17/instalacion-configuracion-firewall-ufw-linux</id>
   <content type="html">&lt;p&gt;Al administrar servidores, una de las primeras cosas que se deben configurar para
aumentar la seguridad de los mismos es configurar un Firewall, Por suerte en Linux
se incluye uno por defecto llamado Iptables pero este firewall muchos lo ven un poco
complejo de configurar y administrar. Existen alternativas mas sencillas de usar 
como por ejemplo &lt;strong&gt;UFW&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;UFW es en realidad es una CLI o intefaz de linea de comandos para el Firewall Iptables
que incluye Linux, esta interfaz nos proporciona una manera un poco mas sencilla de 
administrar y configurar Iptables. para UFW incluso existe una GUI o interfaz
grafica llamada &lt;strong&gt;GUFW&lt;/strong&gt; el cual podriamos usar en una PC de escritorio o Laptop
para administrar y configurar el firewall.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;h1 id=&quot;instalacion-de-ufw-en-el-servidor&quot;&gt;Instalacion de UFW en el servidor:&lt;/h1&gt;

&lt;p&gt;para instalarlo basta con escribir en una terminal el comando&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo apt-get install ufw&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Por defecto UFW esta desactivado luego de la instalacion, por lo que podemos ver
su estado con el comando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw status verbose&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1 id=&quot;configuraciones-basicas-de-ufw&quot;&gt;Configuraciones basicas de UFW:&lt;/h1&gt;

&lt;p&gt;Algunas de las configuraciones basicas que podemos usar en UFW para asegurar nuestros
servidores son.&lt;/p&gt;

&lt;h3 id=&quot;reglas-por-defecto&quot;&gt;Reglas por defecto:&lt;/h3&gt;

&lt;p&gt;Las reglas por defecto o &lt;strong&gt;default rules&lt;/strong&gt; son, como su nombre lo indica, una serie
de reglas standar que nos facilita la configuracion de el Firewall, estas reglas nos
permiten especificar si queremos permitir &lt;code&gt;allow&lt;/code&gt; o denegar &lt;code&gt;deny&lt;/code&gt; el trafico entrante
&lt;code&gt;incoming&lt;/code&gt; o el trafico saliente &lt;code&gt;outgoing&lt;/code&gt;, ademas de algunas otras reglas.&lt;/p&gt;

&lt;p&gt;Una configuracion muy buena que de hecho usa GUFW apenas es instalado en una PC, 
es la de denegar &lt;code&gt;deny&lt;/code&gt; todo el trafico entrante y permitir &lt;code&gt;allow&lt;/code&gt; el trafico saliente.&lt;/p&gt;

&lt;p&gt;Esto lo podemos ajustar con los siguientes comandos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw default deny incoming&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Para denegar todo el trafico entrante.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw default allow outgoing&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Con estas dos configuraciones una PC esta bastante protegida al igual que un servidor,
pero si queremos aumentar la seguridad podriamos tambien denegar el trafico saliente
para una mayor seguridad, claro esta con la desventaja de que tendras que estar 
pendiente de que aplicaciones requieren alguna regla de trafico saliente para poder
funcionar correctamente.&lt;/p&gt;

&lt;h3 id=&quot;permitir-conexiones&quot;&gt;Permitir conexiones:&lt;/h3&gt;

&lt;p&gt;Supongamos que estamos configurando el firewall en nuestro servidor y denegamos 
todo el trafico entrante, como vamos a conectarnos remotamente a el mediante &lt;strong&gt;SSH&lt;/strong&gt;?. 
Necesitamos aplicar una regla que nos permita conectarnos al puerto &lt;code&gt;22&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Para esto usamos la opcion &lt;code&gt;allow&lt;/code&gt; y le especificamos el puerto al que queremos
permitir el trafico entrante y el protocolo TCP que este use:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw allow 22/tcp&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;UFW viene con algun conjunto de reglas prestablecidas que podemos usar mediante su nombre,
por ejemplo el comando anterior trata de abrir el puerto &lt;code&gt;22&lt;/code&gt; que es conocido por 
ser el puerto usado para conexiones &lt;strong&gt;SSH&lt;/strong&gt;, esta regla podriamos tambien habilitarla
con el comando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw allow ssh&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;De la misma forma podriamos usar otras reglas preestablecidas para servicios conocidos
como por ejemplo &lt;strong&gt;HTTP&lt;/strong&gt; que usa el puerto &lt;code&gt;80&lt;/code&gt;, &lt;strong&gt;HTTPS&lt;/strong&gt; que usa el puerto &lt;code&gt;443&lt;/code&gt;, etc.&lt;/p&gt;

&lt;h3 id=&quot;rangos-de-puertos&quot;&gt;Rangos de puertos:&lt;/h3&gt;

&lt;p&gt;Es posible tambien que quieras permitir el trafico entrante no solo a un puerto sino
a un rango de estos, un ejemnplo de esto podria ser con la aplicacion &lt;strong&gt;Mosh&lt;/strong&gt; 
que requiere sea abierto el rango de puertos que van del &lt;code&gt;60000&lt;/code&gt; al &lt;code&gt;61000&lt;/code&gt; por el 
protocolo &lt;code&gt;udp&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Esto lo podriamos aplicar escribiendo algo como:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw allow 60000:61000/udp&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id=&quot;denegar-conexiones&quot;&gt;Denegar conexiones:&lt;/h3&gt;

&lt;p&gt;De la misma forma en la que permitimos conexiones entrantes, podemos denegar dichas
conexiones.&lt;/p&gt;

&lt;p&gt;Supongamos que tenemos una regla por defecto en la que se permite todo el trafico 
entrante (NO se recomienda), pero nosotros queremos denegar el trafico entrante
solo en un puerto determinado, podriamos aplicar dicha configuracion con algo como:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw deny 22/tcp&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;De la misma forma podriamos hacerlo para denegar un rango de puerto.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw deny 60000:61000/udp&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id=&quot;eliminar-reglas&quot;&gt;Eliminar reglas:&lt;/h3&gt;

&lt;p&gt;Supongamos que hemos configurado el servidor SSH para usar el puerto &lt;code&gt;2222&lt;/code&gt; en lugar
del puerto &lt;code&gt;22&lt;/code&gt; anteriormente abierto, deberiamos eliminar la regla anterior en 
la que se permitia la entrada al puerto &lt;code&gt;22&lt;/code&gt;. Esto podriamos realizarlo con el 
siguiente comando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw delete allow 22/tcp&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;De forma similar podriamos hacerlo si se trata de un rango de puertos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw delete allow 60000:61000/udp&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Si por ejemplo tenemos un conjunto de reglas establecidas con UFW de las cuales 
queremos eliminar algunas pero no conocemos como realizar dicha eliminacion por ser
algun tipo de regla compleja, podriamos listarlas con el comando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw status numbered&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Lo que nos devolveria un conjunto de reglas numeradas como estas:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;     To                         Action      From
     --                         ------      ----
[ 1] 22                         ALLOW IN    Anywhere
[ 2] 80                         ALLOW IN    Anywhere
[ 3] 443                        ALLOW IN    Anywhere
[ 4] 60000:61000/udp            ALLOW IN    Anywhere
[ 5] 22000/tcp                  ALLOW IN    Anywhere
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Como se nota arriba, las reglas estan numeradas, por lo que podriamos usar ese 
numero para eliminar una regla en especifico:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw delete 5&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Lo que nos eliminara la ultima regla listada.&lt;/p&gt;

&lt;h1 id=&quot;activando-y-desactivando-ufw&quot;&gt;Activando y desactivando UFW:&lt;/h1&gt;

&lt;p&gt;Una vez configurada todas las reglas y asegurarnos de que todo esta correcto,
procedemos a activar el firewall con el comando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw &lt;span class=&quot;nb&quot;&gt;enable&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Con esto ya tendremos UFW activo y protegiendo las conexiones con las reglas que
hemos especificado.&lt;/p&gt;

&lt;p&gt;En caso de que queramos desactivar UFW tecleamos el comando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw disable&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Si por alguna razon requieres que se eliminen todas las reglas aplicadas&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo ufw reset&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Estas son solo algunas de las configuraciones basicas de UFW con las que podemos
agregar una buena capa de seguridad a nuestras PC y servidores, logicamente existen
configuraciones avanzadas que se pueden usar para mejorar todavia mas la seguridad
o para realizar algun tipo de tarea espeficica.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Autenticacion SSH basada en llaves publicas y privadas.</title>
   <link href="http://blog.jam.net.ve/2014/12/16/autenticacion-ssh-basada-en-llaves"/>
   <updated>2014-12-16T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2014/12/16/autenticacion-ssh-basada-en-llaves</id>
   <content type="html">&lt;p&gt;Por lo general cuando uno va a administrar un servidor o VPS de forma remota,
lo hace mediante una conexion SSH y por lo general inicias sesion usando un nombre
de usuario y clave. A pesar de que estas conexiones SSH son seguras, la forma de
autenticarse con usuario y clave no lo es del todo ya que esta expuestas a posibles
ataques mediante fuerza bruta. Para tener un poco mas a segurado nuestros servidores 
o VPS es aconsejable la autenticacion pero usando llaves SSH y desactivando la
autenticacion con claves.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Para realizar esto tan solo debemos realizar unos pocos pasos:&lt;/p&gt;

&lt;h1 id=&quot;subiendo-tu-llave-ssh-publica-al-servidor&quot;&gt;Subiendo tu llave SSH publica al servidor:&lt;/h1&gt;

&lt;p&gt;Para poder autenticarnos en un servidor usando llaves SSH lo primero que podemos
hacer es subir nuestra llave publica, estas, cuando las creas, por defecto son 
un archivo llamado &lt;code&gt;id_rsa.pub&lt;/code&gt; ubicado en la carpeta &lt;code&gt;~/.ssh/&lt;/code&gt; en tu &lt;strong&gt;PC&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;El contenido de esta llave publica SSH &lt;code&gt;id_rsa.pub&lt;/code&gt; debemos colocarlo en el
&lt;strong&gt;servidor&lt;/strong&gt;, en un archivo llamado &lt;code&gt;authorized_keys&lt;/code&gt; ubicado en la carpeta &lt;code&gt;~/.ssh&lt;/code&gt;
en el servidor.&lt;/p&gt;

&lt;h1 id=&quot;configurando-el-servidor-openssh-para-autenticacion-con-llaves&quot;&gt;Configurando el servidor OpenSSH para autenticacion con llaves:&lt;/h1&gt;

&lt;p&gt;Una vez subida al servidor la llave publica, toca realizar algunas configuraciones
para autenticarnos usando dicha llave. Es probable de que si en este punto intentas
autenticarte en el servidor, puedas realizarlo sin problemas usando la llave SSH
pero la idea es que solo se permitan los accesos y autenticacion solo con llaves 
y no con claves.&lt;/p&gt;

&lt;p&gt;Para realizar esto necesitamos editar en el &lt;strong&gt;servidor&lt;/strong&gt; el archivo 
&lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt; y cambiar o agregar las siguientes lineas de modo que 
queden como esta:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;PubkeyAuthentication yes
PasswordAuthentication no
ChallengeResponseAuthentication no¬
UsePAM no&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;La primera y la segunda linea son las mas importantes, &lt;code&gt;PubkeyAuthentication yes&lt;/code&gt;
permite la autenticacion mediante llaves SSH, y &lt;code&gt;PasswordAuthentication no&lt;/code&gt; 
deshabilita la autenticacion mediante claves.&lt;/p&gt;

&lt;p&gt;Con esto ya puedes conectarte a tu servidor o VPS usando tu llave publica SSH
y estar un poco mas tranquilo ya que con esto le agregas un poco mas de seguridad
a tu servidor. &lt;/p&gt;

&lt;p&gt;Pero ya que estamos, podriamos mejorar un poco mas la seguridad del servidor
haciendo algunos ajustes extras:&lt;/p&gt;

&lt;h1 id=&quot;desactivando-la-autenticacion-para-el-usuario-root&quot;&gt;Desactivando la autenticacion para el usuario root:&lt;/h1&gt;

&lt;p&gt;El usuario &lt;strong&gt;root&lt;/strong&gt; es el usuario con los mayores permisos en el sistema, iniciar
sesion en el servidor con este usuario es arriesgado ya que con el mas minimo error
en un comando es posible que produscas fallas irreparables en el sistema operativo.&lt;/p&gt;

&lt;p&gt;Desactivar la autenticacion del usuario root tambien nos permite agregar una capa
mas de seguridad al impedir que inicien sesion como root algun atacante que haya
logrado conseguir la clave del usuario root o su llave ssh.&lt;/p&gt;

&lt;p&gt;Para realizar esto necesitamos editar en el &lt;strong&gt;servidor&lt;/strong&gt; el archivo 
&lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt; y cambiar o agregar las siguientes lineas de modo que 
queden como esta:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;PermitRootLogin no&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Nota&lt;/strong&gt; Recuerda habilitar esta opcion solo despues de darle permisos de
administrador a algun usuario standar. por ejemplo agregando tu usuario al archivo
en &lt;code&gt;/etc/sudoers&lt;/code&gt;&lt;/p&gt;

&lt;h1 id=&quot;permitir-acceso-solo-a-ciertos-usuarios&quot;&gt;Permitir acceso solo a ciertos usuarios:&lt;/h1&gt;

&lt;p&gt;Otra forma de aumentar la seguridad es permitir el acceso solo a determinados 
usuarios. Para realizar esto necesitamos editar en el &lt;strong&gt;servidor&lt;/strong&gt; el archivo 
&lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt; y cambiar o agregar las siguientes lineas de modo que 
queden como esta:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;AllowUsers mi-usuario pepito fulanito&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;De la misma forma podrias usar la directiva &lt;code&gt;AllowGroup&lt;/code&gt; para permitir unicamente
a cierto grupo autenticarse en el servidor.&lt;/p&gt;

&lt;p&gt;Una vez terminado tan solo necesitamos reiniciar OpenSSH y tendremos activa todas
estas configuraciones.&lt;/p&gt;

&lt;p&gt;Con esto ya aumentamos un poco mas la seguridad en nuestro servidor, logicamente
se podrian realizar mas ajustes o agregar por ejemplo un sistema que utilice el 
firewall para bloquear el acceso a las IP que hayan tenido una cierta cantidad
de intentos fallidos de autenticacion. Esto ultimo lo explicare un poco mas adelante.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Administrando multiples llaves SSH y repositorios Git</title>
   <link href="http://blog.jam.net.ve/2014/12/04/administrando-multiples-llaves-ssh-y-repositorios-git"/>
   <updated>2014-12-04T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2014/12/04/administrando-multiples-llaves-ssh-y-repositorios-git</id>
   <content type="html">&lt;p&gt;Hay ocasiones en la que te encuentras con que tienes que usar multiples cuentas
GitHub, Bitbuket, Heroku o mas especifico, multiples cuentas en diversos
repositorios git. Esto puede deberse a que por ejemplo ya tengas cuenta personal 
en Github y alguna empresa para la que estes trabajando te pida crearte una nueva
cuenta GitHub usando una direccion de correo de dicha empresa. En estos casos y
si usas autenticacion via llaves SSH, puedes encontrarte con el inconveniente de 
que al hacer un &lt;code&gt;git pull&lt;/code&gt;, &lt;code&gt;git push&lt;/code&gt; o similares, git use la llave SSH que no 
corresponde a la cuenta que debes usar en ese servicio especifico. &lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Para corregir esto y poder usar multiples llaves SSH y multiples cuentas de 
repositorios Git, podemos crear un archivo &lt;code&gt;config&lt;/code&gt; de configuracion dentro de la carpeta
&lt;code&gt;~/.ssh&lt;/code&gt; en la que espeficiquemos como trabajaremos con las multiples cuentas y 
llaves SSH en un mismo servicio o reporisorio Git.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#############################&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# CONFIGURACION PARA GITHUB.#&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#############################&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#Cuenta GitHub Personal.&lt;/span&gt;
Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa
  IdentitiesOnly yes

&lt;span class=&quot;c&quot;&gt;#Cuenta GitHub segundaria&lt;/span&gt;
Host segundaria.github.com
  HostName github.com
  User git
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa_segundaria
  IdentitiesOnly yes&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;En este ejemplo podemos ver que tenemos dos cuentas GitHub a las cuales se acceden
desde una URL personalizada que especificamos con &lt;code&gt;Host&lt;/code&gt;. 
Esta a su vez se le indica la llave SSH a usar mediante &lt;code&gt;IdentityFile&lt;/code&gt; y el servidor
en donde se encuentra dicho servicio se especifica con &lt;code&gt;HostName&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Notese que en este ejemplo logicamente la URL &lt;strong&gt;segundaria.github.com&lt;/strong&gt; no existe, 
esta URL tan solo la usamos para poder indicar la cuenta GitHub y su respectiva 
llave SSH que debera usar Git para identificarnos en GitHub.&lt;/p&gt;

&lt;p&gt;De la misma forma podemos hacer algo muy similar con multiples cuentas en servicios
como Bitbucket o Heroku como podemos ver a continuacion en el siguiente archivo.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;################################&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# CONFIGURACION PARA BITBUCKET.#&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;################################&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#Cuenta BitBucket Personal.&lt;/span&gt;
Host bitbucket.com
  HostName bitbucket.com
  User git
  IdentityFile ~/.ssh/id_rsa
  IdentitiesOnly yes

&lt;span class=&quot;c&quot;&gt;#Cuenta BitBucket segundaria&lt;/span&gt;
Host segundaria.bitbucket.com
  HostName bitbucket.com
  User git
  IdentityFile ~/.ssh/id_rsa_segundaria
  IdentitiesOnly yes

&lt;span class=&quot;c&quot;&gt;#############################&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# CONFIGURACION PARA HEROKU.#&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#############################&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#Cuenta Heroku Personal.&lt;/span&gt;
Host heroku.com
  HostName heroku.com
  User git
  IdentityFile ~/.ssh/id_rsa
  IdentitiesOnly yes

&lt;span class=&quot;c&quot;&gt;#Cuenta Heroku segundaria&lt;/span&gt;
Host segundaria.heroku.com
  HostName heroku.com
  User git
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa_segundaria
  IdentitiesOnly yes&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Hay ocasiones en la que solo tienes una cuenta en algun servidor Git, pero igual
necesitas espeficicar que use una llave SSH especifica para poder autenticarnos
correctamente en dicho servidor. En esos casos podemos escribir algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;############################################&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# CONFIGURACION PARA SERVIDOR GIT PERSONAL.#&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;############################################&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#Cuenta Git Personal.&lt;/span&gt;
Host git.miservidor.net
  HostName git.miservidor.net
  User git
  IdentityFile ~/.ssh/id_rsa_gitpersonal
  IdentitiesOnly yes&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Con esto hecho ya podemos comenzar a clonar repositorios usando el el comando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git clone git@segundaria.github.com:jesusangelm/ConfVim.git&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Con esto clonaremos dicho repo usando la cuenta &lt;strong&gt;segundaria&lt;/strong&gt; en GitHub y su 
respectiva llave SSH.&lt;/p&gt;

&lt;p&gt;Notese que pueden haber ocasiones en donde para hacer un &lt;code&gt;git pull&lt;/code&gt; o &lt;code&gt;git push&lt;/code&gt; 
necesitaras especificar manualmente la URL personalizada o alias dentro de la 
carpeta &lt;code&gt;.git/&lt;/code&gt; en el archivo &lt;code&gt;config&lt;/code&gt; en la carpeta principal de tu proyecto Git:&lt;/p&gt;

&lt;p&gt;Cambiamos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;url&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; git@github.com:jesusangelm/jesusangelm.github.com.git&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;por:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;url&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; git@segundaria.github.com:jesusangelm/jesusangelm.github.com.git&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

</content>
 </entry>
 
 <entry>
   <title>Referencia Markdown</title>
   <link href="http://blog.jam.net.ve/2014/07/19/referencia-markdown"/>
   <updated>2014-07-19T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2014/07/19/referencia-markdown</id>
   <content type="html">&lt;p&gt;Segun la Wikipedia:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Markdown es un lenguaje de marcado ligero creado originalmente por John Gruber y Aaron Swartz que trata de conseguir la máxima legibilidad y “publicabilidad” tanto en sus forma de entrada como de salida, inspirándose en muchas convenciones existentes para marcar mensajes de correo electrónico usando texto plano. Markdown convierte el texto marcado en documentos XHTML bien formados, reemplazando el signo ‘menor que’ (‘&amp;lt;’) y los et por sus correspondientes referencias de entidad de caracteres. Markdown fue implementado originariamente en Perl por Gruber, pero desde entonces ha sido traducido a multitud de lenguajes de programación, incluyendo PHP, Python, Ruby, Java y Common Lisp. Se distribuye bajo licencia BSD y se distribuye como plugin (o al menos está disponible) en diferentes sistemas de gestión de contenidos (CMS).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;!-- more --&gt;

&lt;p&gt;Hago este articulo a modo de referencia debido a que por lo general cuando tengo
que formatear texto para algun comentario o algun articulo de este blog, lo hago
en &lt;strong&gt;Markdown&lt;/strong&gt; y siempre se me olvidan la sintaxis por lo que tengo que correr
a a buscar un sitio para referencias. Con esto ya sabre que lo unico que tengo 
que buscar es mi propio blog xD.&lt;/p&gt;

&lt;p&gt;Cuando escribes un comentario, un articulo, un correo por lo general lo haces
en texto plano y sin formato o con un formato muy pobre que podria perderse al
publicar dicho texto, con un comentario en algun foro o un articulo en un blog
es probable que le quieras dar algo de formato, como por ejemplo resaltar un
texto, agregar un enlace o crear una lista simple. En un correo o un articulo
de uhn blog por ejemplo la solucion seria escribir el contenido en HTML, pero
escribir HTML para formatear un texto podria ser un suplicio ya que necesitarias
escribir muchas etiquetas y muy probablemente necesitaras agregar estilos CSS
para ayudar al formateado del texto. Es aqui donde &lt;strong&gt;Markdown&lt;/strong&gt; te ayuda ya que
al tener una sintaxis sencilla y basica te sera mas facil escirbir y formatear
el texto. &lt;/p&gt;

&lt;p&gt;Hay que tener en cuenta que markdown no es un reemplazo de HTML y
muchas de las etiquetas existentes en HTML no estan disponibles para Markdown,
para estos casos lo que se debe hacer es simplemente usar la forma HTML.&lt;/p&gt;

&lt;h1 id=&quot;cabeceras&quot;&gt;Cabeceras:&lt;/h1&gt;

&lt;p&gt;Markdown soporta dos estilos de cabeceras, el estilo &lt;a href=&quot;http://docutils.sourceforge.net/mirror/setext.html&quot;&gt;Setex&lt;/a&gt;
y el estilo &lt;a href=&quot;http://www.aaronsw.com/2002/atx/&quot;&gt;Atx&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;estilo-atx&quot;&gt;Estilo Atx:&lt;/h3&gt;

&lt;p&gt;En HTML necesitarias escribir una cabecera con las etiquetas &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; y &lt;code&gt;&amp;lt;/h1&amp;gt;&lt;/code&gt; 
pero en markdown basta con solo escribir el simbolo &lt;code&gt;#&lt;/code&gt; para obtener una 
cabecera &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt;. Este estilo acepta los 6 niveles tal cual lo hace las etiquetas
&lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Teniendo esto en cuenta y para obtener algo como esto:&lt;/p&gt;

&lt;h1 id=&quot;texto-con-cabecera-h1&quot;&gt;Texto con cabecera h1&lt;/h1&gt;

&lt;h2 id=&quot;texto-con-cabecera-h2&quot;&gt;Texto con cabecera h2&lt;/h2&gt;

&lt;h3 id=&quot;text-con-cabecera-h3&quot;&gt;Text con cabecera h3&lt;/h3&gt;

&lt;p&gt;Necesitariamos escribir algo como esto: &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Texto con cabecera h1

## Texto con cabecera h2

### Text con cabecera h3
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;estilo-setex&quot;&gt;Estilo Setex:&lt;/h3&gt;

&lt;p&gt;Este estilo acepta unicamente dos niveles de la etiqueta &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Si quieres obtener algo como esto:&lt;/p&gt;

&lt;h1 id=&quot;texto-con-nivel-h1&quot;&gt;Texto con nivel h1&lt;/h1&gt;

&lt;h2 id=&quot;texto-con-estilo-h2&quot;&gt;Texto con estilo h2&lt;/h2&gt;

&lt;p&gt;Debes escribir algo como esto:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Texto con nivel h1
==================

Texto con estilo h2
-------------------
&lt;/code&gt;&lt;/pre&gt;

&lt;h1 id=&quot;parrafos&quot;&gt;Parrafos:&lt;/h1&gt;

&lt;p&gt;En HTML si quieres indicar que escribes un parrafo debes usar la etiqueta &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;
y &lt;code&gt;&amp;lt;/p&amp;gt;&lt;/code&gt;. Pero en Markdown no es necesario esto, de hecho no es necesario nada,
 simplemente escribes una lineas de texto continuas y sin espacio y markdown 
 tomara esta linea como un parrafo. Por ejemplo este parrafo explicativo se
 obtiene tan solo con escribir algo como esto:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;En HTML si quieres indicar que escribes un parrafo debes usar la etiqueta `&amp;lt;p&amp;gt;`
y `&amp;lt;/p&amp;gt;`. Pero en Markdown no es necesario esto, de hecho no es necesario nada,
 simplemente escribes una lineas de texto continuas y sin espacio y markdown 
 tomara esta linea como un parrafo. Por ejemplo este parrafo explicativo se
 obtiene tan solo con escribir algo como esto:
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;No tiene ningun misterio…&lt;/p&gt;

&lt;h1 id=&quot;citas&quot;&gt;Citas:&lt;/h1&gt;

&lt;p&gt;En HTML probablemente has escrito citas con las etiquetas &lt;code&gt;&amp;lt;blockquote&amp;gt;&lt;/code&gt;, pero
en Markdown es tan facil como colocar un &lt;code&gt;&amp;gt;&lt;/code&gt; al inicio del texto de la cita.&lt;/p&gt;

&lt;p&gt;Por ejemplo el extracto de Wikipedia que ves arriba es una &lt;strong&gt;cita&lt;/strong&gt; que se
obtubo escribiendo algo como esto:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; Markdown es un lenguaje de marcado ligero creado originalmente por John Gruber y Aaron Swartz que trata de conseguir la máxima legibilidad y &quot;publicabilidad&quot; tanto en sus forma de entrada como de salida, inspirándose en muchas convenciones existentes para marcar mensajes de correo electrónico usando texto plano. Markdown convierte el texto marcado en documentos XHTML bien formados, reemplazando el signo &#39;menor que&#39; (&#39;&amp;lt;&#39;) y los et por sus correspondientes referencias de entidad de caracteres. Markdown fue implementado originariamente en Perl por Gruber, pero desde entonces ha sido traducido a multitud de lenguajes de programación, incluyendo PHP, Python, Ruby, Java y Common Lisp. Se distribuye bajo licencia BSD y se distribuye como plugin (o al menos está disponible) en diferentes sistemas de gestión de contenidos (CMS).
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;cita-anidada&quot;&gt;Cita anidada:&lt;/h3&gt;

&lt;p&gt;Puedes anidar una cita dentro de otra como por ejemplo esta:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Una cita principal.&lt;/p&gt;

  &lt;blockquote&gt;
    &lt;p&gt;Una cita anidada.&lt;/p&gt;
  &lt;/blockquote&gt;

&lt;/blockquote&gt;

&lt;p&gt;La cual se lograria con algo como:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; Una cita principal.
&amp;gt;
&amp;gt; &amp;gt; Una cita anidada.
&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Tambien puedes formatear las citas agregandole elementos markdown dentro de
ellas.&lt;/p&gt;

&lt;h1 id=&quot;listas&quot;&gt;Listas:&lt;/h1&gt;

&lt;p&gt;En HTML tu creas una lista con etiquetas como &lt;code&gt;&amp;lt;ol&amp;gt;&lt;/code&gt; y &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt;.
Markdown soporta listas tanto ordenadas como no-ordenadas.&lt;/p&gt;

&lt;h3 id=&quot;listas-no-ordenadas&quot;&gt;Listas no-ordenadas:&lt;/h3&gt;

&lt;p&gt;Las listas no-ordenadas las puedes escribir con los simbolos &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt; o &lt;code&gt;*&lt;/code&gt;
como marcador de lista, por lo que si quieres hacer algo como esto:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;ArchLinux.&lt;/li&gt;
  &lt;li&gt;Ubuntu.&lt;/li&gt;
  &lt;li&gt;Debian.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Se usaria algo como esto:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;* ArchLinux.
* Ubuntu.
* Debian.

es igual a

- ArchLinux.
- Ubuntu.
- Debian.

y es igual a

+ ArchLinux.
+ Ubuntu.
+ Debian.
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;listas-ordenadas&quot;&gt;Listas ordenadas:&lt;/h3&gt;

&lt;p&gt;Las listas ordenadas las escribes simplemente con numeros seguidos de un punto.
Asi que si quieres crear algo como esto:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;ArchLinux.&lt;/li&gt;
  &lt;li&gt;Ubuntu.&lt;/li&gt;
  &lt;li&gt;Debian.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Escribiras algo como:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;1. ArchLinux.
2. Ubuntu.
3. Debian.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Un detalle a tener en cuenta es que el orden de los numeros que coloques para
marcar una lista ordenada no tiene efectos al ser convertido a HTML por lo que
si escribes algo como:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;1. ArchLinux.
1. Ubuntu.
1. Debian.

o escribes algo como

1. ArchLinux.
3. Ubuntu.
5. Debian.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;siempre obtendras una lista ordenada similar al ejemplo de arriba.&lt;/p&gt;

&lt;h1 id=&quot;bloques-de-codigo&quot;&gt;Bloques de codigo:&lt;/h1&gt;

&lt;p&gt;Puedes escribir codigo fuente con bloques de codigo pre-formateados, HTML hace
esto usando las etiquetas &lt;code&gt;&amp;lt;pre&amp;gt;&lt;/code&gt; y &lt;code&gt;&amp;lt;code&amp;gt;&lt;/code&gt;, pero en Markdown tu escribes
los bloques de codigo identando el mismo codigo con 4 espacios o un tab.&lt;/p&gt;

&lt;p&gt;Por ejemplo si queremos mostrar un bloque de codigo fuente como este:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def metodo_ruby
  puts &quot;Hola mundo&quot;
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Deberas escribir algo como esto:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line-numbers&quot;&gt;&lt;a href=&quot;#n1&quot; name=&quot;n1&quot;&gt;1&lt;/a&gt;&lt;/span&gt;    &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;metodo_ruby&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;&lt;a href=&quot;#n2&quot; name=&quot;n2&quot;&gt;2&lt;/a&gt;&lt;/span&gt;      puts &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;Hola mundo&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;&lt;a href=&quot;#n3&quot; name=&quot;n3&quot;&gt;3&lt;/a&gt;&lt;/span&gt;    &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Notese los 4 espacios antes de la palabra clave &lt;code&gt;def&lt;/code&gt; de la funcion los cuales 
van consecutivos hasta la palabra clave &lt;code&gt;end&lt;/code&gt; que cierra la funcion.&lt;/p&gt;

&lt;h1 id=&quot;reglas-horizontales&quot;&gt;Reglas horizontales:&lt;/h1&gt;

&lt;p&gt;En HTML tu crearias una linea o regla horizontal usando la etiqueta &lt;code&gt;&amp;lt;hr&amp;gt;&lt;/code&gt;,
pero en markdown las puedes hacer repitiendo los simbolos &lt;code&gt;*&lt;/code&gt; y &lt;code&gt;-&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Para conseguir las siguientes cuatros reglas (si, probale que no las veas bien):&lt;/p&gt;

&lt;hr /&gt;

&lt;hr /&gt;

&lt;hr /&gt;

&lt;hr /&gt;

&lt;hr /&gt;

&lt;p&gt;Necesitaras escribir algo como esto:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;* * *


***


*****


- - -


-----------------
&lt;/code&gt;&lt;/pre&gt;

&lt;h1 id=&quot;enlaces&quot;&gt;Enlaces:&lt;/h1&gt;

&lt;p&gt;En HTML los enlaces se escriben usando la etiquetas &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; pero en markdown
se hace tan solo con rodeando el texto del enlace con &lt;code&gt;[]&lt;/code&gt; y justo al lado 
colocas la url del enlace rodeada con &lt;code&gt;()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Por ejemplo el siguiente enlace:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://blog.jam.net.ve&quot;&gt;Jam Blog&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;lo logramos escribiendo algo como:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[Jam Blog](http://blog.jam.net.ve)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Tambien se puede agregar identificadores a los enlaces para luego agrupar estos
todos juntos en cualquier parte del documento, esto como una forma de tenerlos
ordenados para facil edicion.&lt;/p&gt;

&lt;p&gt;Por ejemplo los siguientes grupos de enlaces:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://ubuntu.com&quot; title=&quot;Linux para seres humanos.&quot;&gt;Ubuntu&lt;/a&gt;
&lt;a href=&quot;https://archlinux.org&quot;&gt;Arch Linux&lt;/a&gt;
&lt;a href=&quot;http://debian.org&quot;&gt;Debian&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Se obtienen escribiendo lo siguiente:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[Ubuntu][1]
[Arch Linux][2]
[Debian][3]

[1]: http://ubuntu.com &quot;Linux para seres humanos.&quot;
[2]: https://archlinux.org
[3]: http://debian.org
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Notese el texto opcional que se muestra al colocar el cursor sobre el enlace
de &lt;em&gt;Ubuntu.&lt;/em&gt;&lt;/p&gt;

&lt;h1 id=&quot;enfasis&quot;&gt;Enfasis:&lt;/h1&gt;

&lt;p&gt;En HTML si quieres hacer notar un texto negritas o haciendolo cursivo usas las 
etiquetas &lt;code&gt;&amp;lt;strong&amp;gt;&lt;/code&gt; y &lt;code&gt;&amp;lt;em&amp;gt;&lt;/code&gt; respectivamente, pero en markdown logras el mismo
efecto usando &lt;code&gt;*&lt;/code&gt; y &lt;code&gt;_&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Por ejemplo:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Pablito&lt;/em&gt; clavo un &lt;em&gt;clavito&lt;/em&gt; y el &lt;strong&gt;clavito&lt;/strong&gt; &lt;strong&gt;clavo&lt;/strong&gt; a Pablito.&lt;/p&gt;

&lt;p&gt;lo puedes lograr escribiendo:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;*Pablito* clavo un _clavito_ y el **clavito** __clavo__ a Pablito.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Como puedes notar se puede lograr el texto negrita usando solo un &lt;code&gt;_&lt;/code&gt; o un &lt;code&gt;*&lt;/code&gt; 
y el texto cursivo se puede lograr usando dos &lt;code&gt;**&lt;/code&gt; o dos &lt;code&gt;__&lt;/code&gt; al inicio y al 
final de la palabra.&lt;/p&gt;

&lt;h1 id=&quot;codigo-simple&quot;&gt;Codigo simple:&lt;/h1&gt;

&lt;p&gt;Ya habiamos visto como escribir &lt;strong&gt;bloques de codigo&lt;/strong&gt; mas arriba, pero esta vez
veremos como escribir codigo fuente de una sola linea.&lt;/p&gt;

&lt;p&gt;En HTML lo escribes usando la etiqueta &lt;code&gt;&amp;lt;code&amp;gt;&lt;/code&gt;, usando markdown se logra con
el &lt;code&gt;`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Por ejemplo:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;puts &quot;Hola Markdown&quot; if Markdown.include?&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`mosca`&lt;/code&gt; que el simbolo es &lt;code&gt;`&lt;/code&gt; y no &lt;code&gt;&#39;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Le hace escribiendo:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;`puts &quot;Hola Markdown&quot; if Markdown.include?`

`` `mosca` `` que el simbolo es `` ` `` y no `&#39;`.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Notese que si se quiere incluir un texto con que contiene el mismo simbolo &lt;code&gt;`&lt;/code&gt;
debes rodear el contenido con un doble &lt;code&gt;`&lt;/code&gt;&lt;/p&gt;

&lt;h1 id=&quot;imagenes&quot;&gt;Imagenes:&lt;/h1&gt;

&lt;p&gt;En HTML agregas imagenes al documento usando la etiqueta &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;, con markdown
se hace de una forma muy similar a como se hacen con los enlaces, con la unica
diferencia de que se usa un simbolo &lt;code&gt;!&lt;/code&gt; al inicio de los &lt;code&gt;[]&lt;/code&gt; y en los &lt;code&gt;()&lt;/code&gt; se
coloca la ruta de la imagen.&lt;/p&gt;

&lt;p&gt;Por ejemplo:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/Mz0i3G8.png&quot; alt=&quot;Markdown&quot; title=&quot;Logo Markdown&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Se puede lograr escribiendo:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;![Markdown](https://i.imgur.com/Mz0i3G8.png &quot;Logo Markdown&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Notese que a pesar de que se puede colocar el texto &lt;code&gt;alt&lt;/code&gt; y el &lt;code&gt;title&lt;/code&gt;
existentes en la etiqueta &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; HTML, no podemos controlar la dimension de la
imagen ni la posicion. Asi que asegurate de que la imagen ya este en las 
dimensiones deseadas o usa solo la etiqueta HTML &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; y codigo CSS.&lt;/p&gt;

&lt;p&gt;De la misma forma que hicimos con los enlaces, podemos agrupar imagenes
con un identificador.&lt;/p&gt;

&lt;h1 id=&quot;miselaneos&quot;&gt;Miselaneos:&lt;/h1&gt;

&lt;h3 id=&quot;enlaces-automaticos&quot;&gt;Enlaces automaticos:&lt;/h3&gt;

&lt;p&gt;Cuando vimos como formatear enlaces en Markdown lo hicimos con algo como
&lt;code&gt;[texto enlace](http://url.tld)&lt;/code&gt;, pero markdown de hecho tiene una forma
simple de convertir una url escrita en un enlace basico:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://blog.jam.net.ve&quot;&gt;http://blog.jam.net.ve&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;&amp;#109;&amp;#097;&amp;#105;&amp;#108;&amp;#116;&amp;#111;:&amp;#099;&amp;#111;&amp;#114;&amp;#114;&amp;#101;&amp;#111;&amp;#064;&amp;#100;&amp;#111;&amp;#109;&amp;#105;&amp;#110;&amp;#105;&amp;#111;&amp;#046;&amp;#116;&amp;#108;&amp;#100;&quot;&gt;&amp;#099;&amp;#111;&amp;#114;&amp;#114;&amp;#101;&amp;#111;&amp;#064;&amp;#100;&amp;#111;&amp;#109;&amp;#105;&amp;#110;&amp;#105;&amp;#111;&amp;#046;&amp;#116;&amp;#108;&amp;#100;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Se logra simplemente escribiendo:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;http://blog.jam.net.ve&amp;gt;

&amp;lt;correo@dominio.tld&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;quiebre-de-linea&quot;&gt;Quiebre de linea:&lt;/h3&gt;

&lt;p&gt;Si por ejemplo quieres escribir una linea&lt;br /&gt;
y romperla en un punto especifico tan solo&lt;br /&gt;
debes agregar dos o masespacios en el  punto&lt;br /&gt;
donde quieres que se haga el salto de linea.&lt;/p&gt;

&lt;p&gt;Como puedes notar el parrafo explicativo de arriba no es tan largo, pues se
incluyo en el el quiebre de linea el cual se obtubo escribiendo:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Si por ejemplo quieres escribir una linea  
y romperla en un punto especifico tan solo  
debes agregar dos espacios en el  punto donde  
quieres que se haga el salto de linea.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Notese los dos espacios al final de cada linea para marcar el quiebre o salto.&lt;/p&gt;

&lt;h3 id=&quot;escape&quot;&gt;Escape:&lt;/h3&gt;

&lt;p&gt;Markdown nos da una forma para escribir simbolos que el mismo usa en su sintaxis
como por ejemplo el &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;_&lt;/code&gt;, etc.&lt;/p&gt;

&lt;p&gt;*Texto rodeado con &lt;code&gt;*&lt;/code&gt;*&lt;/p&gt;

&lt;p&gt;_Texto rodeado con &lt;code&gt;_&lt;/code&gt;_&lt;/p&gt;

&lt;p&gt;Esto se logra escribiendo:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;\*Texto rodeado con `*`\*

\_Texto rodeado con `_`\_
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Tambien hay caracteres de escape para los siguientes simbolos:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;\   backslash
`   backtick
*   asterisk
_   underscore
{}  curly braces
[]  square brackets
()  parentheses
#   hash mark
+   plus sign
-   minus sign (hyphen)
.   dot
!   exclamation mark
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Como ven, markdown es sumamente sencillo y basico con una sintaxis facil de
escribir. Existen algunas reglas especificas para cada algunos elementos que no
se describen aqui, si deseas  puedes visitar la &lt;a href=&quot;http://daringfireball.net/projects/markdown/syntax&quot;&gt;referencia oficial&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Creando imagenes Docker desde archivos dockerfile</title>
   <link href="http://blog.jam.net.ve/2014/07/07/creando-imagenes-docker-usando-dockerfile"/>
   <updated>2014-07-07T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2014/07/07/creando-imagenes-docker-usando-dockerfile</id>
   <content type="html">&lt;p&gt;Hace algunos meses atras escribi un articulo en el que comentaba que era la
herramienta &lt;a href=&quot;http://docker.io&quot;&gt;Docker&lt;/a&gt;  y &lt;a href=&quot;http://blog.jam.net.ve/2014/03/01/instalando-docker-archlinux&quot;&gt;Como instalar Docker&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;En &lt;strong&gt;Docker&lt;/strong&gt; existe un archivo llamado &lt;code&gt;dockerfile&lt;/code&gt; el cual es una especie de
receta que interpreta Docker y que crea a partir de ella una &lt;strong&gt;Imagen Docker&lt;/strong&gt;
desde la cual y con un simple comando podremos nosotros crear un contenedor
Docker para alvergar alli nuestras aplicaciones o servicios.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;En esta oportunidad mostrare un ejemplo sumamente sencillo de como se podria
construir una imagen docker adaptada a nuestras necesidades especificas.
En este caso creare una imagen basada en Ubuntu 14.04 LTS la cual se le
instalaran una serie de paquetes basicos y se le le realizara la configuracion
de el servidor OpenSSH para asi poder conectarnos a el contenedor de manera
remota.&lt;/p&gt;

&lt;h2 id=&quot;el-archivo-dockerfile&quot;&gt;El archivo dockerfile&lt;/h2&gt;

&lt;p&gt;Vamos a crear un archivo llamado &lt;code&gt;dockerfile&lt;/code&gt; el cual va a contener lo siguiente:&lt;/p&gt;

&lt;p&gt;Nota: Este dockerfile esta disponible en mi &lt;a href=&quot;https://github.com/jesusangelm/dockerfile&quot;&gt;Repositorio Github&lt;/a&gt;
para una mejor lectura y seguimiento del articulo.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#Imagen docker de prueba.&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#Origen: Ubuntu 14.04 LTS&lt;/span&gt;
FROM ubuntu:14.04

&lt;span class=&quot;c&quot;&gt;#Creador:&lt;/span&gt;
MAINTAINER Jesus Marin &amp;lt;jam@jam.net.ve&amp;gt;

&lt;span class=&quot;c&quot;&gt;#Actualizar el repositorio Ubuntu, luego descarga e instala paquetes que&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#requieren actualizacion.&lt;/span&gt;
RUN apt-get -qq update &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get -qqy upgrade

&lt;span class=&quot;c&quot;&gt;#Instalar algunos paquetes bases, utiles para mi y algunas dependencias.&lt;/span&gt;
RUN apt-get -qqy install wget git curl dnsutils tmux zsh openssh-server pwgen vim

&lt;span class=&quot;c&quot;&gt;#Tomado de https://github.com/tutumcloud/tutum-ubuntu/blob/master/Dockerfile&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#Para configurar SSHD y crear una contrasena para usuario ROOT&lt;/span&gt;
RUN mkdir -p /var/run/sshd &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; sed -i &lt;span class=&quot;s2&quot;&gt;&amp;quot;s/UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g&amp;quot;&lt;/span&gt; /etc/ssh/sshd_config &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; sed -i &lt;span class=&quot;s2&quot;&gt;&amp;quot;s/UsePAM.*/UsePAM no/g&amp;quot;&lt;/span&gt; /etc/ssh/sshd_config &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; sed -i &lt;span class=&quot;s2&quot;&gt;&amp;quot;s/PermitRootLogin.*/PermitRootLogin yes/g&amp;quot;&lt;/span&gt; /etc/ssh/sshd_config
ADD set_root_pw.sh /set_root_pw.sh
ADD run.sh /run.sh
RUN chmod +x /*.sh

EXPOSE 22
CMD &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;/run.sh&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id=&quot;un-dockerfile-por-dentro&quot;&gt;Un dockerfile por dentro.&lt;/h2&gt;

&lt;p&gt;Notese que el archivo esta compuesto principalmente por conjuntos de 
&lt;code&gt;INSTRUCCION&lt;/code&gt; en mayusculas segido de una &lt;code&gt;sentencia&lt;/code&gt; en minuscula.&lt;/p&gt;

&lt;p&gt;El texto que esta despues de un &lt;code&gt;#&lt;/code&gt; es simplemente un comentario.&lt;/p&gt;

&lt;h2 id=&quot;la-instruccion-from&quot;&gt;La instruccion FROM.&lt;/h2&gt;

&lt;p&gt;En la primeras lineas podemos ver la palabra &lt;code&gt;FROM&lt;/code&gt;, esta nos indica que
&lt;strong&gt;Imagen Base&lt;/strong&gt; vamos a tomar para crear nuestra imagen personalizada, en este
caso usamos &lt;code&gt;ubuntu:14.04&lt;/code&gt;. Docker toma esta imagen desde el &lt;strong&gt;&lt;a href=&quot;https://registry.hub.docker.com/&quot;&gt;Docker Registry&lt;/a&gt;&lt;/strong&gt; el cual contiene nuestra imagen
base &lt;strong&gt;&lt;a href=&quot;https://registry.hub.docker.com/_/ubuntu/&quot;&gt;Ubuntu 14.04 LTS&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Notese que despues del nombre de la imagen indicamos la version de Ubuntu a
usar, bueno esto en Docker se llama &lt;code&gt;TAG&lt;/code&gt; y es la forma en que podemos usar una
version especifica de esa imagen, si vemos las &lt;strong&gt;tags&lt;/strong&gt; disponibles de dicha
imagen en su repositorio podemos ver que tambien disponemos de otras versiones
de Ubuntu como la &lt;code&gt;13.10&lt;/code&gt; o la &lt;code&gt;12.04&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Si por ejemplo no queremos usar como imagen base a Ubuntu sino que queremos
crear una imagen Debian o CentOS podriamos decir:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;FROM debian:stable&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;FROM centos:6.4&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id=&quot;la-instruccion-maintainer&quot;&gt;La instruccion MAINTAINER&lt;/h2&gt;

&lt;p&gt;Esta instruccion no tiene mucha ciencia, tan solo especificamos quien es el
autor de dicho dockerfile y su correo.&lt;/p&gt;

&lt;h2 id=&quot;la-instruccion-run&quot;&gt;La instruccion RUN&lt;/h2&gt;

&lt;p&gt;Esta instruccion la veras en casi cualquier dockerfile ya que con ella
especificas los comandos que quieras ejecutar. En este caso indicamos que
se ejecutara el comando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;apt-get -qq update &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get -qqy upgrade&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;El cual ejecuta a &lt;code&gt;apt-get&lt;/code&gt; para que actualice el listado de repositorios e
inmediatamente actualice los paquetes que dispongan de actualizacion.&lt;/p&gt;

&lt;p&gt;Mas abajo puedes ver que se ejecuta nuevamente &lt;code&gt;apt-get&lt;/code&gt; pero esta vez para 
instalar algunos paquetes basicos que no estan en la imagen base y que podrias
requerir para tu imagen personalizada.&lt;/p&gt;

&lt;p&gt;Tambien puedes ver que ejecuta una serie de comandos concatenados que crean
carpetas en ciertas ubicaciones de la imagen base y realiza configuraciones en
archivos. En esta parte se realiza una configuracion de el servidor OpenSSH.&lt;/p&gt;

&lt;h2 id=&quot;la-instruccion-add&quot;&gt;La instruccion ADD&lt;/h2&gt;

&lt;p&gt;Con esta instruccion podemos hacer que se agrege a la imagen base un archivo que
nosotros queremos que contenga, indicando la ubicacion actual de dicho archivo
en nuestro sistema y la ubicacion donde dentro de la imagen donde queremos que
se aloje dicho archivo.&lt;/p&gt;

&lt;p&gt;En este caso &lt;code&gt;set_root_pw.sh&lt;/code&gt; es el archivo a agregar, no especificamos una ruta
ya que el archivo esta en la misma carpeta en la que esta el archivo dockerfile.
Esta instruccion es seguida de &lt;code&gt;/set_root_pw.sh&lt;/code&gt; notese el &lt;code&gt;/&lt;/code&gt; delante del 
nombre del archivo, aqui si estamos especificando una ruta y es la ruta de
destino dentro de la imagen en donde ubicaremos dicho archivo a agregar.&lt;/p&gt;

&lt;h2 id=&quot;la-instruccion-expose&quot;&gt;La instruccion EXPOSE&lt;/h2&gt;

&lt;p&gt;Con esta instruccion le decimos a Docker que los contenedores de esta imagen
escucharan en el puerto especificado una vez que dichos contenedores se esten
ejecutando. Docker tambien puede usar esta informacion para interconectar 
contenedores usando enlaces.&lt;/p&gt;

&lt;p&gt;En nuestro caso exponemos el puerto &lt;code&gt;22&lt;/code&gt; ya que usaremos un servidor OpenSSH
para poder conectarnos al contenedor via SSH. Si por ejemplo estubiesemos
creando un contenedor que alberga un servidor Web como por ejemplo Nginx o
Apache, necesitariamos exponer su puerto de eschucha el cual es tipicamente el
puerto &lt;code&gt;80&lt;/code&gt;, lo mismo va si queremos usar cualquier otro servicio.&lt;/p&gt;

&lt;h2 id=&quot;la-instruccion-cmd&quot;&gt;La instruccion CMD&lt;/h2&gt;

&lt;p&gt;Esta instruccion es un tanto similar a la instruccion &lt;code&gt;RUN&lt;/code&gt; solo que &lt;code&gt;CMD&lt;/code&gt; ejecuta
el comando indicado unicamente cuando arranque el contenedor y no cuando se
este construyendo el mismo, esto puede servirnos para ejecutar servicios que ya
esten instalados o para correr archivos ejecutables espeficicando su ubicacion.&lt;/p&gt;

&lt;p&gt;Esta instruccion tiene la limitante de que solo se puede colocar una sola vez 
en un archivo dockerfile.&lt;/p&gt;

&lt;p&gt;En nuestro caso tan solo arrancamos el ejecutable &lt;code&gt;run.sh&lt;/code&gt; que ya hemos agregado
en la raiz de la imagen base.&lt;/p&gt;

&lt;p&gt;Por supuesto estas no son todas las instrucciones, existen algunas otras mas 
en la &lt;a href=&quot;https://docs.docker.com/reference/builder&quot;&gt;Dockerfile Reference&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;construyendo-la-imagen&quot;&gt;Construyendo la imagen&lt;/h2&gt;

&lt;p&gt;Una vez tenemos nuestro archivo dockerfile nos vamos a una terminal, nos
ubicamos en el mismo directorio donde reside nuestro dockerfile y ejecutamos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;docker build -t&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;usuariodocker/ubuntu:14.04&amp;quot;&lt;/span&gt; .&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Docker tiene como convencion que el nombre del repositorio contenga el nombre 
de la persona u organizacion que crea la imagen seguido de una &lt;code&gt;/&lt;/code&gt; y luego el
nombre de la imagen y como opcional un &lt;code&gt;tag&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Notese tambien el &lt;code&gt;.&lt;/code&gt; al final, con esto indicamos que la ubicacion del archivo
dockerfile esta en el directorio actual.&lt;/p&gt;

&lt;p&gt;Cuando ejecutes el comando veras todo el proceso de construccion de la imagen
separando cada instruccion colocada en el dockerfile como un &lt;code&gt;step&lt;/code&gt; o paso
numerado. El proceso puede tomar algunos minutos ya que consistira en la
descarga de la imagen base desde internet y tambien de la actualizacion de 
repositorios y paquetes.&lt;/p&gt;

&lt;h2 id=&quot;creando-contenedores-en-el-fondo-a-partir-de-nuestra-imagen-personalizada&quot;&gt;Creando contenedores en el fondo a partir de nuestra imagen personalizada&lt;/h2&gt;

&lt;p&gt;Debido a que este contenedor esta creado con servicios, necesitaremos ejecutarlo
en el fondo o como un &lt;code&gt;daemon&lt;/code&gt; para que de este modo pueda ejecutarse el
servicio o los servicios que pueda contener. Para esto ejecutamos en una
terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;docker run -d -P usuariodocker/ubuntu:14.04&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Este comando nos mostrara una secuencia de numeros y letras  el cual es el &lt;code&gt;ID&lt;/code&gt;
del contenedor.&lt;/p&gt;

&lt;p&gt;El flag &lt;code&gt;-d&lt;/code&gt; hace que el contenedor se ejecute en el fondo y el flag &lt;code&gt;-P&lt;/code&gt;
le dice a Docker que mapee los puertos que el contenedor este exponiendo, hacia
el S.O huesped, en nuestro caso el contenedor expone el puerto &lt;code&gt;22&lt;/code&gt; pero Docker
mapea este el acceso a este puerto a travez de nuestro S.O usando un puerto
distinto, como por ejemplo el &lt;code&gt;49153&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Para saber que puerto esta mapeando docker hacia el exterior tan solo teclea 
el comando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;docker ps -a&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;El cual te devolvera algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;CONTAINER ID        IMAGE                      COMMAND             CREATED             STATUS              PORTS                   NAMES
c3032b4c1033        usuariodocker/ubuntu:14.04   /run.sh           &lt;span class=&quot;m&quot;&gt;55&lt;/span&gt; seconds ago       Up &lt;span class=&quot;m&quot;&gt;50&lt;/span&gt; seconds        0.0.0.0:49153-&amp;gt;22/tcp   goofy_archimedes&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;en la columna &lt;code&gt;port&lt;/code&gt; puedes ver el puerto expuesto por el contenedor y el puerto
que docker mapea para que podamos acceder a el. Tambien puedes ver el ID del 
contenedor el cual podemos usar para obtener la clave de usuario root que el
archivo ejecutable &lt;code&gt;set_root_pw.sh&lt;/code&gt; configuro.&lt;/p&gt;

&lt;p&gt;Para ver esta clave ejecutamos en una terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;docker logs c3032b4c1033&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y podras ver algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&amp;gt; Setting a random password to the root &lt;span class=&quot;nv&quot;&gt;user&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&amp;gt; Done!
&lt;span class=&quot;o&quot;&gt;========================================================================&lt;/span&gt;
You can now connect to this Ubuntu container via SSH using:

 ssh -p &amp;lt;port&amp;gt; root@&amp;lt;host&amp;gt;
and enter the root password &lt;span class=&quot;s1&quot;&gt;&amp;#39;S3cR3Tp4SS&amp;#39;&lt;/span&gt; when prompted

Please remember to change the above password as soon as possible!
&lt;span class=&quot;o&quot;&gt;========================================================================&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id=&quot;conectandonos-al-contenedor-mediante-ssh&quot;&gt;Conectandonos al contenedor mediante SSH&lt;/h2&gt;

&lt;p&gt;Habiamos dicho que este contenedor personalizado contenia un servicio SSH para
poder acceder a el remotamente como si se tratase de un servidor dedicado o VPS,
ya sabemos que el contenedor expone el puerto &lt;code&gt;22&lt;/code&gt; perteneciente al servicio OpenSSH
y que Docker mapea este puerto al exterior usando &lt;strong&gt;en este caso&lt;/strong&gt; el puerto
&lt;code&gt;49153&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Bien para poder conectarnos por ssh tan solo ejecutamos en una terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;ssh -p 49153 root@localhost&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;usando la clave root que vimos arriba.&lt;/p&gt;

&lt;p&gt;Con vez, no es nada del otro mundo y con solo unos pocos pasos podemos crear
imagenes docker adaptadas a nuestras necesidades, de las cuales podemos crear 
contenedores portatiles para alojar nuestras aplicaciones, servicios o un entorno de
desarrollo y todo esto aislado de nuestro sistema operativo.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Instalando chruby y ruby-install</title>
   <link href="http://blog.jam.net.ve/2014/04/19/instalando-chruby"/>
   <updated>2014-04-19T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2014/04/19/instalando-chruby</id>
   <content type="html">&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/postmodern/chruby&quot;&gt;chruby&lt;/a&gt;&lt;/strong&gt; es un administrador de versiones Ruby tal como RVM o rbenv pero que a
diferencia de estos dos ultimos, lleva la simplicidad al extremo ya que esa 
es basicamente su unica funcion, esto tambien le da la ventaja de ser uno de
los administradores de versiones Ruby mas ligero con cerca de &lt;a href=&quot;https://github.com/postmodern/chruby/blob/master/share/chruby/chruby.sh&quot;&gt;99 Lineas de codigo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;La principal diferencia de &lt;strong&gt;chruby&lt;/strong&gt; con respecto a &lt;strong&gt;rvm&lt;/strong&gt; es su sencillez
debido a que no esta plagado de caracteristicas que probablemente no uses o que
en realidad no necesitas. Su principal diferencia con respecto a &lt;strong&gt;rbenv&lt;/strong&gt; es
que no usa los fulanos &lt;code&gt;shims&lt;/code&gt; los cuales en mi opinion y experiencia hacian que
los comandos ruby se ejecutaran con lentitud teniendo por ejemplo retrasos de
hasta 1 segundo para que respondiera un simple &lt;code&gt;ruby -v&lt;/code&gt;.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Entre sus caracteristicas esta:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Actualiza la Variable de Entorno &lt;code&gt;$PATH&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Agrega tambien los directorios RubyGems &lt;code&gt;bin/&lt;/code&gt; a &lt;code&gt;$PATH&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Configura correctamente &lt;code&gt;$GEM_HOME&lt;/code&gt; y &lt;code&gt;$GEM_PATH&lt;/code&gt;.
    &lt;ul&gt;
      &lt;li&gt;lo que hace que para los usuarios las gemas se instalen en &lt;code&gt;~/.gem/$ruby/$version&lt;/code&gt;.&lt;/li&gt;
      &lt;li&gt;y para el usuario root las gemas se instalen en &lt;code&gt;/path/to/$ruby/$gemdir&lt;/code&gt;.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Tambien configura las Variables de Entorno &lt;code&gt;$RUBY_ROOT&lt;/code&gt;, &lt;code&gt;$RUBY_ENGINE&lt;/code&gt;, &lt;code&gt;$RUBY_VERSION&lt;/code&gt; y &lt;code&gt;$GEM_ROOT&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Opcionalmente puede configurar &lt;code&gt;$RUBYOPT&lt;/code&gt; si se le da el argumento especifico.&lt;/li&gt;
  &lt;li&gt;Llama a &lt;code&gt;hash -r&lt;/code&gt; para limpiar el command-lookup hash-table.&lt;/li&gt;
  &lt;li&gt;Por defecto usa la version ruby del sistema.&lt;/li&gt;
  &lt;li&gt;Soporte opcional del cambiado automatico de rubies por medio del archivo &lt;code&gt;.ruby-version&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Soporte para bash y zsh.&lt;/li&gt;
  &lt;li&gt;Ligero (~99 LOC).&lt;/li&gt;
  &lt;li&gt;incluye tests.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;instalacion&quot;&gt;Instalacion:&lt;/h2&gt;

&lt;p&gt;La documentacion oficial de chruby te explica este paso pidiendote que
descargues la ultima version contenida en un archivo comprimido, pero yo
prefiero usar &lt;strong&gt;Git&lt;/strong&gt;, listar los Tags de sus versiones y elegir la ultima
version para luego compilar desde alli, esto me permite estar al tanto de las
ultimas versiones con tan solo un &lt;code&gt;git pull&lt;/code&gt; en vez de estar revisando la pagina
y descargar archivos comprimidos.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#clonamos el repositorio&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git clone https://github.com/postmodern/chruby.git

&lt;span class=&quot;c&quot;&gt;#revisamos las versiones disponibles&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git tag

&lt;span class=&quot;c&quot;&gt;#elegimos la ultima version disponible hasta ahora&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git checkout v0.3.8

&lt;span class=&quot;c&quot;&gt;#instalamos&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo make install&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id=&quot;configuracion&quot;&gt;Configuracion:&lt;/h2&gt;

&lt;p&gt;Luego de instalar &lt;strong&gt;chruby&lt;/strong&gt; tan solo debemos modificar nuestro archivo de
configuracion &lt;code&gt;.bashrc&lt;/code&gt; o &lt;code&gt;.zshrc&lt;/code&gt; segun sea el caso y agregar la siguiente 
linea.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt; /usr/local/share/chruby/chruby.sh&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ya con esto tenemos instalado y configurado chruby, pero debido a que chruby se
enfoca en ser lo mas simple y minimalista no podremos hacer nada con el sin
tener instalado alguna version de ruby. De hecho si escribes el comando &lt;code&gt;chruby&lt;/code&gt;
en la terminal, este no te mostrara informacion alguna.&lt;/p&gt;

&lt;p&gt;Es aqui donde entra &lt;strong&gt;&lt;a href=&quot;https://github.com/postmodern/ruby-install&quot;&gt;ruby-install&lt;/a&gt;&lt;/strong&gt;. el cual es una aplicacion hecha por el
mismo creador de chruby la cual nos permite instalar cualquier version de ruby
que quieras, algo asi como el &lt;strong&gt;ruby-build&lt;/strong&gt; de &lt;strong&gt;rbenv&lt;/strong&gt; pero con
caracteristicas extras interesantes como resolucion de dependencias requeridas
para compilar las distintas versiones de ruby disponibles.&lt;/p&gt;

&lt;p&gt;Para instalar ruby-install hacemos lo mismos pasos que hicimos para instalar
chruby:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#clonamos el repositorio&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git clone https://github.com/postmodern/ruby-install.git

&lt;span class=&quot;c&quot;&gt;#revisamos las versiones disponibles&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git tag

&lt;span class=&quot;c&quot;&gt;#elegimos la ultima version disponible hasta ahora&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git checkout v0.4.2

&lt;span class=&quot;c&quot;&gt;#instalamos&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo make install&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Con esto tenemos instalado y listo para usar &lt;strong&gt;ruby-install&lt;/strong&gt; por lo que modemos
probarla junto con &lt;strong&gt;chruby&lt;/strong&gt; instalando alguna version de Ruby.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ruby-install ruby 2.1&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Con esto comenzara la descarga, compilacion e instalacion de Ruby.&lt;/p&gt;

&lt;p&gt;Si ejecutas &lt;code&gt;ruby-install&lt;/code&gt; sin ningun parametro podras ver el listado de rubies
disponibles:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ruby-install 
Known ruby versions:
  ruby:
    1:      1.9.3-p545
    1.9:    1.9.3-p545
    1.9.3:  1.9.3-p545
    2.0:    2.0.0-p451
    2.0.0:  2.0.0-p451
    2:      2.1.1
    2.1:    2.1.1
    stable: 2.1.1
  jruby:
    1.7:    1.7.12
    stable: 1.7.12
  rbx:
    2.1:    2.1.1
    2.2:    2.2.6
    stable: 2.2.6
  maglev:
    1.0:    1.0.0
    1.1:    1.1RC1
    stable: 1.0.0
  mruby:
    1.0:    1.0.0
    stable: 1.0.0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Para decirle a &lt;strong&gt;chruby&lt;/strong&gt; que use alguna version de ruby en especifico es tan
simple como un:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;chruby ruby-2.1.1&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;chruby no cambia las versiones ruby por defecto y de hecho si reinicias la
terminal o la pc, no recuerda la version de ruby que acabas de perdirle que use,
por lo que si quieres que mantenga usando por defecto una version en especifica
puedes colocar en tu &lt;code&gt;.bashrc&lt;/code&gt; o &lt;code&gt;.zshrc&lt;/code&gt; ese mismo comando que usamos arriba.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Instalando Docker en ArchLinux</title>
   <link href="http://blog.jam.net.ve/2014/03/01/instalando-docker-archlinux"/>
   <updated>2014-03-01T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2014/03/01/instalando-docker-archlinux</id>
   <content type="html">&lt;p&gt;Cuando se esta desarrollando una aplicacion y llega el momento de implementarla
en produccion siempre se busca que este proceso sea lo mas sencillo, rapido y
confiable tanto como sea posible, hoy en dia existe varias herramientas que nos
facilitan el trabajo como por ejemplo las PaaS como Heroku que no permiten por
ejemplo colocar nuestra aplicaciones Rails y tenerla funcionando en pocos
minutos, o las IaaS como las AWS de Amazon que nos permiten crear instancias de
VM para colocar alli nuestras aplicaciones y sus dependencias, u otras
herramientas un tanto mas sencillas como Chef. En esta ocasion hablaremos de una
nueva herramienta conocida como &lt;a href=&quot;https://www.docker.io/&quot;&gt;Docker&lt;/a&gt; que nos puede ayudar igualmente pero de
la forma mas sencilla posible.&lt;/p&gt;

&lt;center&gt;&lt;img src=&quot;https://i.imgur.com/JVyF5bi.png&quot; title=&quot;Hosted by imgur.com&quot; /&gt;&lt;/center&gt;

&lt;!-- more --&gt;

&lt;h1 id=&quot;docker&quot;&gt;Docker.&lt;/h1&gt;

&lt;p&gt;Docker es una herramienta de codigo abierto que nos permite automatizar el
despliegue de cualquier aplicacion en un contenedor ligero, portatil,
autosuficiente y que se pueda ejecutar practicamente en cualquier lugar.&lt;/p&gt;

&lt;p&gt;Los contenedores de Docker pueden encapsular cualquier carga que se ejecutaran
consistentemente en practicamente cualquier servidor. El mismo contenedor en el
que se desarrolla, contruye y prueba la aplicacion puede correr a escala en un
servidor en produccion, en una maquina virtual, en un cluster, en OpenStack, en
una instancia publica o en cualquier combinacion de estas mismas.&lt;/p&gt;

&lt;p&gt;Los usos comunes de Docker pueden ser:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Automatizacion de el empaquetado y despliegue de aplicaciones.&lt;/li&gt;
  &lt;li&gt;Creacion de entornos PaaS ligeros y privados.&lt;/li&gt;
  &lt;li&gt;Pruebas a automatizadas y de integracion continua.&lt;/li&gt;
  &lt;li&gt;Implementar y escalar aplicaiones web, Bases de datos y servicios backend.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;En una forma simple se podria pensar que Docker funciona como una herramienta
como &lt;strong&gt;VirtualBox&lt;/strong&gt; junto a &lt;strong&gt;Vagrant&lt;/strong&gt;, pero los contenedores Docker no son &lt;strong&gt;Maquinas
Virtuales (VM)&lt;/strong&gt; ya que estos no reservan espacio en memoria o procesos, ademas los
contenedores en Docker y su contenido se ejecutan mucho mas rapido que en una
VM, y son mucho mas ligeros. Muchos dicen que Docker es como un &lt;strong&gt;chroot&lt;/strong&gt; con
esteroides. &lt;/p&gt;

&lt;h1 id=&quot;instalacion&quot;&gt;Instalacion:&lt;/h1&gt;

&lt;p&gt;En &lt;strong&gt;ArchLinux&lt;/strong&gt; el proceso es muy sencillo ya que se cuenta con el respectivo
paquete en los repositorios, tambien puede ser instalado desde AUR. en este caso
optare por instalar Docker desde el repositorio ArchLinux.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo pacman -S docker&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1 id=&quot;configuracion-y-ejecucion&quot;&gt;Configuracion y ejecucion:&lt;/h1&gt;

&lt;p&gt;Para usar Docker sin ser root tan solo debemos agregar nuestro usuario al grupo
&lt;strong&gt;docker&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo gpasswd -a USUARIO docker&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;NOTA: Cambie &lt;strong&gt;USUARIO&lt;/strong&gt; por el usuario que quiera usar.&lt;/p&gt;

&lt;p&gt;Luego tan solo habilitamos sus servicio y lo ejecutamos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo systemctl &lt;span class=&quot;nb&quot;&gt;enable &lt;/span&gt;docker
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo systemctl start docker&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1 id=&quot;pruebas&quot;&gt;Pruebas:&lt;/h1&gt;

&lt;p&gt;Para ver una lista de comandos disponible podemos simplemente ejecutar &lt;code&gt;docker&lt;/code&gt;
en la terminal. Tambien podemos ejecutar el comando &lt;code&gt;docker info&lt;/code&gt; y veremos algo
como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker info
Containers: 5
Images: 4
Driver: devicemapper
 Pool Name: docker-8:17-1706253-pool
 Data file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
 Data Space Used: 305.1 Mb
 Data Space Total: 102400.0 Mb
 Metadata Space Used: 1.0 Mb
 Metadata Space Total: 2048.0 Mb
Username: jesusangelm
Registry: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;https://index.docker.io/v1/&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
WARNING: No swap limit support&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ahora que vemos que funciona todo correctamente podemos descargar una &lt;strong&gt;imagen
base&lt;/strong&gt; pre-construida para Docker, las imagenes de Docker son sistemas que
usaran los contenedores como base para correr nuestras aplicaciones. Estas
imagenes son Sistemas Operativos como Ubuntu, Fedora, ArchLinux, etc y en el
&lt;a href=&quot;https://index.docker.io/&quot;&gt;Docker Index&lt;/a&gt; puedes encontrar un listado de imagenes
disponibles para descargar o tambien puedes subir y comparti una imagen creada
por ti.&lt;/p&gt;

&lt;p&gt;En este caso usare la imagen de &lt;a href=&quot;https://index.docker.io/_/busybox/&quot;&gt;BusyBox&lt;/a&gt;,
para esto tan solo ejecutamos en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker pull busybox&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Una vez descargada la imagen podemos meternos en su terminal y comenzar a
trabajar en ella:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker run -i -t busybox:latest sh&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Con esto entraremos en su entorno como si de un &lt;strong&gt;chroot&lt;/strong&gt; se tratase, para
salir tan solo ejecuta el comando &lt;code&gt;exit&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Con todo esto podremos tener instalado y funcionando Docker para comenzar a
usarlo, crear nuestros entornos de desarrollo o crear contenedores con
aplicaciones que puedan ser implementada en produccion muy rapido y sin
problemas. Este tutorial es una explicacion muy basica para el sin fin de
usos que podemos darle a Docker, recomiendo leer la &lt;a href=&quot;https://www.docker.io/gettingstarted/&quot;&gt;Tutorial Interactivo&lt;/a&gt; y la &lt;a href=&quot;http://docs.docker.io/&quot;&gt;Documentacion&lt;/a&gt; de Docker para conocerlo en mas detalles.&lt;/p&gt;

&lt;p&gt;Un ejemplo de uso puede ser por ejemplo crear un contenedor Docker en el cual se
desarrolla y alberga una aplicacion Rails y otro contenedor que ejecute un 
servicio PostgreSQL, para luego interconectar estos dos contenedores y hacer que
nuestra aplicacion Rails pueda conectarse y usar la Base de datos Postgresql en
el segundo contenedor. Logicamente podrias colocar estos dos contenedores ne un
servidor de produccion y se ejecutaran se inmediato y sin problemas tal cual
estubiesen en entorno de desarrollo, Ejemplos como estos son los que hacen
interesante el uso de Docker.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>DNSCrypt + DNSMasq en ArchLinux - Encripta tus peticiones DNS y saltate cualquier restrincion de tu ISP.</title>
   <link href="http://blog.jam.net.ve/2014/02/16/dnscrypt-dnsmasq-en-archlinux"/>
   <updated>2014-02-16T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2014/02/16/dnscrypt-dnsmasq-en-archlinux</id>
   <content type="html">&lt;p&gt;Hace &lt;a href=&quot;http://blog.jam.net.ve/2010/08/20/vuela-en-internet-usando-una-cache-dns-dnsmasq-en-ubuntu/&quot;&gt;algo de tiempo&lt;/a&gt; ya escribi un articulo de como acelerar un poco el internet
usando DNSMasq como una cache DNS, en esta ocasion vamos a mejorar un poco la
seguridad de nuestra conexion a internet con la ayuda de &lt;a href=&quot;http://dnscrypt.org/&quot;&gt;DNSCrypt&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;DNSCrypt nos provee un servicio local que puede ser usado directamente como
resolvedor o redireccionador DNS, encriptando y autenticando las peticiones DNS
usando el protocolo DNSCrypt y pasandolos a un servidor superior. Estas
propiedades de DNSCrypt nos permite entonces encriptar las peticiones DNS de
forma que ningun proxy o ISP pueda capturarlas y/o modificarlas para espiarte o
bloquearte determinadas paginas.&lt;/p&gt;

&lt;p&gt;En este ejemplo yo usare ArchLinux ya que es la distro que uso actualmente, pero
la informacion es facilmente aplicable a otras distros como Ubuntu o Debian, en
estas dos ultimas distros linux se requiere compilar e instalar aparte
&lt;a href=&quot;https://github.com/jedisct1/libsodium&quot;&gt;Libsodium&lt;/a&gt; ya que si mal no recuerdo
hasta la fecha no existen paquetes en sus repositorios.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;h1 id=&quot;instalando-dnscript-y-dnsmasq&quot;&gt;Instalando DNSCript y DNSMasq.&lt;/h1&gt;

&lt;p&gt;Para instalarlos en ArchLinux tan solo ejecutamos en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; sudo pacman -S dnsmasq dnscrypt-proxy&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;NOTA: En los repos de ArchLinux cuenta con el paquete libsodium el cual debe
instalarse para poder usar DNSCrypt, aqui es instalado automaticamente como
dependencia, pero si estas en alguna otra distro como Debian o Ubuntu deberas
descargar &lt;a href=&quot;https://github.com/jedisct1/libsodium&quot;&gt;Libsodium&lt;/a&gt; compilarlo e
instalarlo.&lt;/p&gt;

&lt;h1 id=&quot;configurando-dnsmasq-para-que-trabaje-junto-a-dnscrypt&quot;&gt;Configurando Dnsmasq para que trabaje junto a Dnscrypt.&lt;/h1&gt;

&lt;p&gt;Para que Dnsmasq trabaje con Dnscrypt y asi cachear las peticiones dns de
dnscrypt tan solo debemos agregar o descomentar las siguientes lineas en su
archivo de configuracion que deberia estar en &lt;strong&gt;/etc/dnsmasq.conf&lt;/strong&gt; &lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# Configuration file for dnsmasq.&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Format is one option per line, legal options are the same as the&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# long options legal on the command line. See&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# &amp;quot;/usr/sbin/dnsmasq --help&amp;quot; or &amp;quot;man 8 dnsmasq&amp;quot; for details.&lt;/span&gt;
 
&lt;span class=&quot;c&quot;&gt;# Don&amp;#39;t read the hostnames in /etc/hosts.&lt;/span&gt;
no-hosts
 
&lt;span class=&quot;c&quot;&gt;# Do not go into the background at startup but otherwise run as&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# normal.&lt;/span&gt;
keep-in-foreground
 
&lt;span class=&quot;c&quot;&gt;# Do not provide DHCP or TFTP on the loopback interface.&lt;/span&gt;
no-dhcp-interface&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;lo
 
&lt;span class=&quot;c&quot;&gt;# Only listen on the loopback interface.&lt;/span&gt;
listen-address&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;127.0.0.1
 
&lt;span class=&quot;c&quot;&gt;# Only bind to interfaces dnsmasq is listening on.&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;bind&lt;/span&gt;-interfaces
 
&lt;span class=&quot;c&quot;&gt;# Never forward addresses in the non-routed address spaces.&lt;/span&gt;
bogus-priv
 
&lt;span class=&quot;c&quot;&gt;# Don&amp;#39;t read /etc/resolv.conf.&lt;/span&gt;
no-resolv
 
&lt;span class=&quot;c&quot;&gt;# Reject (and log) addresses from upstream nameservers which are in&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# the private IP ranges. This blocks an attack where a browser behind&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# a firewall is used to probe machines on the local network.&lt;/span&gt;
stop-dns-rebind
 
&lt;span class=&quot;c&quot;&gt;# Exempt 127.0.0.0/8 from rebinding checks. This address range is&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# returned by realtime black hole servers, so blocking it may disable&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# these services.&lt;/span&gt;
rebind-localhost-ok
 
&lt;span class=&quot;c&quot;&gt;# Never forward plain names (without a dot or domain part).&lt;/span&gt;
domain-needed
 
&lt;span class=&quot;c&quot;&gt;# Upstream server is dnscrypt-proxy on local machine.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;server&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;127.0.0.2
 
&lt;span class=&quot;c&quot;&gt;# Set the cache size here. If you don&amp;#39;t use spam blocking add-ons such&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Adblock Plus or Ghostery, you may want to increase this value as you&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# will be resolving more domain names.&lt;/span&gt;
cache-size&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1000
 
&lt;span class=&quot;c&quot;&gt;# Pass through DNSSEC validation results from dnscrypt-proxy.&lt;/span&gt;
proxy-dnssec&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Si se fijan en la configuracion indicamos una IP de escucha en
&lt;strong&gt;listen-address=127.0.0.1&lt;/strong&gt; esta IP sera la que luego colocaremos en nuestra
interfaz de red como servidor DNS para asi redireccionar todas las peticiones
DNS hacia Dnsmasq. Tambien podemos notar que especificamos un servidor en
&lt;strong&gt;server=127.0.0.2&lt;/strong&gt; esta sera la direccion IP en la que DNScrypt esta
escuchando peticiones.&lt;/p&gt;

&lt;h1 id=&quot;configurando-dnscrypt&quot;&gt;Configurando Dnscrypt.&lt;/h1&gt;

&lt;p&gt;Bien si de casualidad no lo has notado, hay que hacer un pequeno ajuste para
correjir un conflicto, y es que por defecto tanto DNSMasq como Dnscrypt escuchan
usando la misma direccion IP local, lo cual no deberia ser. Para corregir esto y
adaptarlo a la configuracion que ya tenemos hecha para Dnsmasq editaremos el
archivo &lt;strong&gt;/etc/conf.d/dnscrypt-proxy&lt;/strong&gt; el cual probablemente contenga esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;DNSCRYPT_LOCALIP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;127.0.0.1
&lt;span class=&quot;nv&quot;&gt;DNSCRYPT_LOCALPORT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;53
&lt;span class=&quot;nv&quot;&gt;DNSCRYPT_USER&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;nobody
&lt;span class=&quot;nv&quot;&gt;DNSCRYPT_PROVIDER_NAME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;2.dnscrypt-cert.opendns.com
&lt;span class=&quot;nv&quot;&gt;DNSCRYPT_PROVIDER_KEY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;B735:1140:206F:225D:3E2B:D822:D7FD:691E:A1C3:3CC8:D666:8D0C:BE04:BFAB:CA43:FB79
&lt;span class=&quot;nv&quot;&gt;DNSCRYPT_RESOLVERIP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;208.67.220.220
&lt;span class=&quot;nv&quot;&gt;DNSCRYPT_RESOLVERPORT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;443&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Aqui solo cambiaremos el contenido de la linea que dice
&lt;strong&gt;DNSCRYPT_LOCALIP=127.0.0.1&lt;/strong&gt; y cambiaremos la IP por ADIVINEN!!!
&lt;strong&gt;127.0.0.2&lt;/strong&gt;.&lt;/p&gt;

&lt;h1 id=&quot;configurando-nuestra-interfaz-de-red&quot;&gt;Configurando nuestra interfaz de red:&lt;/h1&gt;

&lt;p&gt;Una vez realizada la configuracion de Dnsmasq y Dnscrypt tan solo resta adaptar
nuestra interfaz de red de internet y ajustarla para que use como unico servidor
DNS la IP &lt;strong&gt;127.0.0.1&lt;/strong&gt; esta es la IP local de nuestra PC y la misma IP a la
cual esta escuchando Dnsmasq. es probable que requieras reiniciar tu interfaz de
red para que los cambios tengan efecto.&lt;/p&gt;

&lt;h1 id=&quot;ejecutando-los-servicios-y-primera-prueba&quot;&gt;Ejecutando los servicios y primera prueba:&lt;/h1&gt;

&lt;p&gt;Con todo esto ya tenemos listo nuestro encriptado de peticiones DNS y chacheado
de las mismas para una mayor seguridad, evitar la vigilancia y saltar la censura
de tu ISP o Gobierno.&lt;/p&gt;

&lt;p&gt;En ArchLinux basta con ejecutar:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; sudo systemctl &lt;span class=&quot;nb&quot;&gt;enable &lt;/span&gt;dnscrypt-proxy.service
&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; sudo systemctl &lt;span class=&quot;nb&quot;&gt;enable &lt;/span&gt;dnsmasq.service&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Para habilitar los servicios y luego para arrancar:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; sudo systemctl start dnscrypt-proxy.service
&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; sudo systemctl start dnsmasq.service&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Bien, para esta prueba podemos hacer una simple consulta DNS con el comando
&lt;strong&gt;dig&lt;/strong&gt; a alguna URL que sepamos esta censurada por nuestro Proveedor de
internet, en mi caso mi proveedor es &lt;strong&gt;CANTV&lt;/strong&gt; el cual pertenece al Gobierno
Venezolano y una de las paginas muy conocidas que esta siendo censuradas desde
hace tiempo por el Gobierno de Venezuela es &lt;a href=&quot;http://dolartoday.com/&quot;&gt;DolarToday&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Si yo realizo una consulta dig a &lt;strong&gt;dolartoday.com&lt;/strong&gt; seguro obtendre algo como
esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;&amp;lt;&amp;lt;&amp;gt;&amp;gt; DiG 9.9.2-P2 &amp;lt;&amp;lt;&amp;gt;&amp;gt; dolartoday.com&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; global options: +cmd&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; Got answer:&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; -&amp;gt;&amp;gt;HEADER&amp;lt;&amp;lt;- opcode: QUERY, status: NOERROR, id: 34898&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1&lt;/span&gt;

&lt;span class=&quot;go&quot;&gt;;; OPT PSEUDOSECTION:&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;; EDNS: version: 0, flags:; udp: 4096&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; QUESTION SECTION:&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;dolartoday.com.			IN	A&lt;/span&gt;

&lt;span class=&quot;go&quot;&gt;;; ANSWER SECTION:&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;dolartoday.com.		299	IN	A	&lt;/span&gt;

&lt;span class=&quot;go&quot;&gt;;; Query time: 316 msec&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; SERVER: 200.44.32.12#53(200.44.32.12)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; WHEN: Sun Feb 16 12:36:53 2014&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; MSG SIZE  rcvd: 59&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Notese que en la columna de registros &lt;strong&gt;A&lt;/strong&gt; no tenemos absolutamente nada, es
decir no nos estan dando la IP del servidor de DolarToday.com  para poder
conectar y cargar la pagina. Notese tambien la IP &lt;strong&gt;200.44.32.12&lt;/strong&gt;  esta es la
IP de uno de los servidores DNS de CANTV los cuales se agregan automaticamente
cuando conectas a internet con dicho proveedor.&lt;/p&gt;

&lt;p&gt;Con Dnsmasq, Dnscrypt ejecutandose y la interfaz de red configurada y lista, al
realizar la misma consulta DNS con &lt;strong&gt;dig&lt;/strong&gt; obtendriamos algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;&amp;lt;&amp;lt;&amp;gt;&amp;gt; DiG 9.9.2-P2 &amp;lt;&amp;lt;&amp;gt;&amp;gt; dolartoday.com&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; global options: +cmd&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; Got answer:&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; -&amp;gt;&amp;gt;HEADER&amp;lt;&amp;lt;- opcode: QUERY, status: NOERROR, id: 34898&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1&lt;/span&gt;

&lt;span class=&quot;go&quot;&gt;;; OPT PSEUDOSECTION:&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;; EDNS: version: 0, flags:; udp: 4096&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; QUESTION SECTION:&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;dolartoday.com.			IN	A&lt;/span&gt;

&lt;span class=&quot;go&quot;&gt;;; ANSWER SECTION:&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;dolartoday.com.		299	IN	A	108.162.207.195&lt;/span&gt;

&lt;span class=&quot;go&quot;&gt;;; Query time: 316 msec&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; SERVER: 127.0.0.1#53(127.0.0.1)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; WHEN: Sun Feb 16 12:36:53 2014&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;;; MSG SIZE  rcvd: 59&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ahora si!!! puedes notarse como se nos entrega un valor en la columna &lt;strong&gt;A&lt;/strong&gt; la
cual es la IP del servidor donde esta alojada la web a la que intentamos acceder
y que esta bloqueada por nuestro ISP. Notese tambien que el servidor al que se
envia la consulta DNS es la IP &lt;strong&gt;127.0.0.1&lt;/strong&gt; el cual es nuestra misma PC y la IP
es en donde esta escuchando Dnsmasq por las peticiones DNS que le solicitemos
para que este a su vez se las solicite a Dnscrypt y este a su vez realice una
consulta &lt;strong&gt;SEGURA&lt;/strong&gt; y &lt;strong&gt;ENCRIPTADA&lt;/strong&gt; a un servidor DNS confiable y libre de
censuras.&lt;/p&gt;

&lt;p&gt;Probablemente te preguntaras a que servidor &lt;strong&gt;Confiable&lt;/strong&gt; esta Dnscrypt
realizando las consultas DNS, pues arriba en la configuracion de Dnscrypt esta
una pista: &lt;strong&gt;DNSCRYPT_RESOLVERIP=208.67.220.220&lt;/strong&gt; y
&lt;strong&gt;DNSCRYPT_PROVIDER_NAME=2.dnscrypt-cert.opendns.com&lt;/strong&gt;. Esta direccion IP
pertenece al servicio &lt;a href=&quot;http://www.opendns.com&quot;&gt;OpenDNS&lt;/a&gt; el cual es el servicio
con el que viene configurado por defecto Dnscrypt.&lt;/p&gt;

&lt;p&gt;Opendns sirve muy bien para realizar el trabajo que deseamos el cual es
saltarnos restrinciones, pero si lo deseas puedes cambiarlo por algun otro, en
la pagina de &lt;a href=&quot;http://dnscrypt.org/&quot;&gt;Dnscrypt&lt;/a&gt; puedes encontrar una lista de
actuales proveedores de servicios DNS con Dnscrypt activado como por ejemplo
&lt;a href=&quot;https://cloudns.com.au/&quot;&gt;CloudNS&lt;/a&gt; de Australia, &lt;a href=&quot;http://www.opennicproject.org/&quot;&gt;OpenNIC&lt;/a&gt; con servidores en varias partes del mundo, &lt;a href=&quot;http://dnscrypt.eu/&quot;&gt;DnsCrypt.eu&lt;/a&gt; con servidores en Holanda y Dinamarca y &lt;a href=&quot;http://dc1.soltysiak.com/&quot;&gt;Soltysiak.com&lt;/a&gt; con servidores en Polonia.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Flisol Margarita 2013 - Venezuela</title>
   <link href="http://blog.jam.net.ve/2013/03/24/flisol-margarita-2013-venezuela"/>
   <updated>2013-03-24T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2013/03/24/flisol-margarita-2013-venezuela</id>
   <content type="html">&lt;p&gt;El &lt;a title=&quot;Web Flisol&quot; href=&quot;http://www.flisol.org.ve/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;FLISOL&lt;/a&gt; &lt;strong&gt;(Festival Latinoamericano de Instalación de Software Libre)&lt;/strong&gt; es un evento que se realiza en las comunidades de todo el mundo en donde todas las personas interesadas en probar y/o instalar una distribución Linux, puede llevar su PC y un colaborador de la feria le instalara la distro que deseas ¡¡¡totalmente Gratis!!!.   Además de esto, se realizaran charlas sobre la filosofía y los beneficios del uso de Linux y software libre.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/jesusangelm/8586973331/&quot; title=&quot;flisol-bannerV-2013 por JamUnix, en Flickr&quot;&gt;&lt;center&gt;&lt;img src=&quot;http://farm9.staticflickr.com/8096/8586973331_98aeb5acce.jpg&quot; width=&quot;212&quot; height=&quot;500&quot; alt=&quot;flisol-bannerV-2013&quot; /&gt;&lt;/center&gt;&lt;/a&gt;&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Este es un tipo de festival que se realiza en todo el mundo, y este &lt;strong&gt;27 de Abril de 2013&lt;/strong&gt; se realizara en 17 ciudades de Venezuela entre ellas la &lt;strong&gt;Isla de Margarita&lt;/strong&gt;. Para ver las demás ciudades participantes click &lt;a href=&quot;http://flisol.org.ve/donde/&quot; rel=&quot;nofollow&quot;&gt;Aqui&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Así que si vives en Margarita y te gusta el software libre o tienes curiosidad en conocer Linux y sus beneficios, no dudes en ir, ¡¡¡la asistencia es totalmente libre y gratuita!!!. Este año el Flisol Margarita tendra 3 sedes:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://flisol.org.ve/donde/porlamar/&quot;&gt;Porlamar&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://flisol.org.ve/donde/guatamare/&quot;&gt;Guatamare (UDO Nueva Esparta)&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://flisol.org.ve/donde/juan-griego/&quot;&gt;Juan Griego&lt;/a&gt;. &lt;strong&gt;¡Posiblemente me veras aqui!&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Si deseas quete instalen una distribucion Linux, puedes llevar tu PC o Laptop. Es muy recomendable de que antes de llevar tu PC/Laptop hagas un respaldo de tus datos y liberes espacio en tu Disco Duro. Tambien es muy recomendable que lleves minimo 2 CD/DVD virgen para copiar en el la distribucion Linux de tu preferencia en caso de que se nos agoten los discos que regalamos, lo cual suele suceder los primeros 5 minutos del evento.&lt;/p&gt;

&lt;h3 id=&quot;te-esperamos-en-el-flisol-margarita-2013&quot;&gt;¡¡¡Te esperamos en el Flisol Margarita 2013!!!&lt;/h3&gt;
</content>
 </entry>
 
 <entry>
   <title>Instalando rbenv en linux</title>
   <link href="http://blog.jam.net.ve/2012/04/27/instalando-rbenv-en-linux"/>
   <updated>2012-04-27T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2012/04/27/instalando-rbenv-en-linux</id>
   <content type="html">&lt;p&gt;Es una herramienta en linea de comandos que nos permite administrar y cambiar fácilmente
entre nuestras múltiples instalaciones de diversas versiones de Ruby. Es muy sencillo, discreto,
y sigue la tradicion UNIX.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/sstephenson/rbenv&quot;&gt;Rbenv&lt;/a&gt;&lt;/strong&gt; a diferencia de &lt;strong&gt;RVM&lt;/strong&gt; solo nos permite en su instalacion
por defecto administrar multiples versiones de Ruby, lo que nos lleva a una solucion mas limpia y
simple con menos peculiaridades y trampas. &lt;strong&gt;rbenv&lt;/strong&gt; fue creado por &lt;a href=&quot;http://sstephenson.us/&quot;&gt;Sam Stephenson&lt;/a&gt; de
&lt;a href=&quot;http://37signals.com/&quot;&gt;37Signal&lt;/a&gt; el cual creo el Framework JavaScript &lt;a href=&quot;http://prototypejs.org/&quot;&gt;Prototype&lt;/a&gt;.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;h1 id=&quot;que-hace-rbenv&quot;&gt;Que hace rbenv?&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Nos permite cambiar la versión de Ruby global de usuario.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Proporciona soporte para las versiones de Ruby en pre-proyecto o desarrollo.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Permite reemplazar la version de Ruby con variables de entorno.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;en-contraste-con-rvm-rbenv-no&quot;&gt;En contraste con RVM, rbenv no…&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Necesita ser cargado en una terminal.&lt;/strong&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;No sobreescribe comandos de consola como &lt;code&gt;cd&lt;/code&gt;.&lt;/strong&gt; Eso es peligroso y propenso a errores.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Tiene un archivo de configuracion. No hay nada que configurar excepto que version de Ruby quieres usar.&lt;/strong&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Instala Ruby.&lt;/strong&gt; Tu puedes compilar e instalar Ruby por tu cuenta, o usar &lt;a href=&quot;https://github.com/sstephenson/ruby-build&quot;&gt;ruby-build&lt;/a&gt; para automatizar el proceso.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Administra gemas.&lt;/strong&gt; Para ese trabajo existen muy buenas herramientas dedicadas como &lt;a href=&quot;http://gembundler.com/&quot;&gt;Bundler&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Exige cambios de las librerias Ruby para compatibilidad.&lt;/strong&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Pregunta con advertencias cuando cambios a un proyecto.&lt;/strong&gt; En lugar de ejecutar código arbitrario, rbenv lee solo el nombre de la version de cada proyecto.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;instalacion&quot;&gt;Instalacion.&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Antes que nada tengo que advertirte que rbenv no es compatible con RVM&lt;/strong&gt; por lo que si estas usandolo
te aconsejo desinstalarlo. Como lo puedes hacer? simplemente elimina la carpeta &lt;code&gt;~/.rvm&lt;/code&gt; y borra cualquier
referencia hacia &lt;strong&gt;RVM&lt;/strong&gt; en tu &lt;code&gt;~/.bashrc&lt;/code&gt; o &lt;code&gt;~/.bash_profile&lt;/code&gt; o &lt;code&gt;~/.zshrc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Antes de instalar rbenv debes instalar algunas dependencias basicas&lt;/strong&gt; para compilar Ruby entre otras cosas,
probablemente ya las tengas instaladas pero si obtienes algun error compilando Ruby te recomiendo leer
mi &lt;strong&gt;&lt;a href=&quot;http://blog.jam.net.ve/2011/05/17/instalando-rvm-ruby-rails-en-ubuntu/&quot;&gt;Guia de instalacion de RVM&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;En primer lugar clonamos &lt;strong&gt;rbenv&lt;/strong&gt; desde su repositorio Github a una carpeta en &lt;code&gt;~/.rbenv&lt;/code&gt; ejecutanto en la terminal:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git clone git://github.com/sstephenson/rbenv.git .rbenv&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;Agregamos &lt;code&gt;~/.rbenv/bin&lt;/code&gt; a nuestro &lt;code&gt;$PATH&lt;/code&gt; para acceder al comando &lt;code&gt;rbenv&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;export PATH=&amp;quot;$HOME/.rbenv/bin:$PATH&amp;quot;&amp;#39;&lt;/span&gt; &amp;gt;&amp;gt; ~/.bash_profile&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;En caso de que uses Zsh&lt;/strong&gt; modifica &lt;code&gt;~/.zshrc&lt;/code&gt; en lugar de &lt;code&gt;~/.bash_profile&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Agrega &lt;code&gt;rbenv init&lt;/code&gt; a tu shell para activar shims y autocompletado:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;eval &amp;quot;$(rbenv init -)&amp;quot;&amp;#39;&lt;/span&gt; &amp;gt;&amp;gt; ~/.bash_profile&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;En caso de que uses Zsh&lt;/strong&gt; modifica &lt;code&gt;~/.zshrc&lt;/code&gt; en lugar de &lt;code&gt;~/.bash_profile&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Reinicia tu terminal, simplemente cierrala y vuelve a abrirla o ejecuta:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$SHELL&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;FELICITACIONES!!! Con esto ya tienes instalado rbenv!!!&lt;/strong&gt;&lt;/p&gt;

&lt;h1 id=&quot;instalacion-de-ruby&quot;&gt;Instalacion de Ruby.&lt;/h1&gt;

&lt;p&gt;Existen dos metodos de instalar Ruby con rbenv:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1-&lt;/strong&gt; Compilando desde sus fuentes:&lt;/p&gt;

&lt;p&gt;Tan solo instala la versionde Ruby que desees en &lt;code&gt;~./rbenv/versions&lt;/code&gt; por ejemplo si queremos instalar Ruby 1.9.3-p194:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Descargamos los fuentes desde &lt;a href=&quot;http://ftp.ruby-lang.org/pub/ruby/1.9/&quot;&gt;ftp.ruby-lang.org&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;luego descomprimes el archivo, entramos a el en una terminal y ejecutamos los siguientes comandos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;./configure --prefix&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/.rbenv/versions/1.9.3-p194
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;make
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;make install&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Con esto ya tendriamos instalado Ruby, tan solo nos faltaria reconstruir los archivos shim (calce) binarios:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;rbenv rehash&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Nota&lt;/strong&gt; Esto lo debemos hacer cada vez que se instala un nuevo binario de Ruby como por ejemplo cuando
instalamos una nueva version de Ruby o cuando instalamos una Gema que contiene un binario como por ejemplo rake.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2-&lt;/strong&gt; Por medio de el plugin &lt;a href=&quot;https://github.com/sstephenson/ruby-build&quot;&gt;ruby-build&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tan solo debemos instalarlo como plugins para rbenv dentro de &lt;code&gt;~/.rbenv/plugins&lt;/code&gt; ejecutando los siguientes comandos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;mkdir -p ~/.rbenv/plugins
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ~/.rbenv/plugins
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git clone git://github.com/sstephenson/ruby-build.git&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Luego de esto puedes usar el comando &lt;code&gt;rbenv install&lt;/code&gt; por ejemplo si queremos instalar Ruby 1.9.2-p318 ejecutamos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;rbenv install 1.9.2-p318&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Nota:&lt;/strong&gt; debido a que &lt;strong&gt;ruby-build&lt;/strong&gt; usa una especie de &lt;a href=&quot;https://github.com/sstephenson/ruby-build/tree/master/share/ruby-build&quot;&gt;recipes o definiciones de compilacion&lt;/a&gt; para descargar, compilar e instalas las distintas versiones de Ruby, al momento de ser liberada una nueva version de ruby te recomiendo&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Antes&lt;/strong&gt; de intentar instalarla, actualizar el plugin &lt;strong&gt;ruby-build&lt;/strong&gt; ejecutando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ~/.rbenv/plugins/ruby-build
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git pull&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Si luego de esto todavia no puedes instalar la nueva version de Ruby es posible que no este todavia actualizado
el repositorio de ruby-build por lo que deberas instalar descargando los fuentes y compilandolos tal cual
explico en el 1er metodo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nota:&lt;/strong&gt; Recuerda ejecutar &lt;code&gt;rbenv rehash&lt;/code&gt; cada vez que instales una version de Ruby o instales una gema que
contenga binarios, esto es lo unico en lo que hay que tener cuidado con &lt;strong&gt;rbenv&lt;/strong&gt;.&lt;/p&gt;

&lt;h1 id=&quot;actualizando-rbenv&quot;&gt;Actualizando rbenv.&lt;/h1&gt;

&lt;p&gt;Debido a que rbenv se descarga desde su repositorio de desarrollo Github usando &lt;code&gt;git&lt;/code&gt;, podemos actualizarlo a
la ultima version facilmente ejecutando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ~/.rbenv
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git pull&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1 id=&quot;usos-basicos-de-rbenv&quot;&gt;Usos basicos de rbenv.&lt;/h1&gt;

&lt;p&gt;Bien ya tenemos instalado rbenv y algunas versiones de Ruby, ahora nos toca ver como podemos cambiar entre
las distintas versiones que tenemos instaladas.&lt;/p&gt;

&lt;p&gt;rbenv determina cual version de Ruby sera utilizada con un simple modelo de prioridad:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;global &amp;gt; local &amp;gt; shell&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;El parametro &lt;strong&gt;global&lt;/strong&gt; le indica a rbenv que se usara la version de Ruby indicada en todo el sistema y todas
las consolas que se abran.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;rbenv global 1.9.3-p194&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;El parametro &lt;strong&gt;local&lt;/strong&gt; le indica a rbenv que se usara la version de Ruby indicada solo en la carpeta
(y subcarpetas) o proyecto en el que te encuentres, y lo configura creando un archivo oculto &lt;strong&gt;.rbenv-version&lt;/strong&gt;
en la raiz de la carpeta en la que estas.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;rbenv local 1.9.2-p318&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;El parametro &lt;strong&gt;shell&lt;/strong&gt; le indica a rbenv que se usara la version de ruby indicada solo en esa sesion shell
en ejecucion, por lo que al cerrar esa terminal y volverla abrir se fijara la version de
Ruby indicada en el parametro &lt;strong&gt;global&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;rbenv shell 1.9.3-p125&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Existe un parametro especial que le indica a rbenv usar la version de Ruby instalada en el sistema.
para acceder a ella tan solo ejecuta:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;rbenv system&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Para mas comandos utiles de rbenv puedes ejecutar &lt;code&gt;rbenv help&lt;/code&gt; para leer la ayuda.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Actualizando de android 2.1 Eclair a Android 2.2.1 Froyo en un Samsung Galaxy Spica i5700 Digitel</title>
   <link href="http://blog.jam.net.ve/2011/10/08/actualizando-de-android-2-1-eclair-a-android-2-2-1-froyo-cyanogenmod-6-1-1-alpha-8-4-en-un-samsung-galaxy-spica-i5700-digitel"/>
   <updated>2011-10-08T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2011/10/08/actualizando-de-android-2-1-eclair-a-android-2-2-1-froyo-cyanogenmod-6-1-1-alpha-8-4-en-un-samsung-galaxy-spica-i5700-digitel</id>
   <content type="html">&lt;p&gt;Sigo aprendiendo cada vez mas sobre Android, aunque con algunos tropezones. Hace unas semanas comentaba como actualice mi &lt;a title=&quot;Actualizar de Android 1.5 Cupcake a Android 2.1 Eclair en un Galaxy Spica I5700&quot; href=&quot;http://blog.jam.net.ve/2011/09/17/actualizando-de-android-1-5-cupcake-a-android-2-1-eclair-en-un-samsung-galaxy-spica-i5700-digitel-venezuela/&quot; target=&quot;_blank&quot;&gt;Galaxy Spica I5700 de Android 1.5 Cupcake (Oficial Digitel) a Android 2.1 Eclair (Oficial Digitel)&lt;/a&gt;, las mejoras eran ya muy notables en esa actualización pero… se puede mejorar mucho mas!!! si actualizamos a alguna de las tantas Rom personalizadas de Android 2.2 Froyo. Pues estuve leyendo sobre las ventajas de hacer una nueva actualización y a la final note que me convenía mucho.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/qGAuu&quot;&gt;&lt;center&gt;&lt;img src=&quot;http://i.imgur.com/qGAuu.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/center&gt;&lt;/a&gt;&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Pues bien la room que elegí fue CyanogenMod 6.1.1 Spica Alpha 8.4 la cual esta basada en Froyo 2.2.1 e incluye mejoras interesantes como soporte 3D y soporte MultiTouch, al ser Froyo también corrige el bug en Eclair de la cámara que se queda oscura cuando se toman fotos estando conectada al Wifi. Por ser una room modificada, incluye un kernel actualizado con muchas mejoras como por ejemplo tener un &lt;a title=&quot;Recovery Wiki en Samdroid.net&quot; href=&quot;http://forum.samdroid.net/wiki/showwiki/Recovery&quot; target=&quot;_blank&quot;&gt;recovery&lt;/a&gt; el cual es una muy buena utilidad que nos permitiria hacer cosas como por ejemplo ser root desde que enciendes el teléfono :D, hacer respaldos, aplicar actualizaciones y/o modificaciones comprimidas en .zip, instalar nuevas room, particionar la MicroSD, entre muchas otras funciones (tambien depende del kernel que instales).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OJO estos pasos fueron realizados partiendo de un Samsung Galaxy Spica I5700 con Android 2.1 Eclair actualizado mediante Kies mini (Room oficial de samsung), si este no es tu caso NO HAGAS NADA!!!&lt;/strong&gt; ya que podrías tener un kernel distinto que podría no ser compatible con los que aquí se usan.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Notas antes de comenzar, si no cumples con algunas de estas notas NO HAGAS NADA!!!&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Tu teléfono debe estar cargado al 100%. lo mismo va en caso de que estés desde una Laptop, y muy recomendable estar conectado a un UPS, no valla a ser que &lt;strong&gt;CortoElec&lt;/strong&gt; le de por quitarte la luz en pleno proceso de actualización.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;En el teléfono ve a &lt;strong&gt;“Configuración”&lt;/strong&gt; o &lt;strong&gt;“Ajustes”&lt;/strong&gt;  luego &lt;strong&gt;“Aplicaciones”&lt;/strong&gt;  luego &lt;strong&gt;“Desarrollo”&lt;/strong&gt; y por ultimo asegurare de que &lt;strong&gt;“Depuración de USB”&lt;/strong&gt; esta marcada.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Entra en teléfono como si fueses a marcar un numero para llamar, pero teclea &lt;strong&gt;*#7284#&lt;/strong&gt; y verifica que &lt;strong&gt;UART&lt;/strong&gt;  y &lt;strong&gt;USB&lt;/strong&gt; &lt;a href=&quot;http://jam.net.ve/capt/phoneutils.png&quot; target=&quot;_blank&quot;&gt;esten marcados en &lt;strong&gt;PDA&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Has un &lt;a title=&quot;respaldo&quot; href=&quot;../tag/respaldo/&quot;&gt;respaldo&lt;/a&gt; de tus contactos y archivos en tu MicroSD. recomendable sincronizar los contactos con tu cuenta de Google/Gmail para que queden respaldados allí y luego puedas recuperarlos fácilmente.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Recomendable: instalar la aplicación &lt;a href=&quot;https://market.android.com/details?id=com.riteshsahu.APNBackupRestore&amp;amp;feature=search_result&quot; rel=&quot;nofollow&quot;&gt;APN Backup &amp;amp; Restore&lt;/a&gt; para que respaldes tus APN la guardes en la memoria MicroSD o tu PC y las puedas restaurar luego.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Si harás la actualización en una PC de &lt;a title=&quot;escritorio&quot; href=&quot;../tag/escritorio/&quot;&gt;escritorio&lt;/a&gt; conecta el cable USB del teléfono a un conector USB que sea directo a la Tarjeta Madre de la PC. no uses los puertos delanteros o laterales del gabinete de la PC ya que suelen ser de pobre calidad y suelen fallar mucho, tampoco uses concentradores o Hub.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Rezar dos Padres Nuestros y tres Ave Maria. es broma, pero de seguro querrás tener a Dios de tu lado en este momento.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Requerimientos:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Descargar &lt;a title=&quot;Odin 4.03 Spica OPS&quot; href=&quot;http://www.jam.net.ve/capt/Odin_4.03_Spica_ops.zip&quot; target=&quot;_blank&quot;&gt;Odin 4.03 &lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://forum.samdroid.net/f53/cyanogenmod-6-1-1-spica-alpha8-4-a-4716/&quot; target=&quot;_blank&quot;&gt;Descargar CyanogenMod-6.1.1-Spica-alpha8.4&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://files.samdroid.net/files/2forum/i5700_LK2-08_PDA.7z&quot; target=&quot;_blank&quot;&gt;Descargar&lt;/a&gt; el kernel de Leshak para &lt;strong&gt;&lt;a href=&quot;http://forum.samdroid.net/f55/lk2-08-original-firmwares-root-new-superuser-wifi-tether-bb-12-07-2010-a-1193/&quot; target=&quot;_blank&quot;&gt;Firmware Original&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;OJO&lt;/strong&gt; claramente dice Firmware original, Android 2.1 de agencia o actualizado mediante Kies Mini como en mi caso, si este no es tu situacion, &lt;strong&gt;NO HAGAS NADA!!!&lt;/strong&gt; ya que podrías tener un kernel distinto que podría &lt;strong&gt;no ser compatible&lt;/strong&gt; con los que aquí se usan.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Necesitas tener instalados los drivers necesarios para conectar el teléfono a la PC, si en tu caso ya tienes instalado Samsung NPS (New PC Studio) o el Kies Mini, entonces ya tienes los drivers instalados, pero cabe aclarar un detalle debes desactivar el inicio automatico de Kies o NPS, puedes hacerlo mediante el Ccleaner. sino  lo que puedes hacer es entrar en la carpeta donde esta instalado NPS y/o Kies, debe haber por alli algun ejecutable llamado SAMSUNG_USB_Driver_for_Mobile_Phones.exe de unos 18.6Mb (Version 1.3.850) respaldalo en alguna otra ubicación, des instala el Kies y/o el NPS, limpia registros y demas con Ccleaner, reinicia la PC, luego instala los drivers que respaldaste y vuelve a reiniciar.  si no quieres hacer todo esto puedes descargar los drivers desde &lt;a href=&quot;http://files.samdroid.net/files/drivers/SAMSUNG_USB_Driver_for_Mobile_Phones.rar&quot; target=&quot;_blank&quot;&gt;aqui.&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Desactivar el inicio automático de tu antivirus, esto es para evitar posibles problema con los drivers.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Procedimientos:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Una vez que tengas instalado los drivers, ayas descargado Odin, la Room de Froyo para tu Spica, descargado el kernel de leshak &lt;strong&gt;i5700_LK2-08_PDA.7z&lt;/strong&gt; y hayas configurado y reiniciado la PC para que NPS, Kies y tu antivirus no se inicien, entonces toca flashear para obtener root y recovery.&lt;/p&gt;

&lt;p&gt;0- Descomprime el &lt;strong&gt;Odin_4.03_Spica_ops.zip&lt;/strong&gt;, obtendrás una carpeta con el Odin y dos archivos.&lt;/p&gt;

&lt;p&gt;1- Descomprime el kernel de leshak &lt;strong&gt;i5700_LK2-08_PDA.7z&lt;/strong&gt;, deberías obtener &lt;strong&gt;i5700_LK2-08_PDA.tar&lt;/strong&gt; (&lt;strong&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;OJO no lo descomprimas nuevamente, déjalo así&lt;/span&gt;&lt;/strong&gt;) de unos 15.2Mb y copíalo dentro de la carpeta donde tienes el Odin&lt;/p&gt;

&lt;p&gt;2- Copia la room &lt;strong&gt;CM-6.1.1-Spica-a8.4_update.zip&lt;/strong&gt; en la raíz de la tarjeta MicroSD, luego apaga tu teléfono, &lt;strong&gt;retira la tarjeta SIM y la MicroSD&lt;/strong&gt;, luego colocalo en &lt;strong&gt;modo Download&lt;/strong&gt;, presionando las teclas &lt;strong&gt;Volumen abajo + Camara + End o Apagar&lt;/strong&gt; .&lt;/p&gt;

&lt;p&gt;3- Abre el Odin (&lt;strong&gt;si estas en Windows Vista/Windows 7 abrelo como Administrador&lt;/strong&gt;) Conecta el teléfono a la PC, espera un ratico que Windows reconozca el dispositivo. El Odin deberia reconocerlo marcando en la casilla de Messages Added!!! y Detected!!!, ademas deberia aparecer con fondo amarillo la casilla COM Port Mapping y un numero de puerto COM.&lt;/p&gt;

&lt;p&gt;4-  En el Odin presiona el boton Reset Files, presiona el boton &lt;strong&gt;OPS&lt;/strong&gt; y agrega el archivo &lt;strong&gt;spica_jc3.ops&lt;/strong&gt;, luego presiona el boton &lt;strong&gt;PDA&lt;/strong&gt; y agrega el archivo &lt;strong&gt;i5700_LK2-08_PDA.tar&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;5- Verifica que todo se vea similar a esto:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/uVOwV&quot;&gt;&lt;img src=&quot;http://i.imgur.com/uVOwV.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;6- Si todo esta bien, entonces le damos al boton Start, Odin debería comenzar a Flashear el nuevo kernel en tu teléfono, el proceso no debería tardar mas que unos pocos segundos ya que el archivo es bastante pequeño.  El teléfono se reiniciara y entrara en el Recovery, (no es necesario, pero por seguridad espera al menos unos dos minutos y verifica que en el teléfono siga mostrándote el recovery) una vez dentro del recovery puedes desconectar el teléfono de la PC y Listo!!! ya tienes tu teléfono Rooteado y con Recovery :D&lt;/p&gt;

&lt;p&gt;7- Apaga el Teléfono, quita la batería, coloca la tarjeta MicroSD (solo la MicroSD no coloques la tarjeta SIM) que en la cual copiaste la Room, coloca nuevamente la batería y entra ahora en el modo Recovery tecleando &lt;strong&gt;Volumen Abajo + Tecla de llamada + Tecla de terminar llamada/Apagar&lt;/strong&gt;. Dejalo unos segundos presionado hasta que veas el menu del Recovery.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/0Eqgy&quot;&gt;&lt;img src=&quot;http://i.imgur.com/0Eqgy.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;8- Este es el famoso Recovery :D se maneja usando los botones del teléfono y las confirmaciones que nos pide la hacemos seleccionando el boton de Home (no se usa tocando la pantalla). lo recomendable en este punto seria hacer un respaldo (por si las moscas) para eso ve a la opción “&lt;strong&gt;Samdroid 0.2.1 Backup&lt;/strong&gt;” y de una vez comenzara a realizarse el respaldo el cual tarda unos minutos o unas 5 o 6 lineas. este respaldo luego en caso de inconvenientes podemos flashearlo mediante el Odin.&lt;/p&gt;

&lt;p&gt;9- Ahora ve a la opcion “&lt;strong&gt;Wipe, Choose what&lt;/strong&gt;” y luego aplica los 3 wipe que aparecen los cuales son “&lt;strong&gt;wipe data/cache&lt;/strong&gt;”, “&lt;strong&gt;wipe cache&lt;/strong&gt;” y “&lt;strong&gt;Wipe Dalvik cache&lt;/strong&gt;” tal como dice el recovery necesitas confirmar la opción a aplicar, presionando el botón Home (el botón de la casita)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/8lqPE&quot;&gt;&lt;img src=&quot;http://i.imgur.com/8lqPE.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;10- Luego de esto vuelve al menú principal del Recovery y selecciona la opcion “Apply any zip from SD” y elegimos el archivo &lt;strong&gt;CM-6.1.1-Spica-a8.4_update.zip&lt;/strong&gt; que copiamos anteriormente en la MicroSD. confirmamos la opción presionando Home, ahora se comenzara a instalar la nueva room, podrás ver el estado del proceso en la pantalla con todo lo que se esta realizando, también veras en el fondo una barra amarilla cargándose. Es posible que el teléfono se reinicie incluso unas 5 veces,  no te preocupes, pues esto es normal. Espera hasta que en la pantalla te diga algo como “&lt;strong&gt;Install from sd complete&lt;/strong&gt;” y vuelva al recovery.  en este punto ya debe de haberse instalado tu nueva version de Android 2.2.1 Froyo :D tan solo reinicia el telefono en la opcion “&lt;strong&gt;Reboot system now&lt;/strong&gt;” y ahora tu Spica se iniciara por primera vez con Froyo :D. no te preocupes si el primer inicio demora mas de lo normal, esto es normal. En mi caso demoro creo que como 5min aunque con el miedo y las bolas en las gargantas me parecieron como 15min LOOL&lt;/p&gt;

&lt;p&gt;11- Una vez que tu Spica cargue Froyo por primera vez, veras que aparecerá el menú de configuración inicial. pero si hiciste los pasos tal cual aparecen aquí es probable que no tengas puesta la tarjeta &lt;strong&gt;SIM&lt;/strong&gt;, por lo que debes preferiblemente cambiar el idioma a tu preferido, omitir toda la configuración inicial y apagar el teléfono. luego saca la batería, coloca la tarjeta &lt;strong&gt;SIM&lt;/strong&gt;, vuelve a colocar la batería y enciende el teléfono nuevamente. Ahora si podras completar la configuración inicial y comenzar a disfrutar de Android 2.2.1 Froyo con multitouch, drivers 3D y rooteado desde el inicio :D&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/eau2R&quot;&gt;&lt;img src=&quot;http://i.imgur.com/eau2R.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Posibles problemas:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Por suerte yo no tuve problemas graves, pero si tuve uno que me comió por varias semanas. Resulta que cuando conectaba el teléfono a la PC, el Odin me lo reconocía sin problemas, marcaba su puerto COM con fondo azul y todo lo demás como la imagen arriba. pero al hacer click en Start el Odin se quedaba sin hacer nada mas que mostrarme el mensaje “&lt;strong&gt;&amp;lt;1&amp;gt;&lt;/strong&gt; &lt;strong&gt;setup connection…&lt;/strong&gt;” en la casilla de mensajes.&lt;/p&gt;

&lt;p&gt;Luego de unas cuantas semanas investigando, probando sugerencias que me fueron recomendadas en varios foros, etc. recibí por Twitter una recomendación por parte de &lt;a href=&quot;http://twitter.com/IIKndyII&quot;&gt;IIKndyII &lt;/a&gt; (Muuuuchas gracias!!!!!) que fue la que soluciono mi problema. Cuando se quede el Odin en “&lt;strong&gt;&amp;lt;1&amp;gt;&lt;/strong&gt; &lt;strong&gt;setup connection…&lt;/strong&gt;” proceda a cerrar el Odin, luego desconecte el teléfono de la PC, apáguelo (quitando la batería y colocándosela nuevamente) inicie nuevamente en modo download, abra el Odin, cargue los archivos necesarios y conecte nuevamente el teléfono, espere unos 2 minutos  (yo me puse a ver un video de como se flasheaba un kernel al Spica :D) y luego presione el boton Start.   Y tal cual como me dijo &lt;strong&gt;IIKndyII&lt;/strong&gt;… seguro ahora si lo reconoce y Odin comienza a flashear :D&lt;/p&gt;

&lt;p&gt;En caso de que Odin te tenga rabia y te siga mostrando el mensaje, reintenta esta recomendación o reinicia la PC y vuelve a intentar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Primeras impresiones:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Esta actualización yo la realice el Lunes de esta semana, por lo que no tengo ni una semana con la room, pero las primeras impresiones han sido muy favorables con respecto a Eclair actualizado desde Kies (oficial). lo mas destacable es que con esta room  la batería me esta durando muuuuchisimo mas que con Eclair. y como muestra les comento que la ultima vez que cargue el teléfono fue el martes en la noche, y hasta el dia de hoy sábado todavía no lo e puesto a cargar, si! lleva casi 4 dias sin cargarse!!! y todavía la bateria esta al 60%.  claro esta tengo las conexiones 2G/3G desactivadas y solo estoy usando la conexión WiFi de mi casa. no he usado mucho el teléfono, tan solo he hecho unas 4 llamadas de menos de 1min C/U, actualice unas 3 aplicaciones desde el market (este mismo se actualizo a la version 3.1.5) e instale unas 4 aplicaciones. use unos 5min el GPS con la aplicación Navitel + los mapas de mi área y todavía tengo batería!!!! :P&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Actualizando de android 1.5 Cupcake a Android 2.1 Eclair en un Samsung Galaxy Spica i5700 Digitel</title>
   <link href="http://blog.jam.net.ve/2011/09/17/actualizando-de-android-1-5-cupcake-a-android-2-1-eclair-en-un-samsung-galaxy-spica-i5700-digitel-venezuela"/>
   <updated>2011-09-17T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2011/09/17/actualizando-de-android-1-5-cupcake-a-android-2-1-eclair-en-un-samsung-galaxy-spica-i5700-digitel-venezuela</id>
   <content type="html">&lt;p&gt;Hace poco mas de una semana adquirí un teléfono con S.O Android, específicamente el Samsung Galaxy Spica I5700 de Digitel, luego de jurungarlo por unas cuantas horas viendo y probando todas sus funciones me encontré con que no podía instalar muchas de las mejores aplicaciones disponibles para Android por el simple hecho de que el teléfono viene con Android 1.5 Cupcake, el cual es ya una versión desactualizada, por lo que para exprimir mejor las funciones del equipo debería actualizar como mínimo a Android 2.1 Eclair o superiores.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/rHHwV&quot;&gt;&lt;img src=&quot;http://i.imgur.com/rHHwV.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;a href=&quot;http://imgur.com/3zjoa&quot;&gt;&lt;img src=&quot;http://i.imgur.com/3zjoa.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;a href=&quot;http://imgur.com/KHhzg&quot;&gt;&lt;img src=&quot;http://i.imgur.com/KHhzg.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Buscando en internet encontré mucha información para actualizar el Galaxy Spica i5700  a Eclair o incluso ir mas allá y actualizar a Froyo o Gingerbread, pero muchas de ellas se realizan con métodos un tanto extraños (Flasheando con Odin y/o aplicar roms con Recovery) a simple  vista para alguien como yo que apenas tenia unas horas de experiencia en Android y teléfonos inteligentes, por lo que decidí dejarlas a un lado para estudiar mejor los procedimientos e intentarlo de forma segura en un futuro cercano.&lt;/p&gt;

&lt;p&gt;Por suerte en la pagina de &lt;a href=&quot;http://www.samsung.com/ve/&quot;&gt;Samsung Venezuela &lt;/a&gt; ofrecen una actualización a Eclair (no es Froyo ni Gingerbread pero al menos es algo.) con un método un tanto mas directo, con menos pasos y podría decirse que mas seguro ya
que en la &lt;a href=&quot;http://www.digitel.com.ve//Secciones/Persona_Detalle.aspx?level=18&amp;amp;Seccion=92&amp;amp;Menu=A5&amp;amp;Control=pla_equ_03.ascx&amp;amp;Equ_id=623&quot;&gt;pagina de Digitel&lt;/a&gt; dicen que hay una actualización disponible para este equipo en la pagina de Samsung (al menos lo incitan a uno a actualizar con ese método, si algo saliera mal ellos “deberían” poder responder sin rechistar.), por lo que decidí actualizar de esta forma:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Lo unico malo de todo esto es que hay que usar Windows :(  pero bueh no queda de otra (por ahora)… en mi caso yo use Windows 7 64bits.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Notas antes de comenzar, si no cumples con algunas de estas notas NO HAGAS NADA!!!:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Tu teléfono debe estar cargado al 100%. lo mismo va en caso de que estés desde una Laptop, y muy recomendable estar conectado a un UPS, no valla a ser que &lt;strong&gt;CortoElec&lt;/strong&gt; le de por quitarte la luz en pleno proceso de actualización.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;En el teléfono ve a &lt;strong&gt;“Configuración”&lt;/strong&gt; o &lt;strong&gt;“Ajustes”&lt;/strong&gt;  luego &lt;strong&gt;“Aplicaciones”&lt;/strong&gt;  luego &lt;strong&gt;“Desarrollo”&lt;/strong&gt; y por ultimo asegurare de que &lt;strong&gt;“Depuración de USB”&lt;/strong&gt; esta marcada.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Has un respaldo de tus contactos, recomendable sincronizar los contactos con tu cuenta de Google/Gmail para que queden respaldados allí y luego puedas recuperarlos fácilmente.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Recomendable: instalar la aplicación &lt;a href=&quot;https://market.android.com/details?id=com.riteshsahu.APNBackupRestore&amp;amp;feature=search_result&quot;&gt;APN Backup &amp;amp; Restore&lt;/a&gt; para que respaldes tus APN la guardes en la memoria MicroSD o tu PC y las puedas restaurar luego.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Estar conectado a internet con una conexión rápida y estable.  ya que Kies se descargara los archivos necesarios y son como 115Mb Aprox. yo me conecte desde un módem USB Movistar que es muy rápido en mi zona, pero sospecho que este fue la causa de  un error que explicare mas adelante, si cuentas con un internet Wifi o cableado de alta velocidad usalo en vez del módem para estar mas seguro.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Si harás la actualización en una PC de escritorio conecta el cable USB del teléfono a un conector USB que sea directo a la Tarjeta Madre de la PC. no uses los puertos delanteros o laterales del gabinete de la PC ya que suelen ser de pobre calidad y suelen fallar mucho, tampoco uses concentradores o Hub.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Rezar dos Padres Nuestros y tres Ave Maria.  :P es broma, pero de seguro querrás tener a Dios de tu lado en este momento :D&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Procedimiento:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Primero que todo debemos descargar la aplicación  &lt;a href=&quot;http://org.downloadcenter.samsung.com/downloadfile/ContentsFile.aspx?CDSite=UNI_VE&amp;amp;CttFileID=4050765&amp;amp;CDCttType=SW&amp;amp;ModelType=N&amp;amp;ModelName=GT-I5700L&amp;amp;VPath=SW/201107/20110727165853433/Kiesmini_1.0.0.11074_2.exe&quot;&gt;Kies Mini&lt;/a&gt; desde la pagina de Samsung Venezuela.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;la instalamos, en la ventana donde pregunta el país elige España e idioma Español ya que Venezuela no aparece por ningún lado :S&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Si por casualidad tienes instalado NPS (Samsung New PC Studio) cierralo por completo, que no haya procesos de el ejecutándose (verifica en la bandeja de sistema y en el administrador de tareas).&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Abre el Kies Mini, y en el menú elige “Instalar controladores” para que se instalen los drivers y reinicia la PC.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Nota:&lt;/strong&gt; a pesar de que en alguno otros tutoriales de flasheo con Odin y similares recomiendan quitar la MicroSD y la SIM, en este método no es necesario. en mi caso yo no se lo quite.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Abre nuevamente el Kies, conecta el teléfono a la PC y espera que lo reconozca, al cabo de unos segundos debería marcarte que hay una actualización. una vez te diga que existe una, comienza el proceso de actualización.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;El proceso comienza descargando los archivos necesarios (Roms y demás)  de internet, por lo que el tiempo depende de que tan rápida y estable sea tu conexión. (en mi caso demoro como 10min).&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Nota:&lt;/strong&gt; en caso de que estando en el proceso de descargas estés se cancele y te muestre error, desconecta el teléfono apagalo quita la pila, colocala nuevamente y enciendelo, cierra el Kies, abrelo nuevamente , conecta el teléfono e intenta de nuevo. en mi caso completo la descarga al tercer intento. :S&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;una vez termine la descarga el teléfono se reiniciara para entrar en “modo download” (pantalla negra con logo y letras de fondo azul) y el Kies comenzara a copiar los archivos descargados al teléfono, veras el proceso de copiado en el teléfono mediante una barra azul que se va llenando.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;una vez terminado, el teléfono se reiniciara nuevamente y ahora mostrara una pantalla negra con un logo de una cajita con una barra abajo que se va llenando (en mi caso no se lleno mucho), supongo que en este paso se instalan y aplican los archivos descargados. En este paso es probable que el Kies te diga que ya ha sido completada la actualización, pero Espera!!! no le hagas caso que el teléfono sigue haciendo algo, mantenlo conectado a la PC.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;cuando termine la instalación, (no demora mucho) el teléfono se reiniciara, cargara Android 2.1 Eclair, entraras en tu escritorio (el del teléfono) y eso sera todo :D&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Posibles problemas:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Bueno a pesar de que este método parece mas directo, corto y sencillo no es a prueba de errores.  en mi caso cuando termino la descarga de los archivos desde internet, y luego de que el teléfono se reiniciara para entrar en &lt;strong&gt;“Modo download”&lt;/strong&gt;  Windows comenzó a instalar unos drivers para reconocer el dispositivos y para remate me pidió reiniciar (ni loco iba yo a reiniciar en pleno proceso de actualización), luego de instalado el drivers y detectado el dispositivo el modem USB se desconecto (eyecto) al igual que el teléfono (quedándose este con el logo de Samsung en la pantalla) y el Kies me mostró un mensaje en el que decía que la actualización no podo ser completada y sugiriendo hacer una recuperación de emergencia. :O  en ese momento tenia las bolas en la garganta!!!!.&lt;/p&gt;

&lt;p&gt;En ese momento lo único que se me ocurrió fue terminar de desconectar el teléfono a la laptop, quitar la pila, volverla a colocar y encender el teléfono. Para mi alivio inicio normalmente y sin problemas a Android Cupcake  (si allí se bajaron las que te conté a su lugar LOOL ).  al cabo de un rato decidí volver a intentarlo, pero para mi sorpresa al  abrir el Kies este  me mostraba que había un intento de actualización que no se completo y me pedía que hiciera una &lt;strong&gt;“recuperación de emergencia”&lt;/strong&gt;  y me paso a mostrar los pasos para realizarla los cuales son simplemente colocar el teléfono uno mismo en &lt;strong&gt;“modo Download”&lt;/strong&gt; presionando las teclas Volumen abajo + Camara + End o Apagar estando apagado el teléfono y luego conectarlo a la PC y darle a “Recuperación de emergencia” en el Kies. Esto lo que hizo fue copiar al teléfono los archivos descargados, pero esta vez si los instalo y los aplico por lo que al cabo de unos segundos el teléfono se reinicio y entro a Android 2.1 Eclair :D&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Implementando una aplicacion Rails 3 en Cloudfoundry</title>
   <link href="http://blog.jam.net.ve/2011/08/15/implementa-una-aplicacion-rails-3-en-cloudfoundry"/>
   <updated>2011-08-15T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2011/08/15/implementa-una-aplicacion-rails-3-en-cloudfoundry</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://cloudfoundry.com/&quot;&gt;CloudFoundry&lt;/a&gt; es la plataforma abierta como proyecto de servicios iniciada por VMware la cual puede soportar múltiples frameworks, varios servicios cloud de algunos proveedores , y múltiples aplicaciones de servicios. todo esto en una plataforma escalable en la nube.&lt;/p&gt;

&lt;center&gt;&lt;a href=&quot;http://imgur.com/NLWkg&quot;&gt;&lt;img src=&quot;http://i.imgur.com/NLWkg.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/center&gt;

&lt;p&gt;Estos servicios están actualmente en version Beta, por lo que de momento son gratuitos pero se requiere de una invitación que puedes solicitar en la pagina de CloudFoundry. casualmente hoy me llego mi invitación (apenas la había pedido ayer) por lo me pude darle un vistazo rápido a la plataforma y hacer unas primeras pruebas.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;strong&gt;Instalación de VMC CLI y configuración:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Lo primero en que me di cuenta es que el servicio se administra mediante una CLI (Command Line Interface) o interfaz de linea de comandos (si todavía no tienes ni P!##@ idea, lo administras desde la terminal!!! ). que se &lt;strong&gt;instala&lt;/strong&gt; mediante una gema ruby llamada VMC (de VMware Cloud… creo!!!) por lo que tenemos que teclear en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;gem install vmc&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;luego de esto debemos ejecutar:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;vmc target api.cloudfoundry.com&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ahora podemos iniciar sesion en el servicio tecleando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;vmc login&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;colocamos nuestro dirección de correos, la contraseña &lt;strong&gt;temporal&lt;/strong&gt; que se nos envió con la invitación y tal cual dice la invitación, aprovechamos de cambiar la contraseña temporal por una fija tecleando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;vmc passwd&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Implementacion de una aplicación Rails 3:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;En mi caso yo use un sencillo blog con registro de usuarios usando la gema Devise. la aplicación no es gran cosa y usa Sqlite 3 como Base de datos.&lt;/p&gt;

&lt;p&gt;para esto me muevo en la terminal y entrar a la carpeta donde esta la aplicación, una vez alli tecleo en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;vmc push&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Esto nos hará una serie de preguntas:&lt;/p&gt;

&lt;p&gt;- Would you like to deploy from the current directory?:&lt;/p&gt;

&lt;p&gt;respondemos  &lt;strong&gt;Y&lt;/strong&gt; - si&lt;/p&gt;

&lt;p&gt;- Application Name: colocamos aqui el nombre de la apliacion&lt;/p&gt;

&lt;p&gt;- Application Deployed URL: ‘blogdevisejam.cloudfoundry.com’?&lt;/p&gt;

&lt;p&gt;nos muestra la URL a la cual podremos acceder y ver nuestra aplicacion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nota:&lt;/strong&gt; si no me equivoco las url son únicas, por lo que si ya existe una aplicación con la url que queremos usar, deberemos pensar en otra.&lt;/p&gt;

&lt;p&gt;- Detected a Rails Application, is this correct? [Yn]:&lt;/p&gt;

&lt;p&gt;nos descubrieron!!! pillaron que queremos subir una aplicacion rails, por lo que no le mentimos y contestamos &lt;strong&gt;Y.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;- Memory Reservation [Default:256M] (64M, 128M, 256M, 512M or 1G)&lt;/p&gt;

&lt;p&gt;respondemos 256M - podemos darle simplemente enter y tomara el valor por defecto el cual es 256M.&lt;/p&gt;

&lt;p&gt;Deja de preguntarnos vainas y comienza a instalar y configurar la aplicacion:&lt;/p&gt;

&lt;p&gt;&lt;img class=&quot;aligncenter&quot; title=&quot;Selección_065&quot; src=&quot;http://blog.jam.net.ve/imagenes/uploads/2011/08/Selección_065-300x102.jpg&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;102&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Y listo!!!&lt;/p&gt;

&lt;p&gt;podemos ir a la url indicada en el “cuestionario” y ver nuestra aplicación en ejecución.&lt;/p&gt;

&lt;p&gt;así de fácil :D&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/zm5RV&quot;&gt;&lt;img src=&quot;http://i.imgur.com/zm5RVs.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Claro esta, esto es solo el principio, aplicaciones mas complejas requieren configuraciones y pasos mas complejos.&lt;/p&gt;

&lt;p&gt;Cloudfoundry ademas de Rails (ruby) soporta aplicaciones Node.js (javascript del lado servidor), Spring (Java), Sinatra (Ruby) y Grails. se pueden usar bases de datos como MongoDB, Redis y MySQL.&lt;/p&gt;

&lt;p&gt;a simple vista tiene buena pinta el servicio, uno mas a la lista de hosting “de momento gratuito” que podemos  usar para probar aplicaciones en Internet. habría que esperar a que salga de la etapa beta, ver que otras características se agregan y demás.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Instalando Zsh y OhMyZsh en Linux</title>
   <link href="http://blog.jam.net.ve/2011/08/09/instalando-zsh-ohmyzsh-en-ubuntulinux"/>
   <updated>2011-08-09T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2011/08/09/instalando-zsh-ohmyzsh-en-ubuntulinux</id>
   <content type="html">&lt;p&gt;Extraído de Wikipedia:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ZSH:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Es un potente intérprete de comandos para sistemas operativos de tipo Unix, como por ejemplo los BSD o GNU/Linux.1 La primera versión de zsh fue escrita por Paul Falstad en 1990, cuando era estudiante en la Universidad de Princeton. Zsh se diseñó para poder usarse interactivamente. Se le han incorporado muchas de las características principales de otras shells de Unix como, bash, ksh, o tcshy además posee características propias originales&lt;/p&gt;
&lt;/blockquote&gt;

&lt;!-- more --&gt;

&lt;p&gt;Una de las características de Zsh que enamoran al usuario es su alta capacidad de personalización y ser compatible con Bash. pues bien estas dos características justamente son las que me hicieron probar por unos meses Zsh y luego usarla como Shell por defecto en mi PC y Laptop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OhMyZsh:&lt;/strong&gt; Es un framework impulsado por la comunidad para la administración de las configuraciones de Zsh, el cual le agrega características como auto-completado, corrección de escritura y viene con mas de 50 plugins opcionales que agregan aun mas funcionalidades a la shell. no conforme con esto también incluye la posibilidad de personalizar la forma en que se muestra tu shell y la información que esta muestre mediante themes que puedes crear tu mismo, o usar uno de los que incluye &lt;a title=&quot;OhMyZsh on Github&quot; href=&quot;https://github.com/robbyrussell/oh-my-zsh&quot;&gt;OhMyZsh&lt;/a&gt; (mas de 90).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instalación:&lt;/strong&gt; Para instalar Zsh en Ubuntu tan solo debemos ejecutar en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo aptitude install zsh&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;con esto ya tendremos instalado Zsh con las caracteristicas que vienen por defecto, pero como en este caso queremos es explotar sus capacidades de personalización necesitaremos instalar OhMyZsh.&lt;/p&gt;

&lt;p&gt;OhMyZsh se instala descargándolo desde su &lt;a href=&quot;https://github.com/robbyrussell/oh-my-zsh&quot;&gt;repositorio en GitHub&lt;/a&gt;, el autor ofrece un comando que automatiza la descarga e instalacion del mismo, pero para poder ejecutarlo necesitas tener instalado Git para clonar el repositorio, esto lo haces son un simple: &lt;strong&gt;sudo aptitude install&lt;/strong&gt; git una vez instalado Git puedes instalar OhMyZsh tecleando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; sh&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Con este comando se descargara &lt;a href=&quot;https://github.com/robbyrussell/oh-my-zsh&quot;&gt;OhMyZsh&lt;/a&gt; desde su repo en github y lo clonara en la carpeta ~/.oh-my-zsh de tu usuario, luego de eso podrás comenzar a usarlo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instalación Manual:&lt;/strong&gt; el metodo mas largo (la verdad no tanto) para instalar &lt;a href=&quot;https://github.com/robbyrussell/oh-my-zsh&quot;&gt;OhMyZsh&lt;/a&gt; es simple, tan solo clona el repositorio en una carpeta oculta llamada &lt;strong&gt;.oh-my-zsh&lt;/strong&gt; tecleando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;luego de esto creas tu archivo de configuracion &lt;strong&gt;.zshrc&lt;/strong&gt; copiando la plantilla que OhMyZsh trae por defecto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Por ultimo ajusta Zsh para que sea tu shell predeterminada:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;chsh -s /usr/bin/zsh&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;ya luego de esto solo debes reiniciar o abrir una nueva terminal para ver Zsh+OhMyZsh funcionando.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Personalización:&lt;/strong&gt; si vas a la carpeta ~/.oh-my-zsh/themes  y ~/.oh-my-zsh/plugins veras los themes y plugins disponibles para personalizar tu shell y activar nuevas funcionalidades.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Para activar y usar un plugins tan solo debes abrir con tu editor favorito el archivo ~/.zshrc y buscar la linea:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;plugins&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;git&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y agregar dentro de los paréntesis el nombre del plugins que quieres usar, por ejemplo en las ultimas actualizaciones de han agregado plugins como cloudapp el cual es una herramienta para subir imágenes desde la terminal  a el hosting de imagenes en getcloudapp.com que hasta donde se puede ver en la pagina solo ofrece soporte para MacOS, pero como dispone de una API, podemos usarlo tambien en Linux :P  asi que para agregarlo tan solo escribimos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;plugins&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;git cloudapp&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;Para activar y usar themes es similar a como hicimos para ctivar plugins. pero en vez de buscar la linea plugins, buscamos la linea:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;ZSH_THEME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;robbyrussell&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y cambiamos “robbyrussell” por el nombre del theme que quieras usar.&lt;/p&gt;

&lt;p&gt;yo en mi caso me hice mi &lt;a href=&quot;https://github.com/jesusangelm/Jam-Zsh-Theme&quot;&gt;propio theme&lt;/a&gt; modificando y combinando funciones de varios themes que vienen incluidos, mi theme lo llame “&lt;a href=&quot;https://github.com/jesusangelm/Jam-Zsh-Theme&quot;&gt;jam&lt;/a&gt;” por lo que en mi caso esta linea se ve asi:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;ZSH_THEME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;jam&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y mi shell se ve asi:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/GqNVC&quot;&gt;&lt;img src=&quot;http://i.imgur.com/GqNVCl.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Instalando RVM, Ruby y Rails en Linux.</title>
   <link href="http://blog.jam.net.ve/2011/05/17/instalando-rvm-ruby-rails-en-ubuntu"/>
   <updated>2011-05-17T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2011/05/17/instalando-rvm-ruby-rails-en-ubuntu</id>
   <content type="html">&lt;p&gt;Hace unos días atras estaba intentando instalar Ruby 1.9.2  desde los repositorios, como ya mi laptop tenia la versión 1.8.7 me di a la tarea de desinstalar por completo esta versión. Luego de terminal de instalar Ruby 1.9.2 y hacer la primera prueba, me encontré con que con que no había salido todo bien, algunas aplicaciones como Gem y Rake estaban buscando el ejecutable de Ruby 1.8.7 (que ya no estaba) y no el de Ruby 1.9.2.  Leyendo en internet encontré algunas posibles soluciones en las que sugerían crear enlaces simbólicos para que de este modo las aplicaciones que buscaran determinadas versiones de Ruby (1.8.7 en mi caso) usara la versión instalada (Ruby 1.9.2). asi lo hice, pero no fue la solución optima ya que muchas aplicaciones no estaban trabajando del todo bien y seguían mostrando algunos errores.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/zRyar&quot;&gt;&lt;center&gt;&lt;img src=&quot;http://i.imgur.com/zRyar.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/center&gt;&lt;/a&gt;&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;De vuelta a los buscadores,  intentando encontrar alguna forma de tener Ruby 1.9.2 + Rails 3.0.7 y demás acompañantes en su ultima versión trabajando en armonía y sin problemas, me tope con  &lt;a href=&quot;https://rvm.beginrescueend.com&quot;&gt;RVM&lt;/a&gt; (Ruby Version Manager) el cual es una aplicación de linea de comandos que nos permite instalar, administrar y poder trabajar con múltiples versiones (o sabores) de Ruby y otras aplicaciones en gemas. Esto quiere decir que si asi lo queremos podríamos tener instalado en nuestra computadora Ruby 1.8.7, Ruby 1.9.2, Rails 2.x, Rails 3.07  y usar en cualquier momento la version que mas nos convenga. En este caso yo instale Ruby 1.9.2 + Rails 3.0.7 En Ubuntu 10.10 64bits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instalación:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Si nos vamos a la guia de&lt;a href=&quot;https://rvm.beginrescueend.com/rvm/install/&quot; target=&quot;_blank&quot;&gt; instalación&lt;/a&gt; en la pagina oficial, lo primero que nos dice es que tenemos dos formas de instalación a elegir:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instalación para un solo usuario&lt;/strong&gt; es la mas comun, y la recomendada en la cual todo el contenido de RVM y la versión de Ruby y Gems a elegir estarán ubicadas en la carpeta del usuario que realice la instalación.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instalación multi-usuario (root)&lt;/strong&gt; este método es similar a como cuando instalas Ruby u otro paquete desde los repositorios usando privilegios de administrador, este metodo permise que todos los usuarios en el sistema puedan usar la instalacion de RVM y Ruby.&lt;/p&gt;

&lt;p&gt;Como yo soy el único que usa esta Laptop y tan solo quiero Ruby para aprender y hacer pruebas, me basta con la primera opción, ademas de que me da la ventaja de mantener mi configuración en caso de que decida reinstalar el S.O tan solo haciendo un respaldo de mi carpeta personal y luego restaurándola en otra PC.&lt;/p&gt;

&lt;p&gt;Para instalar RVM tecleamos en una terminal:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nota:&lt;/strong&gt; este comando requiere algunas dependencias instaladas, tan solo teclean &lt;strong&gt;sudo aptitude install build-essential git-core curl&lt;/strong&gt; en la terminal y luego continua con:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;bash &amp;lt;&amp;lt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;curl -s https://rvm.beginrescueend.com/install/rvm&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Esto nos descargara un script en bash (el cual recomiendan leer &lt;a href=&quot;https://rvm.beginrescueend.com/install/rvm&quot; target=&quot;_blank&quot;&gt;aqui&lt;/a&gt;) que luego es ejecutado por… ¡adivinen! :P  ¡si! por Bash. este script lo que hace es clonar RVM de su repositorio en &lt;a href=&quot;https://github.com/wayneeseguin/rvm&quot; target=&quot;_blank&quot;&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Una vez terminada la instalacion, el contenido de RVM se ubicara en la carpeta &lt;strong&gt;.rvm&lt;/strong&gt; que se encuentra dentro de tu carpeta de usuario &lt;strong&gt;~/ &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cargando RVM en tu sesion Shell como funcion:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Para que nuestra terminal pueda trabajar sin problemas con RVM debemos agregar la siguiente linea al archivo &lt;strong&gt;~/.bash_profile&lt;/strong&gt;, para esto tecleamos en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;[[ -s &amp;quot;$HOME/.rvm/scripts/rvm&amp;quot; ]] &amp;amp;&amp;amp; . &amp;quot;$HOME/.rvm/scripts/rvm&amp;quot; # Load RVM function&amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; ~/.bash_profile&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Recargando la configuración de Shell y primera prueba:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Cierra y abre tu terminal en uso, (o abre una nueva) y teclea en ella la siguiente linea para recargar la configuración nueva:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt; .bash_profile&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Luego teclea la siguiente linea para hacer una prueba y ver si todo esta trabajando bien:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;type &lt;/span&gt;rvm &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; head -1&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Si todo ha ido bien, nos deberia responder &lt;strong&gt;rvm: es una función&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ahora debemos verificar algunas otras dependencias a instalar antes de continuar:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;rvm notes&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Esto nos devuelve algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;Notes &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; Linux &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;DISTRIB_ID&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Ubuntu
&lt;span class=&quot;nv&quot;&gt;DISTRIB_RELEASE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;10.10
&lt;span class=&quot;nv&quot;&gt;DISTRIB_CODENAME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;maverick
&lt;span class=&quot;nv&quot;&gt;DISTRIB_DESCRIPTION&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Ubuntu 10.10&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

NOTE: &lt;span class=&quot;s1&quot;&gt;&amp;#39;ruby&amp;#39;&lt;/span&gt; represents Matz&lt;span class=&quot;s1&quot;&gt;&amp;#39;s Ruby Interpreter (MRI) (1.8.X, 1.9.X)&lt;/span&gt;
&lt;span class=&quot;s1&quot;&gt;             This is the *original* / standard Ruby Language Interpreter&lt;/span&gt;
&lt;span class=&quot;s1&quot;&gt;      &amp;#39;&lt;/span&gt;ree&lt;span class=&quot;s1&quot;&gt;&amp;#39;  represents Ruby Enterprise Edition&lt;/span&gt;
&lt;span class=&quot;s1&quot;&gt;      &amp;#39;&lt;/span&gt;rbx&lt;span class=&quot;s1&quot;&gt;&amp;#39;  represents Rubinius&lt;/span&gt;

&lt;span class=&quot;s1&quot;&gt;bash &amp;gt;= 3.2 is required&lt;/span&gt;
&lt;span class=&quot;s1&quot;&gt;curl is required&lt;/span&gt;
&lt;span class=&quot;s1&quot;&gt;git is required (&amp;gt;= 1.7 recommended)&lt;/span&gt;
&lt;span class=&quot;s1&quot;&gt;patch is required (for ree and some ruby-head&amp;#39;&lt;/span&gt;s&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;.

If you wish to install rbx and/or Ruby 1.9 head &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;MRI&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;eg. 1.9.2-head&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;,
&lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; you must install and use rvm 1.8.7 first.

If you wish to have the &lt;span class=&quot;s1&quot;&gt;&amp;#39;pretty colors&amp;#39;&lt;/span&gt; again,
  &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;export rvm_pretty_print_flag=1&amp;#39;&lt;/span&gt; in ~/.rvmrc.

dependencies:
&lt;span class=&quot;c&quot;&gt;# For RVM&lt;/span&gt;
  rvm: bash curl git

&lt;span class=&quot;c&quot;&gt;# For Ruby (MRI &amp;amp;amp; ree)  you should install the following OS dependencies:&lt;/span&gt;
  ruby: /usr/bin/apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev

&lt;span class=&quot;c&quot;&gt;# For JRuby (if you wish to use it) you will need:&lt;/span&gt;
  jruby: /usr/bin/apt-get install curl g++ openjdk-6-jre-headless
  jruby-head: /usr/bin/apt-get install ant openjdk-6-jdk

&lt;span class=&quot;c&quot;&gt;# In addition to ruby: dependencies,&lt;/span&gt;
  ruby-head: subversion

&lt;span class=&quot;c&quot;&gt;# For IronRuby (if you wish to use it) you will need:&lt;/span&gt;
  ironruby: /usr/bin/apt-get install curl mono-2.0-devel&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Si leemos detenidamente notamos que una de las dependencias de RVM es Bash, Curl y Git, pero no necesitaremos instalarla ya que de seguro lo hiciste cuando ejecutaste el comando junto a la primera nota antes de instalar RVM, de lo contrario no estarías aqui :P También podemos ver que hay dependencia de acuerdo a la simplemente de Ruby que deseamos usar, en mi caso usare Ruby (‘ruby’ represents Matz’s Ruby Interpreter (MRI) (1.8.X, 1.9.X)) el cual es el mas común ya uqe Jruby es una implementacion de Ruby+Java y Ironruby es implementacion de Ruby+plataforma .Net/Mono. por lo tanto las dependencias a instalar para Ruby serian:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo aptitude install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;¡Felicidades! ya has instalado RVM, pero todavia no hemos terminado…&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instalando Ruby + Rails:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Bien aquí viene la parte mas divertida, primero instalaremos Ruby, recuerden que en mi caso elegi la version 1.9.2 por lo que tecleo en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;rvm install 1.9.2&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Este proceso puede llevar algunos minutos ya que el comando descargara las fuentes de Ruby, las extraerá en la carpeta ~/.rvm , lo compilara y luego lo instalara.&lt;/p&gt;

&lt;p&gt;Una vez terminado el proceso deberás elegir la versión de Ruby a usar, en nuestro caso instalamos Ruby 1.9.2 por lo que tecleamos en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;rvm use 1.9.2&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Bien ahora a comprobar que hemos hecho todo bien, tecleamos en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;ruby -v&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;lo que nos deberá responder algo similar a: &lt;strong&gt;ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;comprobación extra:&lt;/strong&gt; si tecleamos el comando &lt;strong&gt;which ruby&lt;/strong&gt; podremos ver donde se encuentra el ejecutable de Ruby, en mi caso es: &lt;strong&gt;/home/angel/.rvm/rubies/ruby-1.9.2-p180/bin/ruby&lt;/strong&gt; Si hubiésemos instalado ruby desde los repos la ubicacion seria algo como &lt;strong&gt;/usr/bin/ruby&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Si queremos usar esta version de Ruby por defecto, deberemos teclear en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;rvm use 1.9.2 --default&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Pero hay algo que debemos corregir&lt;/strong&gt;, ya que si por ejemplo reiniciamos la PC y al entrar abrimos una terminal y tecleamos &lt;strong&gt;ruby -v&lt;/strong&gt; de seguro obtendremos un error que nos dira que no tenemos ruby instalado, ¡como que no si lo acabo de hacer!, para solventar esto abrimos con tu editor de texto favorito el archivo &lt;strong&gt;.bashrc&lt;/strong&gt; ubicado en tu carpeta de usuario &lt;strong&gt;~/.bashrc&lt;/strong&gt; y al final del archivo coloca la siguiente linea:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/.rvm/scripts/rvm&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ruby 1.9.2 incluye rubygems, asi que lo mas que podriamos hacer seria actualizar tecleando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;gem update --system&amp;lt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;revisamos la versión de gem tecleando &lt;strong&gt;gem -v&lt;/strong&gt; en la terminal&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instalación de Rails:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;gem install rails&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;verificamos la version de rails tecleando en la terminal &lt;strong&gt;rails -v&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Si eres de los que usas &lt;strong&gt;IRB&lt;/strong&gt; (Ruby Interactivo) de seguro al ejecutarlo te mostrara un mensaje de error referente a &lt;strong&gt;readline&lt;/strong&gt;, ademas en IRB no podras mover el cursor entre los caracteres y/o no tendrás auto-completado. Para solucionar esto tecleamos en la terminal estos tres comandos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; .rvm/src/ruby-1.9.2-p180/ext/readline/
ruby extconf.rb
make install&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Para verificar abre de nuevo IRB, si todo ha salido bien, notaras que puedes mover el cursor entre los caracteres y tendrás auto-completado.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mejora Extra en IRB:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;si deseas tener coloreado en IRB instala las gemas wirble y hirb:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;gem install wirble hirb&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Luego abre el archivo &lt;strong&gt;.irbrc&lt;/strong&gt; ubicado en tu carpeta de usuario &lt;strong&gt;~/.irbrc&lt;/strong&gt; (crealo si no existe) y agrega lo siguiente:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;rubygems&amp;#39;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;wirble&amp;#39;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;hirb&amp;#39;&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Wirble&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;init&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Wirble&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;colorize&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# hirb (active record output format in table)&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Hirb&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;View&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;enable&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# IRB Options&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;IRB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;conf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:AUTO_INDENT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;IRB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;conf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:SAVE_HISTORY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;IRB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;conf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:EVAL_HISTORY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Log to STDOUT if in Rails&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;include?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;RAILS_ENV&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;amp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;amp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;const_defined?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;RAILS_DEFAULT_LOGGER&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;logger&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;RAILS_DEFAULT_LOGGER&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Logger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;STDOUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;#IRB.conf[:USE_READLINE] = true&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;# Display the RAILS ENV in the prompt&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# ie : [Development]&amp;amp;gt;&amp;amp;gt;&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;IRB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;conf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:PROMPT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:CUSTOM&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;ss&quot;&gt;:PROMPT_N&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;[&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;RAILS_ENV&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;capitalize&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;]&amp;amp;gt;&amp;amp;gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
   &lt;span class=&quot;ss&quot;&gt;:PROMPT_I&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;[&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;RAILS_ENV&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;capitalize&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;]&amp;amp;gt;&amp;amp;gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
   &lt;span class=&quot;ss&quot;&gt;:PROMPT_S&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
   &lt;span class=&quot;ss&quot;&gt;:PROMPT_C&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;?&amp;amp;gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
   &lt;span class=&quot;ss&quot;&gt;:RETURN&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;=&amp;gt;; %s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;&lt;/span&gt;
   &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# Set default prompt&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;IRB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;conf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:PROMPT_MODE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:CUSTOM&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# We can also define convenient methods (credits go to thoughtbot)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# def me&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#  User.find_by_email(&amp;quot;me@gmail.com&amp;quot;)&amp;lt;/pre&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Bien esto es todo, ya queda de tu parte instalar las gemas que mas uses y adaptarlo de acuerdo a tus necesidades. :)&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Mongoengine un ODM para conectar a MongoDB desde Python</title>
   <link href="http://blog.jam.net.ve/2011/01/14/mongoengine-un-odm-para-conectar-a-mongodb-desde-python"/>
   <updated>2011-01-14T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2011/01/14/mongoengine-un-odm-para-conectar-a-mongodb-desde-python</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://mongoengine.org/&quot;&gt;MongoEngine&lt;/a&gt; es un ODM (Object Document Mapper) que nos permite mapear la estructura de nuestra base de datos a objetos en nuestras aplicaciones &lt;a href=&quot;http://blog.jam.net.ve/tag/python/&quot;&gt;Python&lt;/a&gt; que se conectan a instancias &lt;a href=&quot;http://blog.jam.net.ve/tag/mongodb/&quot;&gt;MongoDB&lt;/a&gt;, esto con el fin de poder usar la informacion en nuestra base de datos somo si se tratasen de un objeto. Esto nos ofrece la ventaja de que podemos escribir de una manera mas comoda nuestra aplicacion, definir un esquema para la base de datos y mejorar nuestro codigo, entre otras ventajas mas.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Para instar MongoEngine en Linux tan solo debemos escribir en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo easy_install mongoengine&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Nota:&lt;/strong&gt; debido a que MongoEngine usa el driver PyMongo para conectar nuestras aplicaciones Python a bases de datos NoSQL MongoDB, es capaz de detectar si tenemos o no instalado el driver PyMongo, por lo que si no lo tenemos instalado MongoEngine lo instalara automaticamente. De todos modos puedes instalar PyMongo de forma separada tecleando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo easy_install pymongo&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Si leyeron mi articulo anterior sobre &lt;a href=&quot;http://blog.jam.net.ve/2011/01/12/ejemplo-de-consulta-mapreduce-en-mongodb/&quot;&gt;Ejemplos de Consultas Map/Reduce en MongoDB&lt;/a&gt; de seguro habran leido que al final del articulo mencionaba que en especifico esa consulta map/reduce podriamos mejorarla y hacerlas de una forma mas sencilla y sin funciones JavaScript si usaramos un ODM, pues bien MongoEngine es uno de los ODM con los que podemos mejorar el codigo de la aplicacion RegistroDeTransferencias.&lt;/p&gt;

&lt;p&gt;Usando el ODM MongoEngine nuestra aplicacion quedaria similar a esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c&quot;&gt;#! /usr/bin/env python&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;mongoengine&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;datetime&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;time&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Rsubida&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;subida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FloatField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;fecha_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;StringField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;hora_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;StringField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Rbajada&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;bajada&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FloatField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;fecha_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;StringField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;hora_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;StringField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Conectando a la Base de datos en la instancia Local&amp;quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#Conectando a la instancia MongoDB local en la base de datos &amp;quot;bdregistrotransgerenciamdb&amp;quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;connect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;bdregistrotransgerenciamdb&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;la_subida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;Introdusca la cantidad de datos Enviados: &amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;la_bajada&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;Introdusca la cantidad de datos Recibidos: &amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;fecha&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;today&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;fechaagregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fecha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strftime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%d&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;-%m-%y&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;horaagregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strftime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;%I:%M %p&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Los datos ingresados son:&amp;quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Subida: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;la_subida&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Bajada: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;la_bajada&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Fecha Agregado &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fechaagregado&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Hora Agregado &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;horaagregado&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;respuesta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Estos datos son correctos? introdusca solo (s/n): &amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;respuesta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;s&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;regsubida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Rsubida&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;subida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;la_subida&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fecha_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fechaagregado&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hora_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;horaagregado&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;regbajada&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Rbajada&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bajada&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;la_bajada&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fecha_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fechaagregado&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hora_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;horaagregado&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

 &lt;span class=&quot;n&quot;&gt;regsubida&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;save&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;regbajada&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;save&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Registros de Subida y Bajada ALMACENADOS con Exito!&amp;quot;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Cancelado!!!&amp;quot;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#Algunas consultas&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;respuesta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Deseas ver algunas consultas? introdusca solo (s/n): &amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;respuesta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;s&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;#Mostrando todos los registros de bajada en la coleccion&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rbajada&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Rbajada&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Bajada: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbajada&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bajada&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

 &lt;span class=&quot;c&quot;&gt;#Sumatoria de todos los registros de bajada :)&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Total datos Bajada: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Rbajada&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;bajada&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot; MB&amp;quot;&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Total datos Subida: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Rsubida&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;subida&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot; MB&amp;quot;&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;tbajada&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Rbajada&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;bajada&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;tsubida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Rsubida&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;subida&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tbajada&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tsubida&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Total Consumido: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;total&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot; MB&amp;quot;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Cancelado!&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Como podemos ver en las primeras lineas del codigo, creamos dos clases llamadas &lt;strong&gt;Rsubida&lt;/strong&gt; y &lt;strong&gt;Rbajada&lt;/strong&gt;, estas clases contienen lo que es la estructura y tipo de datos de lo que contendran nuestros documentos. De esta forma podemos establecer un esquema predeterminado para la informacion que se almacenara en nuestra base de datos. Cabe destacar tambien que por cada clase que se crea, MongoEngine generara una coleccion correspondiente en la base de datos, por lo que en en este ejemplo nuestra base de datos contendra dos colecciones &lt;strong&gt;rsubida&lt;/strong&gt; que contendra los registros de subida y &lt;strong&gt;rbajada &lt;/strong&gt;que contendra los registros de bajada.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consultas:&lt;/strong&gt; Aqui esta la parte que mas nos interesa, si nos fijamos en todo el codigo, no vemos por ningun lado las funciones JavaScript Map/Reduce, esto es porque simplemente no las necesitamos para realizar especificamente las consultas que ya teniamos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c&quot;&gt;#Mostrando todos los registros de bajada en la coleccion&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rbajada&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Rbajada&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Bajada: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbajada&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bajada&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;el ejemplo de salida de esta seccion del codigo seria algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;Bajada: 36.3
Bajada: 123.0
Bajada: 66.4&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Esta seccion del codigo nos mostrara los registros de bajadas que estan contenido en el campo bajada, notese que en esta ocacion no nos devuelve un documento JSON con los datos solicitados (incluyendo su corchetes y comillas), sino que simplemente nos devuelve el valor en especifico.&lt;/p&gt;

&lt;p&gt;La seccion del codigo con la que sustituimos las consultas map/reduce y su codigo en javascript es la siguiente:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Total datos Bajada: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Rbajada&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;bajada&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot; MB&amp;quot;&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Total datos Subida: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Rsubida&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;subida&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot; MB&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;lo que nos devolvera algo como:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;Total datos Bajada: 225.7 MB
Total datos Subida: 142.3 MB&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Coo vez aqui estamos aprovechando una de los beneficios de usar un ODM, y usar el contenido de nuestra base de datos como si de simples objetos se tratasen ya que con simplemente elegir la clase Rbajada y seleccionando su atributo (variable) “bajada” y haciendo uso del metodo sum() podremos realizar la sumatoria de todo los registros de bajada en en la coleccion Rbajada. Todo esto sin usar map/reduce ni funciones javascript :P&lt;/p&gt;

&lt;p&gt;Con esto podemos completar la aplicacion y mostrar el total consumido, es decir, la suma de los datos de subida con los datos de bajada.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;n&quot;&gt;tbajada&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Rbajada&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;bajada&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;tsubida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Rsubida&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;subida&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tbajada&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tsubida&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Total Consumido: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;total&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot; MB&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;los que nos muestra:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;Total Consumido: 368.0 MB&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Como vemos, un ODM nos puede facilitar mucho la vida y mejorar nuestras aplicaciones, ademas de acortar un poco el codigo ya que si se fijan. hay muchas menos lineas y mas funciones que la version anterior de la aplicacion que no usa MongoEngine.&lt;/p&gt;

&lt;p&gt;Esta aplicacion planeo mejorarla cada vez mas mientras continue aprendiendo sobre Python y MongoDB por loq eu e puesto a disposicion su codigo en &lt;a href=&quot;http://github.com/jesuangelm/RegistroDeTransferencias_Mdb_Meng&quot;&gt;GitHub&lt;/a&gt; para los que quieran descargarlo o solo si les parece util. :)&lt;/p&gt;

&lt;p&gt;Saludos y espero les sirva!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Ejemplos de consultas MapReduce en MongoDB</title>
   <link href="http://blog.jam.net.ve/2011/01/12/ejemplo-de-consulta-mapreduce-en-mongodb"/>
   <updated>2011-01-12T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2011/01/12/ejemplo-de-consulta-mapreduce-en-mongodb</id>
   <content type="html">&lt;p&gt;Hace unos articulos atras les mostre un ejemplo de como podriamos usar Python y el driver PyMongo para almacenar informacion en MongoDB, el ejemplo que vimos fue mi aplicacion de &lt;a href=&quot;http://blog.jam.net.ve/2011/01/10/almacenando-datos-en-mongodb-desde-python/&quot;&gt;RegistroDeTransferencias&lt;/a&gt;. Al final de dicho articulo  explico como podriamos ver y consultar los datos almacenados usando la consola interactiva de MongoDB, pero… ¿y si queremos que sea la misma aplicacion que nos muestre algunas consultas?. Pues a eso vamos, en este articulo haremos que RegistroDeTransferencias nos muestre el total de datos de subida y bajada.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Para que nuestra aplicacion nos muestre esta informacion necesitamos crear dos funciones &lt;strong&gt;Map/Reduce&lt;/strong&gt; escritas en JavaScript.&lt;/p&gt;

&lt;p&gt;La funcion &lt;strong&gt;Map&lt;/strong&gt; para los datos de &lt;strong&gt;subida&lt;/strong&gt; seria algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;nx&quot;&gt;ms&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Code&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;&amp;quot;&amp;quot;function() {&lt;/span&gt;
&lt;span class=&quot;s2&quot;&gt; emit(&amp;quot;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Subida&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;, this.subida);&lt;/span&gt;
&lt;span class=&quot;s2&quot;&gt; }&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y su funcion Reduce seria algo como:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;rs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; Code&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;&amp;quot;&amp;quot;function(k, v) {&lt;/span&gt;
&lt;span class=&quot;s2&quot;&gt; var i, sum = 0;&lt;/span&gt;
&lt;span class=&quot;s2&quot;&gt; for (i in v) {&lt;/span&gt;
&lt;span class=&quot;s2&quot;&gt; sum += v[i];&lt;/span&gt;
&lt;span class=&quot;s2&quot;&gt; }&lt;/span&gt;
&lt;span class=&quot;s2&quot;&gt; return sum;&lt;/span&gt;
&lt;span class=&quot;s2&quot;&gt; }&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Nota&lt;/strong&gt; Para que el metodo &lt;strong&gt;Code()&lt;/strong&gt; que contiene las funciones &lt;strong&gt;Map/Reduce&lt;/strong&gt; funcione es necesario hacer uso del modulo &lt;strong&gt;BSON&lt;/strong&gt; e importar &lt;strong&gt;Code&lt;/strong&gt;, por lo que al inicio del archivo debemos agregar lo siguiente:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;bson.code&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Code&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;En la funcion &lt;strong&gt;Map (ms)&lt;/strong&gt; lo que hara sera seleccionarnos todos registros del campo &lt;strong&gt;subida&lt;/strong&gt; en nuestra coleccion y emitirlos como parametro &lt;strong&gt;VALUE&lt;/strong&gt;, mientras que la funcion &lt;strong&gt;Reduce (rs)&lt;/strong&gt; recibira como parametro en  la &lt;strong&gt;KEY VALUE (v)&lt;/strong&gt; los registros de &lt;strong&gt;subida&lt;/strong&gt; que seleccionamos en nuestra funcion &lt;strong&gt;Map&lt;/strong&gt; y a continuacio en una secuencia for, sumara todos los valores de subida existentes, lo que nos devolvera el total de subida.&lt;/p&gt;

&lt;p&gt;Para ejecutar nuestras funciones Map/Reduce y hacer que nos genere y muestre la informacion que solicitamos debemos agregar en nuestra aplicacion lo siguiente:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Sumatoria de SUBIDA&amp;quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;resultado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;colsubida&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;map_reduce&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ms&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;subida&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;resultado&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;subida&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Como podemos ver, se elige la coleccion colsubida que contiene los registros de subida y a continuacion usamos el metodo &lt;strong&gt;map_reduce()&lt;/strong&gt; pasandole como parametro nuestras funciones &lt;strong&gt;Map (ms)&lt;/strong&gt; y funcion &lt;strong&gt;Reduce (rs)&lt;/strong&gt;. Luego de esto la recorremos en un for y mostramos el resultado.&lt;/p&gt;

&lt;p&gt;De forma similar podriamos usar otra funcion &lt;strong&gt;Map/Reduce&lt;/strong&gt; para mostrar el total de bajada, si modificamos el codigo de la aplicacion RegistroDeTransferencias y añadimos lo que hemos visto, nos quedaria algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pymongo&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;datetime&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;time&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;bson.code&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Code&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Conectando al Servidor de Base de Datos Local...&amp;quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;conexion&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Connection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Conexion local por defecto&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#conexion = Connection(&amp;quot;usuario:contraseña@servidor.com:27075/basededato&amp;quot;) #Conexion a un servidor remoto&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#creando/obteniendo un objeto que referencie a la base de datos.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;db&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;conexion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;bdregistrodetransferencias&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;#base de datos a usar&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#creando/obteniendo un objeto que referencie a la coleccion.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;colbajada&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;db&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;bajada&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;#coleccion con registros de bajada&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;colsubida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;db&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;subida&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;#coleccion con registros de subida&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#solicitando los datos de subida y bajada&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;la_subida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;Introdusca la cantidad de datos Enviados: &amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;la_descarga&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;Introdusca la cantidad de datos Recibidos: &amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# obteniendo la fecha, hora y almacenandolas en variables.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;fecha&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;today&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;fecha_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fecha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strftime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%d&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;-%m-%y&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;hora_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strftime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;%I:%M %p&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Los datos ingresados son:&amp;quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Subida: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;la_subida&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Bajada: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;la_descarga&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Fecha Agregado &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fecha_agregado&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Hora Agregado &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hora_agregado&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;respuesta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Estos datos son correctos? introdusca solo (s/n): &amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;respuesta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;s&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#creando el diccionario con los documentos de subida y bajada&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;registrobajada&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;bajada&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;la_descarga&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;fecha_agregado&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fecha_agregado&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;hora_agregado&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hora_agregado&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;registrosubida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;subida&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;la_subida&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;fecha_agregado&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fecha_agregado&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;hora_agregado&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hora_agregado&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#insertando los datos en la BD&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;colbajada&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;insert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;registrobajada&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;colsubida&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;insert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;registrosubida&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;Documento Guardado con EXITO!&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Cancelado!!!&amp;quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;respuesta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Deseas ver la sumatoria de subida/bajada? (s/n): &amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;respuesta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;s&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;ms&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Code&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&amp;quot;&amp;quot;function() {&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; emit(&amp;quot;Subida&amp;quot;, this.subida);&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; }&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

 &lt;span class=&quot;n&quot;&gt;rs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Code&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&amp;quot;&amp;quot;function(k, v) {&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; var i, sum = 0;&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; for (i in v) {&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; sum += v[i];&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; }&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; return sum;&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; }&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

 &lt;span class=&quot;n&quot;&gt;mb&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Code&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&amp;quot;&amp;quot;function() {&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; emit(&amp;quot;Bajada&amp;quot;, this.bajada);&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; }&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

 &lt;span class=&quot;n&quot;&gt;rb&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Code&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&amp;quot;&amp;quot;function(k, v) {&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; var i, sum = 0;&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; for (i in v) {&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; sum += v[i];&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; }&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; return sum;&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt; }&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Sumatoria de SUBIDA&amp;quot;&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;resultado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;colsubida&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;map_reduce&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ms&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

 &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;subida&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;resultado&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;subida&lt;/span&gt;

 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Sumatoria de BAJADA&amp;quot;&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;resultado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;colbajada&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;map_reduce&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

 &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bajada&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;resultado&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bajada&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Cancelado!!!&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Al ejecutar la aplicacion y responder afirmativamente a la pregunta “Deseas ver la sumatoria de subida/bajada? (s/n): “ veremos algo similar a esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;Deseas ver la sumatoria de subida/bajada? &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;s/n&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;: s
Sumatoria de SUBIDA
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;u&lt;span class=&quot;s1&quot;&gt;&amp;#39;_id&amp;#39;&lt;/span&gt;: u&lt;span class=&quot;s1&quot;&gt;&amp;#39;Subida&amp;#39;&lt;/span&gt;, u&lt;span class=&quot;s1&quot;&gt;&amp;#39;value&amp;#39;&lt;/span&gt;: 126.10999999999999&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
Sumatoria de BAJADA
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;u&lt;span class=&quot;s1&quot;&gt;&amp;#39;_id&amp;#39;&lt;/span&gt;: u&lt;span class=&quot;s1&quot;&gt;&amp;#39;Bajada&amp;#39;&lt;/span&gt;, u&lt;span class=&quot;s1&quot;&gt;&amp;#39;value&amp;#39;&lt;/span&gt;: 805.0&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Como vemos, no es muy dificil realizar consultas &lt;strong&gt;Map/Reduce&lt;/strong&gt; en MongoDB, aunque comparandola a como lo haciamos en CouchDB es un tanto mas largo y posiblemente engorroso.&lt;/p&gt;

&lt;p&gt;Lo bueno de esto es que, esta misma consulta podriamos realizarla tal cual, hacer que nos devuelva unicamente solo numeros y no un documento JSON ({u’_id’: u’Subida’, u’value’: 126.10999999999999}) si usamos un ODM :D y lo mejor,  sin usar funciones Map/Reduce lo que hara tambien que nuestra aplicacion tenga menos lineas de codigo… Pero esto se los mostrare proximamente :P&lt;/p&gt;

&lt;p&gt;Saludos y espero les sirva!.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Instalando RockMongo interfaz de administracion web para MongoDB</title>
   <link href="http://blog.jam.net.ve/2011/01/11/instalando-rockmongo-interfaz-de-administracion-web-para-mongodb"/>
   <updated>2011-01-11T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2011/01/11/instalando-rockmongo-interfaz-de-administracion-web-para-mongodb</id>
   <content type="html">&lt;p&gt;En el mundo de las bases de datos relacionales, una de las formas mas usadas para administrar una base de datos es usando una interfaz web, esto sobretodo si el usuario no cuenta con un acceso shell a su cuenta de hosting. En las bases de datos relacionales por lo general se usa aplicaciones escritas en PHP como phpMyAdmin para MySQL y phpPgAdmin para PostgreSQL.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/ZgBVN&quot;&gt;&lt;img src=&quot;http://i.imgur.com/ZgBVNl.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bien en el mundo de las bases de datos NoSQL hay aplicaciones web similares, una de ellas es &lt;a href=&quot;https://code.google.com/p/rock-php/&quot;&gt;RockMongo&lt;/a&gt; la cual esta escrita en PHP y posee una interfaz bastante intuitiva y un tanto similar a phpMyAdmin. Instalar RockMongo es sumamente sencillo y al estar escrita en PHP lo unico que requerimos es tener instalado y corriendo un servicio web como Nginx, Apache o similares, el lenguaje PHP y el driver correspondiente para accesar a MongoDB desde PHP.&lt;/p&gt;

&lt;p&gt;Bien por suerte hace unos dias explique &lt;a href=&quot;http://blog.jam.net.ve/2011/01/04/instalando-nginx-con-soporte-php5-en-ubuntu/&quot;&gt;como instalar Nginx con soporte PHP5 en Ubuntu&lt;/a&gt;, por lo que siguiendo dicho articulo tendremos mas de medio camino listo! (¡Todos mis articulos estan friamente calculados! jajajaja :P ). Nos queda nada mas instalar el driver PHP para MongoDB y descargar e instalar RockMongo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instalando el Driver MongoDB y PHP:&lt;/strong&gt; Bien para instalar este driver tan solo abrimos una terminal y escribimos en ella:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo pecl install mongo&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;esto nos instalara el driver para poder acceder a MongoDB desde PHP, ahora debemos configurar nuestro archivo &lt;strong&gt;php.ini &lt;/strong&gt;y agregar la siguiente linea:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;extension&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;mongo.so&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Nota:&lt;/strong&gt; si seguiste mi articulo sobre &lt;a href=&quot;blog.jam.net.ve/2011/01/04/instalando-nginx-con-soporte-php5-en-ubuntu/&quot;&gt;como instalar Nginx con soporte PHP5 en Ubuntu&lt;/a&gt;, en la carpeta &lt;strong&gt;/etc/php5&lt;/strong&gt; encontraras varios archivos &lt;strong&gt;php.ini&lt;/strong&gt;, el que debemos editar sera aquel que se encuentre dentro de la carpeta &lt;strong&gt;fpm&lt;/strong&gt;, es decir la ruta del archivo seria algo como &lt;strong&gt;/etc/php5/fpm/php.ini&lt;/strong&gt; ¿porque editamos especificamente este archivo? pues simple, porque siguiendo ese tutorial estamos corriendo PHP mediante &lt;strong&gt;FastCGI&lt;/strong&gt; usando PHP5-FPM, de todos modos y si asi lo deseas, puedes agregar la linea en las demas archivos php.ini sin problemas.&lt;/p&gt;

&lt;p&gt;luego de editar el archivo php.ini debemos reiniciar PHP5-FPM para que los cambios tengan efecto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo service php5-fpm restart&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ahora nos queda instalar RockMongo, para esto tan solo debemos &lt;a href=&quot;https://code.google.com/p/rock-php/downloads/list&quot;&gt;descargar&lt;/a&gt; la ultima version desde la pagina oficial. Al momento de escirbir esto la ultima version es la 1.0.11 con buenas mejoras como traduccion al Español, insertar y modificar documentos en formato JSON (en versiones anteriores habia que escribir los documentos en arrays PHP).&lt;/p&gt;

&lt;p&gt;una ves descargardo, lo descomprimimos y obtendremos una carpeta llamada &lt;strong&gt;rockmongo&lt;/strong&gt; la cual debemos copiar en la raiz de nuestro servidor web, en nustro caso debemos copiar dicha carpeta en &lt;strong&gt;/var/www&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nota:&lt;/strong&gt; recuerda que el directorio &lt;strong&gt;/var/www&lt;/strong&gt; por lo general pertenece a root (administrador) por lo que necesitaras privilegios de administrador para copiar la carpeta rockmongo dicho directorio.&lt;/p&gt;

&lt;p&gt;si lo deseas puedes abrir con tu editor favorito y ver el archivo config.php, encontraremos algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-php&quot; data-lang=&quot;php&quot;&gt;&lt;span class=&quot;x&quot;&gt;$MONGO[&amp;quot;servers&amp;quot;] = array(&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt; array(&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt; &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;localhost&amp;quot;, // Replace your MongoDB host ip or domain name here&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt; &amp;quot;port&amp;quot; =&amp;gt; &amp;quot;27017&amp;quot;, // MongoDB connection port&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt; &amp;quot;username&amp;quot; =&amp;gt; null, // MongoDB connection username&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt; &amp;quot;password&amp;quot; =&amp;gt; null, // MongoDB connection password&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt; &amp;quot;auth_enabled&amp;quot; =&amp;gt; true,//Enable authentication, set to &amp;quot;false&amp;quot; to disable authentication&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt; &amp;quot;admins&amp;quot; =&amp;gt; array(&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt; &amp;quot;admin&amp;quot; =&amp;gt; &amp;quot;admin&amp;quot;, // Administrator&amp;#39;s USERNAME =&amp;gt; PASSWORD&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt; //&amp;quot;iwind&amp;quot; =&amp;gt; &amp;quot;123456&amp;quot;,&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt; ),&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;como ves, RockMongo nos permite configurarlo para conectarse a instancias locales o remotas de MongoDB, asi como tambien ver y cambiar los datos de usuario y contraseña del admin para iniciar sesion en Rockmongo. Si dejamos el archivo tal como esta, rockmongo se conectara a nuestra instancia local de mongodb y usaremos para iniciar sesion em rockmongo el nombre de usuario “admin”  y contraseña “admin”.&lt;/p&gt;

&lt;p&gt;Bien ya tenemos instalado y configurado RockMongo y ya podemos comenzar a usarlo, tan solo debemos ingresar en nuestro navegador y escirbir en la barra de direcciones:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;http://localhost/rockmongo&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;luego de loguearte como admin veras algo como esto:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/gMehz&quot;&gt;&lt;img src=&quot;http://i.imgur.com/gMehzs.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nota:&lt;/strong&gt; es probable que al teclear esta direccion en el navegador no veas nada o veas un error, es posible que requieras darle los permisos de lectura-escritura-ejecucion necesarios a la carpeta rockmongo y sus archivos.&lt;/p&gt;

&lt;p&gt;tecleando el comando estando ubicado en &lt;strong&gt;/var/www&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo chmod &lt;span class=&quot;m&quot;&gt;777&lt;/span&gt; rockmongo/*&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;te podria sacar del apuro, pero ojo no es lo mas recomendable en un servidor.&lt;/p&gt;

&lt;p&gt;Bien ya con esto tienes instalado y funcionando RockMongo por lo que ya puedes usarlo para “jugar” con MongoDB. Por supuesto este no es la unica interfaz de administracion para MongoDB, existen muchas otras como FangOfMongo la cual esta programada en Python y Django, pero en mis pruebas no me convencio mucho. Existen tambien phpMoAdmin la cual es bastante liviana y viene escrita en tan solo 1 archivo .php, pero la interfaz no me parece muy intuitiva, ademas de ser extremadamente simple. Si conocer las demas Gui de Administarcion ta solo visita la documentacion oficial de &lt;a href=&quot;http://www.mongodb.org/display/DOCS/Admin+UIs&quot;&gt;MongoDB&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Saludos y espero les sirva :D&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Almacenando datos en MongoDB desde Python</title>
   <link href="http://blog.jam.net.ve/2011/01/10/almacenando-datos-en-mongodb-desde-python"/>
   <updated>2011-01-10T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2011/01/10/almacenando-datos-en-mongodb-desde-python</id>
   <content type="html">&lt;p&gt;Mas NoSQL :D … luego de ver como &lt;a href=&quot;http://blog.jam.net.ve/2010/12/13/instalando-couchdbkit-y-almacenando-datos-en-couchdb-desde-python/&quot;&gt;almacenabamos informacion en CouchDB desde una aplicacion en Python&lt;/a&gt;, veremos como hacer lo mismo pero esta vez enviando los datos a una base de datos MongoDB.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/ZgBVN&quot;&gt;&lt;img src=&quot;http://i.imgur.com/ZgBVNl.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Para este caso usaremos la misma aplicacion de &lt;a href=&quot;http://blog.jam.net.ve/2010/12/23/programando-una-aplicacion-de-registrodetransferencias-en-python-y-couchdb/&quot;&gt;RegistroDeTransferencias&lt;/a&gt; que programe anteriormente y que almacena los datos en CouchDB, solo que esta vez modificare el codigo para que almacene la informacion en MongoDB. :P&lt;/p&gt;

&lt;p&gt;Para poder conectar nuestras aplicaciones Python a MongoDB y que estas utilicen dicha base de datos NoSQL para almacenar la informacion necesitamos del driver correspondiente el cual se llama &lt;a href=&quot;http://api.mongodb.org/python&quot;&gt;PyMongo&lt;/a&gt;. Para instalar el driver para python en Ubuntu lo haremos de forma similar a como lo hicimos con CouchDB usando  Easy_Install, para esto abrimos una terminal y escribimos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo easy_install pymongo&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ya con esto tendremos instalado Pymongo y podremos comenzar a usarlo para que nuestras aplicaciones en python se conecten a MongoDB.&lt;/p&gt;

&lt;p&gt;Como les decia, la aplicacion que usaremos en este ejemplo es mi aplicacion de &lt;strong&gt;RegistroDeTransferencias&lt;/strong&gt; que programe anteriormente y que almacena los datos en CouchDB, pero luego de hacerle unos pequeños cambios pasara a almacenar la informacion en MongoDB. La aplicacion se compone de un simple archivo llamado &lt;strong&gt;rdtmongo.py&lt;/strong&gt; y el codigo es el siguiente:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pymongo&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;datetime&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;time&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Conectando al Servidor de Base de Datos Local...&amp;quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;conexion&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Connection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Conexion local por defecto&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#conexion = Connection(&amp;quot;usuario:contraseña@servidor.com:27075/basededato&amp;quot;) #Conexion a un servidor remoto&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#creando/obteniendo un objeto que referencie a la base de datos.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;db&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;conexion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;bdregistrodetransferencias&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;#base de datos a usar&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#creando/obteniendo un objeto que referencie a la coleccion.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;colbajada&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;db&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;bajada&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;#coleccion con registros de bajada&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;colsubida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;db&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;subida&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;#coleccion con registros de subida&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#solicitando los datos de subida y bajada&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;la_subida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;Introdusca la cantidad de datos Enviados: &amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;la_descarga&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;Introdusca la cantidad de datos Recibidos: &amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# obteniendo la fecha, hora y almacenandolas en variables.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;fecha&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;today&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;fecha_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fecha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strftime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%d&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;-%m-%y&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;hora_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strftime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;%I:%M %p&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Los datos ingresados son:&amp;quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Subida: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;la_subida&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Bajada: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;la_descarga&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Fecha Agregado &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fecha_agregado&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Hora Agregado &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hora_agregado&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;respuesta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Estos datos son correctos? introdusca solo (s/n): &amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;respuesta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;s&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#creando el diccionario con los documentos de subida y bajada&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;registrobajada&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;bajada&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;la_descarga&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;fecha_agregado&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fecha_agregado&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;hora_agregado&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hora_agregado&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;registrosubida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;subida&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;la_subida&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;fecha_agregado&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fecha_agregado&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;hora_agregado&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hora_agregado&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#insertando los datos en la BD&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;colbajada&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;insert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;registrobajada&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;colsubida&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;insert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;registrosubida&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;Documento Guardado con EXITO!&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Cancelado!!!&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Como ven es una aplicacion super sencilla y basica, en este ejemplo yo separe los registros de subida y bajada en en dos colecciones &lt;strong&gt;subida&lt;/strong&gt; y &lt;strong&gt;bajada&lt;/strong&gt; almacenadas en la base de datos &lt;strong&gt;bdregistrodetransferencias&lt;/strong&gt; de esta forma los registros en la base de datos quedan mejor organizados y nos ayuda a la hora de buscar o consultar un documento.&lt;/p&gt;

&lt;p&gt;Para ejecutar esta aplicacion en la terminal tan solo tecleamos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;python rdtmongo.py&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y veremos algo como esto&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/3yw6W&quot;&gt;&lt;img src=&quot;http://i.imgur.com/3yw6Wl.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Si nos vamos a la consola interactiva de MongoDB y nos movemos a la base de datos bdregistrodetransferencias:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;use bdregistrodetransferencias&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;podremos ver las colecciones tecleando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;show collections&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;tambien podremos ver todos los documentos de la coleccion &lt;strong&gt;subida&lt;/strong&gt; y &lt;strong&gt;bajada&lt;/strong&gt; teclando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;db.subida.find&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;db.bajada.find&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;respectivamente, lo cual nos devolvera algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;_id&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ObjectId&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;4d2150de5ff0885b8b000001&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;subida&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;2.9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;fecha_agregado&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;03-01-11&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;hora_agregado&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;12:00 AM&amp;quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;_id&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ObjectId&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;4d2164dd5ff0887868000001&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;subida&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;7.02&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;fecha_agregado&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;03-01-11&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;hora_agregado&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;01:25 AM&amp;quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;_id&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ObjectId&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;4d2221855ff0884395000001&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;subida&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;5.57&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;fecha_agregado&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;03-01-11&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;hora_agregado&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;02:50 PM&amp;quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;_id&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ObjectId&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;4d22b1505ff08829ab000001&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;subida&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;11.4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;fecha_agregado&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;04-01-11&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;hora_agregado&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;01:04 AM&amp;quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Por supuesto podriamos ejecutar consultas simples para visualizar los datos de subida y bajada o consultas Map/Reduce para calcular un total de datos de subida o bajada consumidos, pero eso se los mostrare proximamente :D&lt;/p&gt;

&lt;p&gt;Tambien has estado probando MongoDB ??? ya has realizado una aplicacion??? cuentanos tu experiencia con MongoDB!!!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Usos basicos de MongoDB Console</title>
   <link href="http://blog.jam.net.ve/2011/01/09/usos-basicos-de-mongodb-console"/>
   <updated>2011-01-09T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2011/01/09/usos-basicos-de-mongodb-console</id>
   <content type="html">&lt;p&gt;Y seguimos con mas pruebas de &lt;a href=&quot;http://blog.jam.net.ve/category/nosql/&quot;&gt;NoSQL&lt;/a&gt; :D … Hace unos dias comentaba como &lt;a href=&quot;http://blog.jam.net.ve/2011/01/03/instalando-mongodb-en-ubuntu/&quot;&gt;instalar MongoDB en Ubuntu 10.10&lt;/a&gt;, ahora veremos algunos usos basicos de la consola de administracion que incluye MongoDB para almacenar informacion, hacer algunas consultas entre otras tareas administrativas.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/ZgBVN&quot;&gt;&lt;img src=&quot;http://i.imgur.com/ZgBVNl.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Para acceder a la consola administrativa de MongoDB tan solo debemos escribir en la teminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;mongo&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;esto nos devolvera:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;MongoDB shell version: 1.6.5
connecting to: &lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Al hacer esto ejecutaremos la consola de MongoDB la cual por defecto intenta conectarse a la instancia MongoDB local (en tu PC) por lo que conviene tener MongoDB ejecutandoce con anterioridad. Cuando arrancamos la consola de esta manera y sin parametros, la misma se conecta a una base de datos llamada “&lt;strong&gt;test&lt;/strong&gt;” en la que podemos hacer nustras primeras pruebas, esto lo podemos comprobar ejecutando el siguiente comando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;db&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;lo cual nos devolvera el nombre de la base de datos en la qeu estamos la cual es &lt;strong&gt;test&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creando/Usando una base de datos&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;Para crear la nueva base de datos llamada “pruebas” tan solo debemos escribir el siguiente comando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;use pruebas&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;esto nos devolvera algo como:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&amp;gt; use pruebas
switched to db pruebas&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Este comando creara la base de datos “pruebas” y nos movera hacia ella, una detalle en este comando es que si por ejemplo la base de datos ya existe, tan solo nos mueve hacia ella para poder usarla, en caso de no existir la base de dato, el sistema la crea.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creando Colecciones e insertando documentos:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Como les comentaba en el articulo “&lt;a href=&quot;http://blog.jam.net.ve/2011/01/03/instalando-mongodb-en-ubuntu/&quot;&gt;instalando MongoDB en Ubuntu&lt;/a&gt;“  MongoDB es una base de datos del tipo documentos en la que almacena dichos  documentos en una especie de agrupaciones conocidas como colecciones, estas colecciones vendrian siendo algo asi como las tablas en MySQL.&lt;/p&gt;

&lt;p&gt;Para crear una coleccion llamada “&lt;strong&gt;prueba01&lt;/strong&gt;” y y almacenar documentos en ella podemos usar el siguiente comando de ejemplo:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;db.prueba01.insert&lt;span class=&quot;o&quot;&gt;({&lt;/span&gt;titulo: &lt;span class=&quot;s2&quot;&gt;&amp;quot;Primera prueba&amp;quot;&lt;/span&gt;, contenido: &lt;span class=&quot;s2&quot;&gt;&amp;quot;Mi primera prueba de insercion de un documento&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;})&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;en donde:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;prueba01&lt;/strong&gt; es el nombre de la coleccion donde se encuentra el documento.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;{titulo: “Primera prueba”, contenido: “Mi primera prueba de insercion de un documento”} &lt;/strong&gt;es el documento que estamos insertando en la coleccion.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Podemos añadir mas documentos en formato JSON con campos iguales o diferentes al que  acabamos de añadir y estos seran almacenados sin ningun problema, justamente esta es una de las ventajas de las bases de datos NoSQL.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;db.prueba01.insert&lt;span class=&quot;o&quot;&gt;({&lt;/span&gt;titulo: &lt;span class=&quot;s2&quot;&gt;&amp;quot;Segunda prueba&amp;quot;&lt;/span&gt;, contenido: &lt;span class=&quot;s2&quot;&gt;&amp;quot;Mi segunda prueba de insercion de un documento&amp;quot;&lt;/span&gt;, hora: &lt;span class=&quot;s2&quot;&gt;&amp;quot;03:20 PM&amp;quot;&lt;/span&gt;, fecha: &lt;span class=&quot;s2&quot;&gt;&amp;quot;9/01/2011&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;})&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Mostrar los documentos almacenados en una coleccion:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Para ver todos los documentos almacenados en nuestra coleccion &lt;strong&gt;prueba01&lt;/strong&gt; podemos usar el siguiente comando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;db.prueba01.find&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;lo cual nos devolvera algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;_id&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ObjectId&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;4d2a1f5f9d3ceffc299d0fad&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;titulo&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Primera prueba&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;contenido&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Mi primera prueba de insercion de un documento&amp;quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;_id&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ObjectId&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;4d2a223b9d3ceffc299d0fae&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;titulo&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Segunda prueba&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;contenido&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Mi segunda prueba de insercion de un documento&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;hora&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;03:20 PM&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;fecha&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;9/01/2011&amp;quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;en nuestro caso solo hemos almacenado dos documento y esto es lo unico que nos muestra. pero si por ejemplo queremos ver solo un resultado podemos ejecutar el siguiente comando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;db.prueba01.findOne&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;el cual nos devolvera algo como:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;s2&quot;&gt;&amp;quot;_id&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ObjectId&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;4d2a1f5f9d3ceffc299d0fad&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
 &lt;span class=&quot;s2&quot;&gt;&amp;quot;titulo&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Primera prueba&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
 &lt;span class=&quot;s2&quot;&gt;&amp;quot;contenido&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Mi primera prueba de insercion de un documento&amp;quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Listando las bases de datos:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Si queremos obtener un listado de las bases de datos que estan en nuestra instancia MongoDB tan solo tecleamos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;show dbs&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y esto nos mostrara las bases de datos que tenemos… en nuestro caso puede devolvernos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&amp;gt; show dbs
admin
&lt;span class=&quot;nb&quot;&gt;local&lt;/span&gt;
pruebas
&lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Listando las colecciones en una base de datos:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Para obtener un listado de las colecciones almacenadas en la base de datos en la que nos encontramos podemos teclear:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;show collections&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;el cual nos devolvera&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&amp;gt;show collections
perros
prueba01&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Consultas “super basicas”:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;usando el comando &lt;strong&gt;db.prueba01.find()&lt;/strong&gt; podemos realizar una consulta sencilla pasandole al metodo &lt;strong&gt;find()&lt;/strong&gt; un parametro el cual sera un documento, este documento sera una especie de ejemplo de lo que queremos que sea buscado. Por ejemplo si queremos que se nos muestre el documento en donde esta contenida la Key/Value &lt;strong&gt;“hora” : “03:20 PM”&lt;/strong&gt; podemos pasarle eso mismo como documento:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;db.prueba01.find&lt;span class=&quot;o&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;hora&amp;quot;&lt;/span&gt; : &lt;span class=&quot;s2&quot;&gt;&amp;quot;03:20 PM&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;})&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;esto nos devolvera el segundo documento que añadimos hace un rato y en el cual contiene el campo hora : 03:20 PM:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;db&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;prueba01&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;hora&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;03:20 PM&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;_id&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ObjectId&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;4d2a223b9d3ceffc299d0fae&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;titulo&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Segunda prueba&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;contenido&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Mi segunda prueba de insercion de un documento&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;hora&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;03:20 PM&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;fecha&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;9/01/2011&amp;quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Por supuesto, esta es una consulta super basica, MongoDB incluye muchas maneras de realizar consultas de este tipo (pasando un documento JSON como parametro), pero uno de los metodos mas potentes es usando funciones &lt;strong&gt;Map/Reduce&lt;/strong&gt; un tanto parecido a como se hace en CouchDB.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Eliminando documentos:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Para eliminar un documento podemos realizarlo de manera similar a como hicimos la consulta anterior, es decir pasar un documento JSON como parametro a una funcion, solo que en este caso la funcion se llama &lt;strong&gt;remove()&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;db.prueba01.remove&lt;span class=&quot;o&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;hora&amp;quot;&lt;/span&gt; : &lt;span class=&quot;s2&quot;&gt;&amp;quot;03:20 PM&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;})&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Este comando nos elimino el documento que contenia el campo “hora” : “03:20 PM” de la coleccion. prueba a realizar la consulta anterior y veras que ya no aparece dicho documento en la coleccion.&lt;/p&gt;

&lt;p&gt;Por supuesto MongoDB y su consola interactiva tiene muchas otras caracteristicas y funciones que requeririan un libro entero para ser explicada en detalle.&lt;/p&gt;

&lt;p&gt;como complemento podemos usar el comando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;help&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;para visualizar un listado de comandos que podemos usar en la consola MongoDB.&lt;/p&gt;

&lt;p&gt;Si deseas aprender mas sobre MongoDB visita:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://www.mongodb.org/display/DOCSES/Vistazo+a+la+consola+interactiva+MongoDB&quot;&gt;Vistaso a la consola interactiva MongoDB&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://www.mongodb.org/display/DOCSES/Operaciones+DBA+desde+la+consola&quot;&gt;Operaciones DBA desde la consola&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://www.mongodb.org/display/DOCSES/Referencia+de+la+consola+%28dbshell%29&quot;&gt;Referencias de la consola.&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://www.mongodb.org/display/DOCSES/Consultar&quot;&gt;Consultas.&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Instalando Nginx con soporte PHP5 en Ubuntu</title>
   <link href="http://blog.jam.net.ve/2011/01/04/instalando-nginx-con-soporte-php5-en-ubuntu"/>
   <updated>2011-01-04T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2011/01/04/instalando-nginx-con-soporte-php5-en-ubuntu</id>
   <content type="html">&lt;p&gt;Hace unos meses atras escribi un articulo en el que explicaba como &lt;a href=&quot;http://blog.jam.net.ve/2010/02/16/instalando-nginx-en-centos/&quot;&gt;Instalar Nginx en CentOS&lt;/a&gt;,  en aquellos tiempos tenia el servidor dedicado con CentOS en el que hacia las pruebas.  Ahora les paso a explicar como instalar el servicio web &lt;a href=&quot;http://nginx.org/&quot;&gt;Nginx&lt;/a&gt; con soporte para PHP5 (a travez de &lt;a href=&quot;http://php-fpm.org/&quot;&gt;PHP-FPM&lt;/a&gt; - Administrador de procesos FastCGI ) en &lt;a href=&quot;http://blog.jam.net.ve/category/ubuntu/&quot;&gt;Ubuntu&lt;/a&gt; 10.10 y asi tener un servidor web local para hacer pruebas con PHP, instalar algun CMS, instalar alguna interfaz de administracion para &lt;a href=&quot;http://blog.jam.net.ve/tag/mongodb/&quot;&gt;MongoDB&lt;/a&gt; :P , etc.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/hn3A1&quot;&gt;&lt;img src=&quot;http://i.imgur.com/hn3A1.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Para esto lo primero que debemos hacer es instalar Nginx tecleando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo aptitude install nginx&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;con esto tendremos el servidor web Nginx instalado y funcionando en Ubuntu. Lo podemos comprobar escribiendo en el navegador:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;http://localhost&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Es probable que veas un mensaje &lt;strong&gt;404 Not Found &lt;/strong&gt;y esto es porque en Ubuntu 10.10 el directorio raiz de Nginx por defecto es &lt;strong&gt;/var/www &lt;/strong&gt;y alli no hay ningun &lt;strong&gt;index.html&lt;/strong&gt;, sino que esta en &lt;strong&gt;/var/www/nginx-default&lt;/strong&gt; .  Para solucionar esto copia el contenido de este ultimo directorio en &lt;strong&gt;/var/www&lt;/strong&gt; y entra de nuevo en &lt;strong&gt;http://localhost&lt;/strong&gt; Ahora si veras la pagina de Bienvenida de Nginx.&lt;/p&gt;

&lt;p&gt;Ahora debemos instalar PHP5, PHP5-FPM y algunos extras, mas para esto teclamos en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo aptitude install php5-cgi php5-fpm php5-dev php5-curl php5-cli php5-imagick php5-sqlite php-pear&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Con esto ya deberiamos tener instalado PHP5 y ejecutandose PHP5-FPM (PHP5 sobre FastCGI).&lt;/p&gt;

&lt;p&gt;Ahora nos queda configurar un poco Nginx para que pueda dar soporte PHP sobre FastCGI&lt;/p&gt;

&lt;p&gt;Para esto debemos abrir el archivo de configuracion de sitios en Nginx y modificarlo un poco, lo abrimos con Vim teclando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo vim /etc/nginx/sites-available/default&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y lo modificamos para que se vea como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-apache&quot; data-lang=&quot;apache&quot;&gt;&lt;span class=&quot;c&quot;&gt;# You may add here your&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# server {&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#    ...&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# }&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# statements for each of your virtual hosts&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;server&lt;/span&gt; {

 &lt;span class=&quot;nb&quot;&gt;listen&lt;/span&gt;   &lt;span class=&quot;m&quot;&gt;80&lt;/span&gt;; ## listen for ipv4
 &lt;span class=&quot;nb&quot;&gt;listen&lt;/span&gt;   [::]:80 default ipv6only=on; ## listen for ipv6

 &lt;span class=&quot;nb&quot;&gt;server_name&lt;/span&gt;  localhost;

 &lt;span class=&quot;nb&quot;&gt;access_log&lt;/span&gt;  &lt;span class=&quot;sx&quot;&gt;/var/log/nginx/localhost.access.log&lt;/span&gt;;

 &lt;span class=&quot;nb&quot;&gt;location&lt;/span&gt; / {
 &lt;span class=&quot;nb&quot;&gt;root&lt;/span&gt;   &lt;span class=&quot;sx&quot;&gt;/var/www&lt;/span&gt;;
 &lt;span class=&quot;nb&quot;&gt;index&lt;/span&gt;  index.php index.html index.htm;
 &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;

 &lt;span class=&quot;nb&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;sx&quot;&gt;/doc&lt;/span&gt; {
 &lt;span class=&quot;nb&quot;&gt;root&lt;/span&gt;   &lt;span class=&quot;sx&quot;&gt;/usr/share&lt;/span&gt;;
 &lt;span class=&quot;nb&quot;&gt;autoindex&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;on&lt;/span&gt;;
 &lt;span class=&quot;nb&quot;&gt;allow&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;127.0.0.1&lt;/span&gt;;
 &lt;span class=&quot;nb&quot;&gt;deny&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;all&lt;/span&gt;;
 &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;

 &lt;span class=&quot;nb&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;sx&quot;&gt;/images&lt;/span&gt; {
 &lt;span class=&quot;nb&quot;&gt;root&lt;/span&gt;   &lt;span class=&quot;sx&quot;&gt;/usr/share&lt;/span&gt;;
 &lt;span class=&quot;nb&quot;&gt;autoindex&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;on&lt;/span&gt;;
 &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;

 &lt;span class=&quot;c&quot;&gt;#error_page  404  /404.html;&lt;/span&gt;

 &lt;span class=&quot;c&quot;&gt;# redirect server error pages to the static page /50x.html&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;#&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;#error_page   500 502 503 504  /50x.html;&lt;/span&gt;
 &lt;span class=&quot;nb&quot;&gt;location&lt;/span&gt; = &lt;span class=&quot;sx&quot;&gt;/50x.html&lt;/span&gt; {
 &lt;span class=&quot;nb&quot;&gt;root&lt;/span&gt;   &lt;span class=&quot;sx&quot;&gt;/var/www&lt;/span&gt;;
 &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;

 &lt;span class=&quot;c&quot;&gt;# proxy the PHP scripts to Apache listening on 127.0.0.1:80&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;#&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;#location ~ \.php$ {&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;#proxy_pass   http://127.0.0.1;&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;#}&lt;/span&gt;

 &lt;span class=&quot;c&quot;&gt;# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;#&lt;/span&gt;
 &lt;span class=&quot;nb&quot;&gt;location&lt;/span&gt; ~ \.php$ {
 &lt;span class=&quot;nb&quot;&gt;fastcgi_pass&lt;/span&gt;   &lt;span class=&quot;m&quot;&gt;127.0.0.1&lt;/span&gt;:9000;
 &lt;span class=&quot;nb&quot;&gt;fastcgi_index&lt;/span&gt;  index.php;
 &lt;span class=&quot;nb&quot;&gt;fastcgi_param&lt;/span&gt;  SCRIPT_FILENAME  &lt;span class=&quot;sx&quot;&gt;/var/www&lt;/span&gt;$fastcgi_script_name;
 &lt;span class=&quot;nb&quot;&gt;include&lt;/span&gt; fastcgi_params;
 &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;

 &lt;span class=&quot;c&quot;&gt;# deny access to .htaccess files, if Apache&amp;#39;s document root&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;# concurs with nginx&amp;#39;s one&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;#&lt;/span&gt;
 &lt;span class=&quot;nb&quot;&gt;location&lt;/span&gt; ~ /\.ht {
 &lt;span class=&quot;nb&quot;&gt;deny&lt;/span&gt;  &lt;span class=&quot;k&quot;&gt;all&lt;/span&gt;;
 &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;La parte mas importante de todo es el bloque &lt;strong&gt;location ~ .php$&lt;/strong&gt; …  en el que se especifica como Nginx va a trabajar con FastCGI.&lt;/p&gt;

&lt;p&gt;Una vez realizado esto reiniciamos Nginx con:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo service nginx restart&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Para comprobar que Nginx trabaja perfectamente con PHP5 nos vamos al directorio /var/www y con nano agregamos  el archivo info.php:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo vim info.php&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;en dicho archivo agregamos lo siguiente:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-php&quot; data-lang=&quot;php&quot;&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
	&lt;span class=&quot;nb&quot;&gt;phpinfo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;span class=&quot;x&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Lo guardamos, cerramos y en el navegador escribimos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;http://localhost/info.php&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;si todo a ido bien veremos algo como esto:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/RBYxA&quot;&gt;&lt;img src=&quot;http://i.imgur.com/RBYxAl.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bien ya tienes instalado Nginx con soporte PHP5 mediante FastCGI (php5-fpm) :P&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Ejemplos de vistas-consultas en CouchDB</title>
   <link href="http://blog.jam.net.ve/2010/12/26/ejemplos-de-vistasconsultas-en-couchdb"/>
   <updated>2010-12-26T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2010/12/26/ejemplos-de-vistasconsultas-en-couchdb</id>
   <content type="html">&lt;p&gt;Continuando con mis practicas y articulos sobre CouchDB traigo ahora algunos ejemplos de vistas/consultas para mostrar nuestros datos almacenados, recordemos que en CouchDB las vistas se crean usando funciones escritas en el lenguaje JavaScript, aunque se puede usar otros lenguajes como Ruby, Python, etc mediante plugins.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/EUNoH&quot;&gt;&lt;img src=&quot;http://i.imgur.com/EUNoH.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Las vistas que crearemos a continuacion sera para consultar y organizar los datos almacenados por la &lt;a href=&quot;http://blog.jam.net.ve/2010/12/23/programando-una-aplicacion-de-registrodetransferencias-en-python-y-couchdb/&quot;&gt;aplicacion RegistroDeTransferencias&lt;/a&gt; la cual explique hace unos dias, por lo que recomiendo que primero sigas dicho articulo antes de continuar para que asi no estes tan perdido.&lt;/p&gt;

&lt;p&gt;Como comentaba anteriormente cuando programaba la &lt;a href=&quot;http://blog.jam.net.ve/2010/12/23/programando-una-aplicacion-de-registrodetransferencias-en-python-y-couchdb/&quot;&gt;aplicacion de RegistroDeTransferencias&lt;/a&gt;, la misma almacenaba en CouchDB los datos de &lt;strong&gt;subida&lt;/strong&gt; y &lt;strong&gt;bajada&lt;/strong&gt; transferidos durante una sesion, ademas de almacenar tambien la &lt;strong&gt;fecha&lt;/strong&gt; y &lt;strong&gt;hora&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Para crear vistas en CouchDB primero debemos ingresar en Futon, seleccionar nuestra base de datos y luego en el listbox “&lt;strong&gt;View&lt;/strong&gt;” de la parte superior derecha seleccionar “&lt;strong&gt;Temporary view…&lt;/strong&gt;”  Una vez alli veremos una seccion llamada “&lt;strong&gt;View Code&lt;/strong&gt;” la cual contiene dos cajas de textos, una llamada “&lt;strong&gt;Map Function&lt;/strong&gt;” en donde escribiremos la mayoria de nuestras funciones Map para crear vistas, y otra caja de texto llamada “&lt;strong&gt;Reduce Function&lt;/strong&gt;” en donde podremos escribir funciones Reduce que filtren, realicen operaciones u organicen mejor los datos seleccionados por las funciones Map, Estas funciones Reduce son opcionales y no son estrictamente necesarias a menos que algun caso especial las requiera. si te fijas bien ya esta escrito una funcion en la caja de texto Map, esta es uan funcion de ejemplo muy basica que luego de presionar el boton “&lt;strong&gt;Run&lt;/strong&gt;” nos mostrara en el campo “&lt;strong&gt;Value&lt;/strong&gt;” todos los documentos en la base de datos&lt;/p&gt;

&lt;p&gt;Una vista sencilla que podriamos programar podria ser por ejemplo aquella en la que me muestre todos los registros de &lt;strong&gt;bajada&lt;/strong&gt; organizado por &lt;strong&gt;fecha&lt;/strong&gt; y &lt;strong&gt;hora&lt;/strong&gt;. Esta vista la podriamos hacer escribiendo lo siguiente en el textbox de las funciones Map:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;emit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;fecha_agregado&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;hora_agregado&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;bajada&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Esta funcion nos devolvera algo como esto:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/lrc6l&quot;&gt;&lt;img src=&quot;http://i.imgur.com/lrc6ll.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Como podemos ver, en el campo Key (llave) nos muestra la fecha y hora en la que se tomo el documento y en el campo Value (valor) nos muestra los datos de &lt;strong&gt;bajada&lt;/strong&gt; para cada documento en la base de datos. de forma similar podemos crear una vista para mostrar los valores de &lt;strong&gt;subida&lt;/strong&gt;. Esta funcion nos sirve por ejemplo para ver cuantos datos nos descargamos en X dia.&lt;/p&gt;

&lt;p&gt;Una de las bellezas de CouchDB es que estas vistas podemos almacenarlas en la misma base de datos para asi consultarla cuando lo queramos sin necesidad de volver a escribir la misma funcion :D esto lo hacemos haciendo click en el boton “&lt;strong&gt;Save As…&lt;/strong&gt;” y en “&lt;strong&gt;Desing document:&lt;/strong&gt;” colocamos un nombre cualquiera que nos identifique el uso de esas consultas (algo asi como una categoria de consultas), por ejemplo: “&lt;strong&gt;vista_subida-bajada&lt;/strong&gt;” y en “&lt;strong&gt;View Name:&lt;/strong&gt;” colocamos el nombre de la vista que acabamos de escribir, por ejemplo: “&lt;strong&gt;bajada&lt;/strong&gt;”.&lt;/p&gt;

&lt;p&gt;Otro ejemplo de vistas que podemos crear es una en la que por ejemplo muestre unicamente los datos de subida (en el campo Key) y bajada (en el campo Value), esta vista la podriamos ver escribiendo lo siguiente en el campo Map Function:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;emit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Subida&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;subida&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Bajada&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;bajada&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Esto nos devolvera algo como:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/kDt7I&quot;&gt;&lt;img src=&quot;http://i.imgur.com/kDt7Il.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Como podemos ver se le a agregado la leyenda Subida y Bajada junto a los datos de subida y bajada para asi identificarlos mejor.&lt;/p&gt;

&lt;p&gt;Bien hasta ahora hemos usado dos sencillas funciones Map pero ninguna combinada con una funcione Reduce, bien es hora de ver como son estas fuciones y un ejemplo de uso de las mismas. :D&lt;/p&gt;

&lt;p&gt;Una vista que podriamos escribir usando funciones Map y Reduce podria ser aquella en la que nos muestre el valor total de datos de bajada, esto se haria por ejemplo selecionando todos los documentos con la llave bajada y luego haciendo una sumatoria de sus valores, la funcion &lt;strong&gt;Map&lt;/strong&gt; seria algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;emit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;bajada&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;bajada&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y la funcion Reduce seria algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;rereduce&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Esto nos mostrara algo como esto:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/tMWkk&quot;&gt;&lt;img src=&quot;http://i.imgur.com/tMWkkl.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Como vemos solo nos devuelve una sola fila con la leyenda Bajada en el campo Key y en el campo Value nos muestra la suma total de los datos de &lt;strong&gt;bajada&lt;/strong&gt;; 2.498Mb :O y mi plan es de 3000Mb estoy casi qeu sin internet :( LOL.&lt;/p&gt;

&lt;p&gt;Este mismo ejemplo podemos usarlo para calcular el consumo total de &lt;strong&gt;subida&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Por ultimo podriamos hacer una modificacion a la ultima funcion para mostrar y calcular de una sola vez y en una misma vista los datos tanto de subida como de bajada :P&lt;/p&gt;

&lt;p&gt;la funcion Map seria algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;emit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;subida&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;subida&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;emit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;bajada&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;bajada&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Y la funcion Reduce seria algo como:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;rereduce&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Esto nos mostrara algo como:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/8fOzE&quot;&gt;&lt;img src=&quot;http://i.imgur.com/8fOzEl.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Como podemos observar esto nos mostrara dos filas en la que vemos el total de datos de &lt;strong&gt;subida&lt;/strong&gt; como el total de datos de &lt;strong&gt;bajada &lt;/strong&gt;en el campo Value ademas de su respectiva leyenda en el campo Key.&lt;/p&gt;

&lt;p&gt;Bien esto es todo por el momento pero no es para nada complejo ya que estas mismas vistas las podemos usar desde la aplicacion RegistroDeTransferencia para que sea desde ella misma donde hagamos las consultas previamente creadas y asi no tener que estar visitando Futon cada vez que queramos ver y consultar nuestra informacion en la base de datos, pero eso es algo en lo que estoy practicando y aprendiendo asi que por lo tanto se los muestrare en otra ocasion :D&lt;/p&gt;

&lt;p&gt;Saludos&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Programando una aplicacion de registrodetransferencias en Python y CouchDB</title>
   <link href="http://blog.jam.net.ve/2010/12/23/programando-una-aplicacion-de-registrodetransferencias-en-python-y-couchdb"/>
   <updated>2010-12-23T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2010/12/23/programando-una-aplicacion-de-registrodetransferencias-en-python-y-couchdb</id>
   <content type="html">&lt;p&gt;Una de las ventajas de ser programador es que puedes escribir uno mismo sus aplicaciones para resolver un problema determinado que se tenga, y pues yo tenia un problema :D . Resulta que mi unica conexion a internet es mediante un Modem USB, estos modem vienen con un software que solo funciona bajo Windows (algunos funcionan en MacOS) que te permite llevar un registro de las transferencias de datos consumidas y asi saber cuando estas a punto de consumirte tu cuota mensual de datos. Pues como solo uso &lt;a href=&quot;http://blog.jam.net.ve/category/linux/&quot;&gt;Linux&lt;/a&gt; estos registros los llevava era en notas (tomboy) escribiendo los datos de subida y bajada que consumia despues de desconectarme.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/EUNoH&quot;&gt;&lt;img src=&quot;http://i.imgur.com/EUNoH.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Este metodo que usaba me era un tanto engorroso y no era muy fiable ya que mas de una vez perdi algunas notas o las borraba accidentalmente. Luego de aprender las funciones mas basicas de CouchDB, Python y Couchdbkit se me ocurrio escribir una aplicacion de consola que me facilite el registro de mis transferencias y que los almacene en un entorno confiable.&lt;/p&gt;

&lt;p&gt;Ya les e comentado &lt;a href=&quot;http://blog.jam.net.ve/2010/12/12/instalando-couchdb-en-ubuntu/&quot;&gt;como instalar CouchDB en Ubuntu&lt;/a&gt; y tambien como &lt;a href=&quot;http://blog.jam.net.ve/2010/12/13/instalando-couchdbkit-y-almacenando-datos-en-couchdb-desde-python&quot;&gt;instalar Couchdbkit y programar la primera aplicacion basica&lt;/a&gt;, por lo que  si todavia no has instalado Couchdb y/o no tienes instalado Couchdbkit deberas pasar por estos articulos antes de continuar.&lt;/p&gt;

&lt;p&gt;Como les decia, esta aplicacion de &lt;strong&gt;RegistroDeTransferencias&lt;/strong&gt; es super basica y no es nada del otro mundo programarla. Al igual que la aplicacion anterior de Lista de Contactos  esta estara escrita en Python y usara el framework Couchdbkit para gestionar la conexion con la base de datos CouchDB.&lt;/p&gt;

&lt;p&gt;Esta aplicacion que se ejecuta desde la terminal solicitara los datos de subida y bajada transferidos (en Mb), luego los mostrara para verificar que sean correctos y luego tras confirmar se almacenaran en CouchDB.  Al verificar en Futon (la interfaz de Administracion web de couchdb) los documentos creados ademas de ver los datos de subida y bajada previamente introducidos, veremos la fecha y hora en la que se almaceno ese documento. Estos dos ultimos datos se obtienen automaticamente desde la PC usando los modulos time y datetime de Python.  Esta aplicacion esta conformada por dos archivos: &lt;strong&gt;registrodetransferencias.py&lt;/strong&gt; y &lt;strong&gt;registrodetransferenciasapp.py&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;El contenido de &lt;strong&gt;registrodetransferencias.py&lt;/strong&gt; es:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;couchdbkit.schema&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Document&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;couchdbkit.schema.properties&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;registrodetransferencias&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;subida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FloatProperty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;bajada&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FloatProperty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;fecha_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;StringProperty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;hora_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;StringProperty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Y el Contenido de &lt;strong&gt;registrodetransferenciasapp.py&lt;/strong&gt; es:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c&quot;&gt;#Importando los modulos necesarios&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;datetime&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;registrodetransferencias&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;registrodetransferencias&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;couchdbkit&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;time&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Conectando al Servidor de Base de Datos...&amp;quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#Creando el objeto &amp;quot;Servidor&amp;quot; y colocando los datos de conexion&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Server&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;http://usuario:contrasena@localhost:5984&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#Creando/Accesando a la base de dato (no tengo muy claro esto&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#pero al parecer el metodo se encarga de verificar que la base&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#de datos ya exista, si existe crea una session y se conecta&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#si no existe crea la base de datos.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;db&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_or_create_db&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;bdregistrodetransferencias&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;la_subida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;Introdusca la cantidad de datos Enviados: &amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;la_descarga&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;Introdusca la cantidad de datos Recibidos: &amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Los datos ingresados son:&amp;quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Subida: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;la_subida&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Bajada: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;la_descarga&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;respuesta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Estos datos son correctos? introdusca solo (s/n): &amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;respuesta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;s&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#Asocia &amp;quot;Bookmark&amp;quot; a la base de datos (NPI LOL)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;registrodetransferencias&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_db&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;db&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;fecha&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;today&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#Los datos del documento a guardar.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;registro&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;registrodetransferencias&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;subida&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;la_subida&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;bajada&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;la_descarga&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;fecha_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fecha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strftime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%d&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;-%m-%y&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;hora_agregado&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strftime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;%I:%M %p&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;Guardando el documento al Servidor CouchDB...&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#guargando el documento&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;registro&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;save&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;Documento Guardado con EXITO!&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Cancelado!!!&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Nota:&lt;/strong&gt; no se mucho de programacion en Python (estoy aprendiendo) y tengo fallas en programacion orientada a objetos por lo que el programa puede contener errores o ser muy basico.&lt;/p&gt;

&lt;p&gt;Como ven, es una aplicacion sumamente sencilla y facil de hacer muy similar a lista de contactos que se hizo en articulos anteriores. esta aplicacion podria ser mejorado por ejemplo si hacemos que el mismo programa tome los valores de subida y bajada de la PC y los almacene sin necesidad de que uno mismo los introdusca (similar a como se hace con la fecha y hora), pero todavia no encuentro la manera de hacer eso :-( .&lt;/p&gt;

&lt;p&gt;Para ejecutarlo en la terminal tan solo escribimos en la misma:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;python registrodetransferenciasapp.py&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y veremos algo como esto:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/pFFp0&quot;&gt;&lt;img src=&quot;http://i.imgur.com/pFFp0l.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Al ingresar en Futon para verificar los documentos creados veremos algo como esto:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/Q9qZ4&quot;&gt;&lt;img src=&quot;http://i.imgur.com/Q9qZ4s.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Para visualizar de una forma sencilla en Futon los datos almacenados y/o calcular el total consumido podriamos usar las funciones Map/Reduce escritas en JavaScript, pero esto se los mostrare en otro articulo proximamente. :P&lt;/p&gt;

&lt;p&gt;Si eres de los que no quieren tener una base de datos corriendo en su PC pero quieres probarla y aprender a usarla entonces estas de suerte ya que &lt;a href=&quot;http://www.couchone.com/get&quot;&gt;CouchOne&lt;/a&gt; y &lt;a href=&quot;https://cloudant.com/&quot;&gt;Cloudant&lt;/a&gt; ofrecen hosting Cloud de CouchDB Gratis!!! con lo que prodras tener una interfaz Futon online en donde administrar tus bases de datos.&lt;/p&gt;

&lt;p&gt;Tambien has estado probando CouchDB ??? ya has realizado una aplicacion??? cuentanos tu experiencia con CouchDB!!!&lt;/p&gt;

&lt;p&gt;Espero les sirva!!!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Instalando CouchDB en Ubuntu</title>
   <link href="http://blog.jam.net.ve/2010/12/12/instalando-couchdb-en-ubuntu"/>
   <updated>2010-12-12T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2010/12/12/instalando-couchdb-en-ubuntu</id>
   <content type="html">&lt;p&gt;Desde hace un mes aproximadamente e estado leyendo sobre sistemas de bases de datos del tipo &lt;a href=&quot;http://es.wikipedia.org/wiki/NoSQL&quot;&gt;NoSQL&lt;/a&gt;, estos sistemas de bases de datos se estan poniendo de moda entre las grandes compañias que requieren alta escalabilidad y performance a bajo costo. Los sistemas de bases de datos NoSQL no son para nada similares a los sistemas de bases de datos Relacionales a los que estamos acostumbrado, en los Sistemas de Administracion de Bases de Datos Relacionales (RDBMS) se acostumbra a organizar los datos en forma de tablas las cuales contienen filas, columnas y un campo clave o ID por lo general autoincremental, ademas de que se usan esquemas de relaciones entre otras tablas.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/EUNoH&quot;&gt;&lt;img src=&quot;http://i.imgur.com/EUNoH.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bien en los Sistemas NoSQL casi nada de esto existe, CouchDB es un sistema de bases de datos NoSQL que almacena la informacion en forma de documentos, estos documentos reflejan los datos en formato &lt;a href=&quot;http://www.json.org/json-es.html&quot;&gt;JSON&lt;/a&gt;, es decir organiza la los datos en Clave:Valor y no en tablas. Estos documentos JSON contienen una ID unica No-Incremental que puede ser autogenerada o que puede definir uno mismo.&lt;/p&gt;

&lt;p&gt;Una de las ventajas de &lt;a href=&quot;http://couchdb.apache.org/&quot;&gt;CouchDB&lt;/a&gt; frente a otros sistemas NoSQL del tipo documento es que incluye una interfaz web (FUTON) de facil manejo desde la que podemos administrar nuestras bases de datos, CouchDB ademas soporta accesibilidad por REST/HTTP por lo que podemos administrar nuestra base de datos mediante una URL. Otra de las ventajas de couchDB es el soporte de replicaciones del tipo Mestro-Esclavo, Maestro-Maestro y Replicacion incremental con deteccion/resolucion de conflictos bidireccional.&lt;/p&gt;

&lt;p&gt;Un documento sencillo en CouchDB podria ser algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;_id&amp;quot;&lt;/span&gt; : &lt;span class=&quot;s2&quot;&gt;&amp;quot;ksjfhk65464f65g464f68465cx4665&amp;quot;&lt;/span&gt;,
&lt;span class=&quot;s2&quot;&gt;&amp;quot;_rev&amp;quot;&lt;/span&gt; : &lt;span class=&quot;s2&quot;&gt;&amp;quot;1-6d4f654d5fv5fz3214fd45d45&amp;quot;&lt;/span&gt;,
&lt;span class=&quot;s2&quot;&gt;&amp;quot;Nombre&amp;quot;&lt;/span&gt; : &lt;span class=&quot;s2&quot;&gt;&amp;quot;Angel&amp;quot;&lt;/span&gt;,
&lt;span class=&quot;s2&quot;&gt;&amp;quot;Nick&amp;quot;&lt;/span&gt; : &lt;span class=&quot;s2&quot;&gt;&amp;quot;JamUnix&amp;quot;&lt;/span&gt;,
&lt;span class=&quot;s2&quot;&gt;&amp;quot;Web&amp;quot;&lt;/span&gt; : &lt;span class=&quot;s2&quot;&gt;&amp;quot;www.jam.net.ve&amp;quot;&lt;/span&gt;,
&lt;span class=&quot;s2&quot;&gt;&amp;quot;Lenguajes_conocidos&amp;quot;&lt;/span&gt; : &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Vb.Net&amp;quot;&lt;/span&gt;, &lt;span class=&quot;s2&quot;&gt;&amp;quot;HTML5&amp;quot;&lt;/span&gt;, &lt;span class=&quot;s2&quot;&gt;&amp;quot;CSS3&amp;quot;&lt;/span&gt;, &lt;span class=&quot;s2&quot;&gt;&amp;quot;otros mas...&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Para instalar CouchDB en Ubuntu y comenzar a “jugar” con el y aprender como funciona una base de datos NoSQL tan solo teclea en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo aptitude install couchdb&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Con esto tendremos CouchDB instalado y ejecutandoce en nuestra PC, para comprobarlo podemos ir a la terminal y mediante Curl teclear:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;curl http://localhost:5984&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;lo que nos devolvera algo como:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;couchdb&amp;quot;&lt;/span&gt;:&lt;span class=&quot;s2&quot;&gt;&amp;quot;Welcome&amp;quot;&lt;/span&gt;,&lt;span class=&quot;s2&quot;&gt;&amp;quot;version&amp;quot;&lt;/span&gt;:&lt;span class=&quot;s2&quot;&gt;&amp;quot;1.0.1&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;CouchDB ofrece una interfaz web llamada Futon en la que podemos administrar las bases de datos, para entrar en Futon tan solo debemos abrir nuestro navegador y colocar la siguiente URL:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;http://localhost:5984/_utils&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Con lo que veras algo como esto:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/vbyGB&quot;&gt;&lt;img src=&quot;http://i.imgur.com/vbyGBs.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Por ahora no hay mucha documentacion en Español sobre CouchDB, pero si te interesa aprender mas sobre este sistema puedes leer este &lt;a href=&quot;http://4tic.com/blog/40-blgo/63-couchdb-una-bd-diferente&quot;&gt;primer&lt;/a&gt; y &lt;a href=&quot;http://4tic.com/en/blog/40-blgo/64-couchdb-una-base-de-datos-diferente-2&quot;&gt;segundo&lt;/a&gt; articulo publicado en 4tic.com&lt;/p&gt;

&lt;p&gt;Tambien puedes visitar la &lt;a href=&quot;http://wiki.apache.org/couchdb/&quot;&gt;Wiki de CouchDB&lt;/a&gt; o leer &lt;a href=&quot;http://guide.couchdb.org/&quot;&gt;la Guia&lt;/a&gt; en Ingles.&lt;/p&gt;

&lt;p&gt;Pronto publicare mas articulos acerca de como crear documentos sencillos usando Futon, los usos con curl y un ejemplo de como conectar y almacenar datos usando Python y el Framework &lt;a href=&quot;http://couchdbkit.org/&quot;&gt;CouchDBKit.&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Acelerometro y Ubuntu</title>
   <link href="http://blog.jam.net.ve/2010/11/21/acelerometro-y-ubuntu"/>
   <updated>2010-11-21T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2010/11/21/acelerometro-y-ubuntu</id>
   <content type="html">&lt;p&gt;Hasta hace unas horas no sabia que podia usar el Acelerometro (lis3lv02d) que tiene mi laptop en Linux, tan solo sabia que lo usa en Windows la aplicacion HP 3D DriveGuard para proteger el disco duro en casos de una posible caida  y golpe contra el suelo. Pero en Linux es posible sacarle provecho al acelerometro para algo mas que proteger el disco duro.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/Qg7uI&quot;&gt;&lt;img src=&quot;http://i.imgur.com/Qg7uI.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Una manera de saber que nuestra laptop posee un acelerometro es tecleando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;cat /sys/devices/platform/lis3lv02d/position&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;si nos devuelve algo como:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;18,36,936&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;entonces quiere decir que tenermos un acelerometro correctamente reconocido por Linux, el valor en (18,36,936) representa el eje X,Y,Z .&lt;/p&gt;

&lt;p&gt;Buscando en google me encontre con un script en Bash el cual usa el acelerometro de la laptop para rotar las caras del cubo de escritorio de Compiz. el script en cuestion se encuentra en los &lt;a href=&quot;https://bbs.archlinux.org/viewtopic.php?id=78031&quot;&gt;foros de ArchLinux&lt;/a&gt; y fue escrito por el usuario &lt;a href=&quot;https://bbs.archlinux.org/viewtopic.php?id=78031&quot;&gt;SamoTurk&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Este script requiere que tengamos instalado el paquete wmctrl, por lo que si no lo tienes aun tendras que instalarlo tecleando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo aptitude install wmctrl&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;En realidad son dos script:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# lis3lv02d-rotate&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Author: Samo Turk&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Released under GPLv3&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;COUNTER&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0
&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;  &lt;span class=&quot;nv&quot;&gt;$COUNTER&lt;/span&gt; -lt &lt;span class=&quot;m&quot;&gt;100&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
sleep 2
&lt;span class=&quot;nv&quot;&gt;POS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;cat /sys/devices/platform/lis3lv02d/position &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; awk -F , &lt;span class=&quot;s1&quot;&gt;&amp;#39;{print$1}&amp;#39;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; awk -F &lt;span class=&quot;s2&quot;&gt;&amp;quot;(&amp;quot;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;{print$2}&amp;#39;&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$POS&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$POS&lt;/span&gt; -ge &lt;span class=&quot;m&quot;&gt;350&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt;
./compiz-rotate-wmctrl left
&lt;span class=&quot;k&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$POS&lt;/span&gt; -le -350 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt;
./compiz-rotate-wmctrl right
&lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;COUNTER&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;COUNTER+1
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Este script lo guardaremos en un archivo llamado “lis3lv02d-rotate”&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# compiz-rotate-wmctrl - Rotate the cube using wmctrl&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Author: Shang-Feng Yang&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Released under GPLv3&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;VER&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; rotate&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# The target face number (begins with 0)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;TVPN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;NF&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# The X coordinate of the target viewport&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;TVPX&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;TVPN&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;WW&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Change to the target viewport&lt;/span&gt;
wmctrl -o &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;TVPX&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;,0
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; usage&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; -e &lt;span class=&quot;s2&quot;&gt;&amp;quot;$(basename $0) v${VER}\n&amp;quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; -e &lt;span class=&quot;s2&quot;&gt;&amp;quot;Usage:\n&amp;quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; -e &lt;span class=&quot;s2&quot;&gt;&amp;quot;\t$(basename $0) {left|right|#}\n&amp;quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; -e &lt;span class=&quot;s2&quot;&gt;&amp;quot;\tWhere:\n&amp;quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; -e &lt;span class=&quot;s2&quot;&gt;&amp;quot;\t\tleft - rotate the cube to the left&amp;quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; -e &lt;span class=&quot;s2&quot;&gt;&amp;quot;\t\tright - rotate the cube to the right&amp;quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; -e &lt;span class=&quot;s2&quot;&gt;&amp;quot;\t\t# - rotate to #th face (begins with 0)\n\n&amp;quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; -e &lt;span class=&quot;s2&quot;&gt;&amp;quot;Author: Shang-Feng Yang &amp;quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; -e &lt;span class=&quot;s2&quot;&gt;&amp;quot;Released under GPLv3&amp;quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# The action to be performed. $ACT could be &amp;#39;left&amp;#39; or &amp;#39;right&amp;#39; to rotate&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# left or right, accordingly. $ACT could also be the number of the face&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# to rotate into.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;ACT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt;tr &lt;span class=&quot;s1&quot;&gt;&amp;#39;[A-Z]&amp;#39;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;[a-z]&amp;#39;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;x$ACT&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;x&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; usage&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;exit &lt;/span&gt;1&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$ACT&lt;/span&gt; in
left&lt;span class=&quot;p&quot;&gt;|&lt;/span&gt;right&lt;span class=&quot;p&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;0-9&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;0-9&lt;span class=&quot;o&quot;&gt;][&lt;/span&gt;0-9&lt;span class=&quot;o&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;
*&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
usage
&lt;span class=&quot;nb&quot;&gt;exit &lt;/span&gt;1
&lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;esac&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# The informations about the desktop&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;INFO&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;wmctrl -d&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# The width of the desktop&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;DW&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;${INFO}&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; awk &lt;span class=&quot;s1&quot;&gt;&amp;#39;{sub(/x[0-9]+/, &amp;quot;&amp;quot;, $4); print $4}&amp;#39;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# The width of the workarea&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;WW&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;${INFO}&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; awk &lt;span class=&quot;s1&quot;&gt;&amp;#39;{sub(/x[0-9]+/, &amp;quot;&amp;quot;, $9); print $9}&amp;#39;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# The number of faces on the cube&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;NF&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$DW&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$WW&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# The X coordinate of the viewport&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;CVPX&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;${INFO}&amp;quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt;awk &lt;span class=&quot;s1&quot;&gt;&amp;#39;{sub(/,[0-9]+/, &amp;quot;&amp;quot;, $6); print $6}&amp;#39;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Current number of the face in all faces (begins with 0)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;CVPN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;CVPX&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;WW&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;$ACT&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;right&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;ACT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;CVPN&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;$ACT&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;left&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;ACT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;CVPN&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
rotate &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;ACT&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Y este segundo script lo guardaremos en un archivo llamado “compiz-rotate-wmctrl” en la misma carpeta donde esta el primer script luego le agregamos permisos de ejecucion a ambos archivos.&lt;/p&gt;

&lt;p&gt;Para probar este script ejecutamos desde la terminal tecleando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sh ./lis3lv02d-rotate&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ahora solo nos queda inclinar la laptop a la izquierda o derecha y el cubo de escritorio deberia cambiar  en ese sentido similar a como lo muestra este &lt;a href=&quot;http://www.youtube.com/watch?v=CtWywn1zbjA&quot;&gt;video&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Otras de las utilidades que le posemos dar a el acelerometro es en los juegos NeverBall en el que podemos mover la esfera inclinando la laptop hacia los lados como se ve en este &lt;a href=&quot;http://www.youtube.com/watch?v=a92VXK-mURk&quot;&gt;video.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Una tercera utilidad que encontre para el acelerometro es unirse al proyecto &lt;a href=&quot;http://qcn.stanford.edu/&quot;&gt;Quake-Catcher&lt;/a&gt; Network en el cual se usan las laptops con acelerometros como una especie de sismografos conectados a internet y asi detectar posibles temblores y terremotos en tu localidad, lamentablemente  no todo el software que se necesita es soportado en Linux  y al parecer solo esta disponible para Mac y Windows.&lt;/p&gt;

&lt;p&gt;Por ultimo siempre podremos volver a la utilidad principal para la que el fabricante coloco el acelerometro en las laptops, es decir Proteger nuestro disco duro. En linux podemos usar  el software HPfall el cual usara el acelerometro para detectar movimientos bruscos o caidas y proteger el disco duro en esas situaciones para asi evitar daños o perdida de datos.&lt;/p&gt;

&lt;p&gt;Para instalar HPfall debemos agregar el repositorio del autor tecleando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo apt-add-repository ppa:pmjdebruijn/ppa&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;actualizamos la lista de paquetes&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo aptitude update&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;ahora instalamos HPFALL&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo aptitude install hpfall&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Esto nos ejecutara un demonio en cada inicio el cual estara monitoreando junto con el acelerometro los movimientos para asi proteger el disco en caso de una caida.&lt;/p&gt;

&lt;p&gt;Este software no tiene ninguna interfaz de configuracion, asi que no te sorprendas si estas buscando un icono en el menu aplicaciones y no encuentras nada, a fin de cuentas el HP 3D DriveGuard tampoco trae mucha cosa que se diga.&lt;/p&gt;

&lt;p&gt;Me gustaria probar alguna otra utilidad pero de momento no encuentro mas, me gustaria un software en el que pueda ver en tiempo real los valores de X,Y,Z mientras muevo la laptop pero por ahora no e encontrado nada parecido mas que usar el comando cat /sys/devices/platform/lis3lv02d/position&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Guia de restauracion del GRUB con Ubuntu</title>
   <link href="http://blog.jam.net.ve/2010/11/13/guia-de-restauracion-del-grub-con-ubuntu"/>
   <updated>2010-11-13T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2010/11/13/guia-de-restauracion-del-grub-con-ubuntu</id>
   <content type="html">&lt;p&gt;Bueno el amigo &lt;a href=&quot;https://wiki.ubuntu.com/NelsonDelgado&quot;&gt;Nejode&lt;/a&gt; lo a vuelto a hacer y nos a sorprendido nuevamente con otra de sus guias,  hace unas semanas puso a disposicion la &lt;a href=&quot;http://blog.jam.net.ve/2010/11/04/guia-de-conexion-escritorio-remoto-en-ubuntu/&quot;&gt;guia para conexiones a escritorios remotos&lt;/a&gt;, pero en esta ocasion nos ofrece una guia de Grub2 en la que nos explica como podemos usar &lt;a href=&quot;http://blog.jam.net.ve/category/ubuntu/&quot;&gt;Ubuntu&lt;/a&gt; para recuperar el Grub  (gestor de arranque) en nuestro disco duro.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href=&quot;http://db.tt/QpQzgCr1&quot;&gt;&lt;img src=&quot;http://i.imgur.com/iJ4Lsl.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;No es extraño que en ocasiones uno pueda perder el arranque de nuestro pc luego de una instalacion de Winxp/Vista/7  y este daño el arranque de nuestro Linux que ya teniamos en otra particion, pues bien si este es tu caso (o cualquien otro en donde hayas perdido el Grub o el arranque del sistema) entonces ya no tienes escusa para ponerte manos a la obra y recuperar  tu sistema restaurando el Grub.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nota: Esta guia se a publicado en &lt;a href=&quot;http://blog.jam.net.ve/&quot;&gt;JamUnix Blog&lt;/a&gt; con el permiso explicito del autor.&lt;/strong&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Entendiendo la notacion octal de los permisos de sistemas en Linux</title>
   <link href="http://blog.jam.net.ve/2010/11/11/entendiendo-la-notacion-octal-de-los-permisos-del-sistema-en-linux"/>
   <updated>2010-11-11T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2010/11/11/entendiendo-la-notacion-octal-de-los-permisos-del-sistema-en-linux</id>
   <content type="html">&lt;p&gt;Si administras un servidor, una cuenta de hosting o usas una distro Linux es muy probable que en algun momento hayas tenido que cambiar los permisos a alguna carpeta o archivo. En sistemas Linux comunmente se usa el comando chmod seguido de un conjunto de letras y simbolos (notacion simbolica) o seguido de una cifra de 3 digitos (notacion octal), pero en ocasiones usamos estos permisos sin saber que significan o que estan haciendo realmente ya que copiamos el comando de alguna guia o pagina.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Bien en esta ocasion explicare un poco como es el funcionamiento de la notacion octal y como saber el significado de esos numeros que colocamos.&lt;/p&gt;

&lt;p&gt;En primer lugar la notacion octal consiste en un conjunto de valores de 3 o 4 digitos en base 8. cuando escribimos un permiso en notacion octal de 3 digitos, cada numero representa un un componente de permisos a establecer.&lt;/p&gt;

&lt;p&gt;Para saber que permisos le estamos asignando a un archivo o carpeta podemos valernos del significado de cada numero. por ejemplo:&lt;/p&gt;

&lt;p&gt;4 - &lt;span style=&quot;color: #00ff00;&quot;&gt;Lectura&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;2 - &lt;span style=&quot;color: #3366ff;&quot;&gt;Escritura&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;1 - &lt;span style=&quot;color: #ff0000;&quot;&gt;Ejecucion&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;La posicion de estos numeros en la cifra tambien tiene un significado, por ejemplo:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;7 x x&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;La primera posicion en la cifra significa que ese permiso sera valido para el usuario (propietario del archivo o carpeta).&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;x 7 x&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;La segunda posicion en la cifra significa que ese permiso sera valido para el grupo.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;x x 7&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;La tercera posicion en la cifra significa que ese permiso sera valido para el publico.&lt;/p&gt;

&lt;p&gt;Si por ejemplo escribimos un comando como este:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;chmod &lt;span class=&quot;m&quot;&gt;421&lt;/span&gt; archivo.txt&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Lo que estariamos haciendo es:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Permitirle al dueño &lt;span style=&quot;color: #00ff00;&quot;&gt;leer&lt;/span&gt; (abrir/ver) el archivo.txt&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Permitirle al grupo &lt;span style=&quot;color: #3366ff;&quot;&gt;escribir&lt;/span&gt; (editar) el archivo.txt&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Permitirle al resto de los usuarios o el publico &lt;span style=&quot;color: #ff0000;&quot;&gt;ejecutar&lt;/span&gt; el archivo.txt&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hasta aqui todo se entiende a simple vista, pero de seguro te estaras preguntando ¿como hacer si quiero que el usuario tenga permisos de lectura-escritura y permisos de solo lectura a los grupos y el publico? Pues bien muy facil, los valores octales pueden conbinarse (sumarse), veamos este ejemplo:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;chmod &lt;span class=&quot;m&quot;&gt;644&lt;/span&gt; archivo.txt&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Aqui estariamos combinando (sumando) el valor octal para el permiso de &lt;span style=&quot;color: #00ff00;&quot;&gt;lectura&lt;/span&gt; y el valor octal para el permiso de&lt;span style=&quot;color: #00ffff;&quot;&gt; &lt;span style=&quot;color: #3366ff;&quot;&gt;escritura&lt;/span&gt;&lt;/span&gt;, los que nos daria como resultado 6 que seria igual a el permiso &lt;span style=&quot;color: #00ff00;&quot;&gt;Lectura&lt;/span&gt;-&lt;span style=&quot;color: #3366ff;&quot;&gt;Escritura&lt;/span&gt;.  Al grupo y al publico se le asigna el valor octal 4 que seria el equivalente al permiso de solo &lt;span style=&quot;color: #00ff00;&quot;&gt;lectura&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;Otro caso podria ser este ejemplo:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;chmod &lt;span class=&quot;m&quot;&gt;750&lt;/span&gt; archivo.txt&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;En este caso estariamos:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Asignandole permisos de &lt;span style=&quot;color: #00ff00;&quot;&gt;lectura&lt;/span&gt;-&lt;span style=&quot;color: #3366ff;&quot;&gt;escritura&lt;/span&gt;-&lt;span style=&quot;color: #ff0000;&quot;&gt;ejecucion&lt;/span&gt; al usuario.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Asignandole permisos de &lt;span style=&quot;color: #00ff00;&quot;&gt;lectura&lt;/span&gt;-&lt;span style=&quot;color: #ff0000;&quot;&gt;ejecucion&lt;/span&gt; al grupo.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Quitandole todo los permisos al publico.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;En este caso al la posicion correspondiente al publico se le asigna el valor “0” lo que significa que no se le esta dando ningun tipo de permisos, es decir el publico no puede ver/abrir archivo.txt, no puede escribir/editar en archivo.txt ni tampoco puede ejecutar archivo.txt.&lt;/p&gt;

&lt;p&gt;Despues de ver esto ya no seria problemas leer o asignar permisos a un archivo o una carpeta tanto en tu pc con  linux como en un servidor remoto o un hosting accesandi via FTP.&lt;/p&gt;

&lt;p&gt;Espero les sirva tanto como a mi.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Guia de conexion de escritorios remotos en Linux</title>
   <link href="http://blog.jam.net.ve/2010/11/04/guia-de-conexion-escritorio-remoto-en-ubuntu"/>
   <updated>2010-11-04T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2010/11/04/guia-de-conexion-escritorio-remoto-en-ubuntu</id>
   <content type="html">&lt;p&gt;De seguro muchos se han topado con la necesidad de conectarse remotamente con su PC para realizar alguna tarea sin estar frente a ella pero se han vuelto un ocho intentando lograr la conexion. es por esto que les traigo una buena guia escrita por el amigo &lt;a href=&quot;https://wiki.ubuntu.com/NelsonDelgado&quot;&gt;Nejode&lt;/a&gt; Miembro del Grupo de Usuarios &lt;a href=&quot;http://www.ubuntu-ve.org&quot;&gt;Ubuntu de Venezuela&lt;/a&gt;.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href=&quot;http://db.tt/vXNBRtzo&quot;&gt;&lt;img src=&quot;http://i.imgur.com/ambFHl.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Con esta guia podran realizar la configuracion y conexion de escritorios remotos (VNC) usando entre dos PC usando Vino y Vinagre. Cabe destacar que la guia esta muy bien explicada por lo que de seguro no tendran problemas en realizar la configuracion.
Nota: Esta guia se a publicado en &lt;a href=&quot;http://blog.jam.net.ve&quot;&gt;JamUnix Blog&lt;/a&gt; con el permiso explicito del autor.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Montando particiones NTFS en Linux</title>
   <link href="http://blog.jam.net.ve/2010/10/30/montando-particiones-ntfs-en-linux"/>
   <updated>2010-10-30T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2010/10/30/montando-particiones-ntfs-en-linux</id>
   <content type="html">&lt;p&gt;Esto es algo que ya hay en muchos blogs, foros, etc…  pero lo coloco aqui en &lt;a href=&quot;http://blog.jam.net.ve/&quot; target=&quot;_blank&quot;&gt;JamUnix Blog&lt;/a&gt; a modo de respaldo para tenerlo a mano cuando lo necesite ya que cuando instalo una nueva version de &lt;a href=&quot;http://blog.jam.net.ve/category/ubuntu/&quot; target=&quot;_blank&quot;&gt;Ubuntu&lt;/a&gt; u otra distro como Debian o Arch &lt;a href=&quot;http://blog.jam.net.ve/category/linux/&quot;&gt;Linux&lt;/a&gt;, siempre ando buscando como automontar mis particiones NTFS.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Bien comencemos, para automontar particiones usaremos la aplicacion ntfs-3g la cual nos facilitara mucho la tarea, por lo que lo primero que haremos sera instalarla tecleando en una terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo aptitude install ntfs-3g&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Luego de esto creamos una carpeta llamada “JamNTFS”en /media en la cual montaremos la particion NTFS.  Por supuesto podemos colocarle el nombre que queramos a la carpeta.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;mkdir /media/jamunixNTFS&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ahora debemos averiguar en donde se encuentra nuestra particion NTFS a montar, para ver esto tecleamos en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo fdisk -l&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Esto nos mostrara un listado de las particiones que tenemos, es algo similar a esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;Dispositivo Inicio    Comienzo      Fin      Bloques  Id  Sistema
/dev/sda1   *           &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;          &lt;span class=&quot;m&quot;&gt;13&lt;/span&gt;      &lt;span class=&quot;m&quot;&gt;102400&lt;/span&gt;    &lt;span class=&quot;m&quot;&gt;7&lt;/span&gt;  HPFS/NTFS
La partición &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt; no termina en un límite de cilindro.
/dev/sda2              &lt;span class=&quot;m&quot;&gt;13&lt;/span&gt;       &lt;span class=&quot;m&quot;&gt;25843&lt;/span&gt;   &lt;span class=&quot;m&quot;&gt;207478784&lt;/span&gt;    &lt;span class=&quot;m&quot;&gt;7&lt;/span&gt;  HPFS/NTFS
/dev/sda3           &lt;span class=&quot;m&quot;&gt;25843&lt;/span&gt;       &lt;span class=&quot;m&quot;&gt;31984&lt;/span&gt;    &lt;span class=&quot;m&quot;&gt;49324032&lt;/span&gt;   &lt;span class=&quot;m&quot;&gt;83&lt;/span&gt;  Linux
/dev/sda4           &lt;span class=&quot;m&quot;&gt;31984&lt;/span&gt;       &lt;span class=&quot;m&quot;&gt;38914&lt;/span&gt;    &lt;span class=&quot;m&quot;&gt;55663617&lt;/span&gt;    &lt;span class=&quot;m&quot;&gt;5&lt;/span&gt;  Extendida
/dev/sda5           &lt;span class=&quot;m&quot;&gt;31984&lt;/span&gt;       &lt;span class=&quot;m&quot;&gt;32233&lt;/span&gt;     &lt;span class=&quot;m&quot;&gt;1998848&lt;/span&gt;   &lt;span class=&quot;m&quot;&gt;82&lt;/span&gt;  Linux swap / Solaris
/dev/sda6           &lt;span class=&quot;m&quot;&gt;32233&lt;/span&gt;       &lt;span class=&quot;m&quot;&gt;38914&lt;/span&gt;    &lt;span class=&quot;m&quot;&gt;53663744&lt;/span&gt;   &lt;span class=&quot;m&quot;&gt;83&lt;/span&gt;  Linux&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Como podemos ver tenemos 2 particiones NTFS sda1 y sda2, y la que yo configurare para que se automonte sera la sda2.&lt;/p&gt;

&lt;p&gt;Para hacer dicho montaje de la particion /dev/sda2 en la carpeta /media/JamNTFS que ya creamos mas arriba, tecleamos en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;mount -t ntfs-3g /dev/sda2 /media/JamNTFS&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ya con esto tendremos montada nuestra particion NTFS.&lt;/p&gt;

&lt;p&gt;Ahora haremos una configuracion mas para que se automonte la particion cada vez que iniciemos el S.O para esto editaremos el archivo fstab tecleando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo gedit /etc/fstab&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y agregamos la siguiente linea al final del archivo:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/dev/sda2 /media/JamNTFS ntfs-3g defaults,locale&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;es_ES.UTF8 &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt; 0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;guardamos, cerramos y reiniciamos para ver al siguiente inicio nuestra particion NTFS montada de manera automatica.&lt;/p&gt;

&lt;p&gt;Saludos y espero les sirva tanto como a mi.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Monitoreando nuestro sistema vigilando los archivos de registros logs.</title>
   <link href="http://blog.jam.net.ve/2010/10/26/monitoreando-nuestro-sistema-vigilando-los-archivos-de-registro-logs"/>
   <updated>2010-10-26T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2010/10/26/monitoreando-nuestro-sistema-vigilando-los-archivos-de-registro-logs</id>
   <content type="html">&lt;p&gt;Los archivos de registros o archivos log como se conocen comummente, son archivos en donde se van almacenando un registro de todos los eventos que ocurren en un sistema durante un periodo de tiempo en particular. Estos archivos son usados tanto por el sistema operativo como por las aplicaciones o demonios (procesos) para registrar datos o informacion sobre un evento en particular.  En un sistema Linux podemos encontrar estos archivos de registro o logs en la carpeta /var/log  En esta carpeta encontraremos casi todos los archivos de registros de un sistema, pero cabe destacar que muchas aplicaciones crean estos archivos en sus propias carpetas fuera de /var/log.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Ahora bien, ¿En que nos sirve los logs para monitorear nuestro sistema? pues muy sencillo, los principales archivos logs que estan en la carpeta /var/log van almacenando informacion de casi todos los eventos que ocurren en tu PC practicamente desde que la enciendes y en ellos podremos ver por ejemplo que pasa internamente en Linux cuando conectas una Memoria USB, un &lt;a href=&quot;http://blog.jam.net.ve/tag/modem/&quot;&gt;Modem&lt;/a&gt; USB o cuando estas conectado a internet puedes ver los intentos de entrada bloqueados por tu firewall.   En otras circunstancias podremos ser capaces de observar algun mensaje de error que se pueda producir cuando estas conectando algun hardware nuevo o si tienes un servicio web instalado podras ver quienes estan conectados a tu equipo.&lt;/p&gt;

&lt;p&gt;Aqui en &lt;a href=&quot;http://blog.jam.net.ve/&quot;&gt;JamUnix Blog&lt;/a&gt; veremos algunos archivos Logs y sus usos:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/log/messages&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Este es el archivo principal de registros y almacena la mayoria de los mensajes de interes.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/log/auth.log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Muestra mensajes sobre autenticacion de usuarios y permisos&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/log/daemon.log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Muestra mensajes sobre demonios (permisos) o servicios corriendo en el sistema.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/log/dmesg&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Muestra mensajes del nucleo Linux.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/log/dpkg.log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Muestra un registro de los paquetes binarios instalado.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/log/kern.log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Muestra mensajes del Kernel&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/log/boot.log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Muestra mensajes referentes al arranque del sistema.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/log/debug&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Muestra mensajes de depuracion.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/log/lpr.log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Muestra mensajes sobre la impresora&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/log/mail.err

/var/log/mail.info

/var/log/mail.warn

/var/log/mail.log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Archivos varios que muestran mensajes sobre error, informacion, alertas y registro (respectivamente) para los correos (requiere tener un servicio de correos funcionando).&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/log/mysql.*&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Archivos varios de registro para el servicio mysql (requiere tener un servicio mysql).&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/log/user.log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Muestra informacion acerca de los procesos usados por el usuario&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/log/Xorg.0.log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Muestra registros de Xorg&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/log/apache2/*&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Archivos de registro varios que muestra informacion sobre el servicio web Apache (requiere tener apache instalado).&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/log/lighttpd/*&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Archivos de registro varios que muestran informacion sobre el servicio web &lt;a href=&quot;http://blog.jam.net.ve/tag/lighttpd/&quot;&gt;Lighttpd&lt;/a&gt; (requiere tener instalado Lighttpd)&lt;/p&gt;

&lt;p&gt;…   Entre otros.&lt;/p&gt;

&lt;p&gt;Por supuesto existen mucho mas archivos de logs, ya que muchos de los programas y aplicaciones que instales de seguro colocara su propio archivo de registro en /var/log o en su propia carpeta.  Por ejemplo, si instalamos el gestor de paquetes Aptitude, podremos ver un buen logs de los paquetes que instalamos con el en el archivos /var/log/aptitude&lt;/p&gt;

&lt;p&gt;Estos archivos tambien pueden variar dependiendo de la distribucion &lt;a href=&quot;http://blog.jam.net.ve/category/linux/&quot;&gt;Linux&lt;/a&gt; que se use.&lt;/p&gt;

&lt;p&gt;Un tips importante es que podemos ver estos archivos desde la terminal usando comandos como tail, cat, less o grep. un ejemplo podria ser tecleando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;tail -f  /var/log/message&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Con esto podriamos dejar abierta la terminal y detectar en tiempo real cualquier nuevo registro en el archivo log&lt;/p&gt;

&lt;p&gt;Saludos y espero les sirva.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>6 sencillas herramientas para monitoreo de red utiles.</title>
   <link href="http://blog.jam.net.ve/2010/10/17/6-sencillas-herramientas-de-monitoreo-de-red-utiles"/>
   <updated>2010-10-17T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2010/10/17/6-sencillas-herramientas-de-monitoreo-de-red-utiles</id>
   <content type="html">&lt;p&gt;Desde hace unos meses para aca e estado leyendo un poco de las grandes posibilidades que ofrece la terminal y su gran poder para controlar y administar practicamente toda tu PC.  Ultimamente e estado viendo aplicaciones y comandos para la terminal que me permitan ver y monitoriar las conexiones a internet por lo que les traigo aqui 3 comandos y 3 aplicaciones de terminal utiles para monitoriar tu red.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;strong&gt;Aplicaciones:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Iptraf:  Es una aplicacion basada en la terminal de estadisticas de red. tiene como caracteristicas el conteo de bytes y monitoreo de conexiones de paquetes TCP. Tambien ofrece estadisticas de las interfaces de red (eth0, ppp0, wlan0, etc) e indicadores de actividad, tambien nos muestra las interrupciones de trafico TCP/UDP.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/kVLFF&quot;&gt;&lt;img src=&quot;http://i.imgur.com/kVLFFl.gif&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Para instalarlo tan solo tecleamos en una terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo aptitude install iptraf&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y luego lo ejecutamos con:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo iptraf&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;Iftop: Escucha el trafico que hay en una interfaz de red y nos muestra en una tabla el ancho de banda consumido ademas del nombre de host remoto al cual estamos conectados y el puerto usado para la conexion.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/K8pwa&quot;&gt;&lt;img src=&quot;http://i.imgur.com/K8pwal.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Para instalarlo tan solo debemos teclear en una terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo aptitude install iftop&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y lo ejecutamos tecleando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo iftop -i ppp0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Nota: cambie ppp0 por su interfaz de red. ejemplo: eth0 (cableada), wlan0 (inalambrica), ppp0 (modem), etc…&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Ifstat: es una herramienta para informarnos sobre el ancho de banda de las interfaces de red muy similar a  vmstat/iostat.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/Woif2&quot;&gt;&lt;img src=&quot;http://i.imgur.com/Woif2l.jpg&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Para instalarlo tan solo ejecutamos en una terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo aptitude install ifstat&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y lo ejecutamos tecleando:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;ifstat -i ppp0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Nota: cambie ppp0 por su interfaz de red. ejemplo: eth0 (cableada), wlan0 (inalambrica), ppp0 (modem), etc…&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Comandos:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;lsof&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo lsof -i4&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Segun el Man (Manual) de lsof, nos dice que este comando lista los archivos abiertos (de alli deriva su nombre: ls “listar”,  o &amp;gt; de open y f &amp;gt; de file = lsof ) por lo que al ejecutarlo veremos una lista de las conexiones abiertas, que aplicacion, proceso o archivo la esta usando y tambien el puerto por el cual se realiza dicha conexion. Una salida de este comando mostraria algo similar a esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;COMMAND    PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
avahi-dae 1056   avahi   13u  IPv4   7319      0t0  UDP *:mdns
avahi-dae 1056   avahi   15u  IPv4   7321      0t0  UDP *:53814
dnsmasq   1214 dnsmasq    4u  IPv4   7595      0t0  UDP *:domain
dnsmasq   1214 dnsmasq    5u  IPv4   7596      0t0  TCP *:domain (LISTEN)
cupsd     1327    root    6u  IPv4   7752      0t0  TCP localhost.localdomain:ipp (LISTEN)
xchat     2805  usuario   14u  IPv4  22697      0t0  TCP Pc-Linux:43198-&amp;gt;antonieta.freenode.net:8001 (ESTABLISHED)
pidgin    2807   usuario    9w  IPv4  24691      0t0  TCP Pc-Linux:59995-&amp;gt;baymsg1.gateway.messenger.live.com:msnp (ESTABLISHED)
pidgin    2807   usuario   17u  IPv4  24548   0t0  TCP Pc-Linux:57466-&amp;gt;1e100.net:xmpp-client (ESTABLISHED)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Para saber mas sobre este comando lee su manual tecleando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;man lsof&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;netstat:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo netstat -lptu&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;netstat es un comando que nos puede mostrar las conexiones de red, tablas de enrutamiento, estadisticas de las diferentes interfaces de red,  conexiones enmascaradas entre otras funciones. Con la opcion -lptu en realidad le estamos diciendo a netstat que nos muestre multiples opciones de informacion (cada letra equivale a una opcion) por lo que en este caso le estamos pidiendo que liste los sockets abierto “l”, nos mueste los programas que estan usando esos sockets “p” y que sean mediante protocolos TCP “t” y UTP “u”&lt;/p&gt;

&lt;p&gt;una salida tipica de este comando seria similar a esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;Conexiones activas de Internet (solo servidores)
Proto  Recib Enviad Dirección local         Dirección remota       Estado       PID/Program name
tcp        0      0 *:domain                *:*                        ESCUCHAR    1214/dnsmasq
tcp        0      0 localhost.localdoma:ipp *:*                     ESCUCHAR    1327/cupsd
tcp6       0      0 [::]:domain             [::]:*                     ESCUCHAR    1214/dnsmasq
tcp6       0      0 PC-Linux:ipp          [::]:*                      ESCUCHAR    1327/cupsd
udp        0      0 *:mdns                  *:*                                 1056/avahi-daemon:
udp        0      0 *:domain                *:*                                 1214/dnsmasq
udp        0      0 *:53814                 *:*                                 1056/avahi-daemon:
udp6       0      0 [::]:mdns               [::]:*                              1056/avahi-daemon:
udp6       0      0 [::]:42850              [::]:*                              1056/avahi-daemon:
udp6       0      0 [::]:domain             [::]:*                              1214/dnsmasq&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Para saber mas de este comando y sus posibilidades teclea en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;man netstat&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;ss:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;ss -o&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;ss es un comando muy similar a netstat que nos sirve para investigar cualquier informacion acerca de los sockets y conexiones abiertas. ademas de volcado de datos.&lt;/p&gt;

&lt;p&gt;Una salida tipica de este comando seria algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;State      Recv-Q Send-Q                Local Address:Port                         Peer Address:Port
ESTAB      0      0                                     127:xx:xx:xx:34123             69:xx:xx:xx:www
CLOSE-WAIT 1      0                                 127:xx:xx:xx:42456       69:xx:xx:xx:www
ESTAB      0      0                                     127:xx:xx:xx:59995             69:xx:xx:xx:msnp
ESTAB      0      0                                     127:xx:xx:xx:37673              69:xx:xx:xx:www&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Para saber mas de este comando teclea en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;man ss&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Saludos.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Exportar tus contrasenas de lastpass a keepassx</title>
   <link href="http://blog.jam.net.ve/2010/09/14/exportar-tus-contrasenas-de-lastpass-a-keepassx"/>
   <updated>2010-09-14T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2010/09/14/exportar-tus-contrasenas-de-lastpass-a-keepassx</id>
   <content type="html">&lt;p&gt;Para los que no conocen &lt;a href=&quot;http://lastpass.com&quot;&gt;LastPass&lt;/a&gt; es un servicio online gratuito que nos permite guardar las
contraseñas de todas las paginas a las cuales estamos registrados y nos facilita la tarea de loguearnos o
registrarnos en dichas paginas autorellenando los formularios. Y para los que no conoscan &lt;a href=&quot;http://www.keepassx.org/&quot;&gt;KeePassX&lt;/a&gt;
es una aplicacion con caracteristicas similares a LastPass solo que este se ejecuta como aplicacion
de escritorio y guarda las contraseñas en tu PC.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Para muchos paranoicos no les agrada mucho la idea de usar LastPass ya que este al ser un servicio gratuito y online esta
propenso a ataques o a que los mismos creadores escudriñen en nuestras contraseñas (a fin de cuentas ellos son
los que tienen acceso a esos datos). Por lo que si tu ya tienes unas cuantas contraseñas almacenadas en
LastPass y deseas almacenarlas en tu PC podemos valernos del Script
&lt;a href=&quot;http://github.com/nazariuskappertaal/lastpass2keepass&quot;&gt;LastPass2KeePass&lt;/a&gt; que nos permite importarlas en .XML y
exportarlas en KeePassX para administrarlas desde este ultimo y no desde LastPass.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Para hacer esto tan solo debemos descargarnos el Script haciendo click &lt;a href=&quot;http://github.com/nazariuskappertaal/lastpass2keepass/raw/master/lastpass2keepass.py&quot;&gt;Aqui&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Nota: articulo Actualizado el 22-02-2011, Salte al final para saber mas y luego continué a partir de aqui&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Una vez descargado el script le damos permiso de ejecucion tecleando en la terminal:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo chmod +x lastpass2keepass.py&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Ahora solo necesitamos exportar las contraseñas almacenadas en LastPast en un archivo, si por ejemplo usas
el plugins de LastPass en tu navegador basta con hacer click en el icono Herramientas  Exportar a  Archivo CVS LastPass.
Le colocas un nombre al archivo y lo guardas en la misma carpeta donde tengas el script LastPass2KeePass&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Ahora nos vamos a la terminal y ejecutamos el script de importacion tecleando en la terminal:&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo python lastpass2keepass.py contraseñasLastPass contraseñaskeepass.xml&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Donde:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;contraseñasLastPass : Es el nombre del archivo donde estan las contraseñas exportadas desde LastPass.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;contraseñaskeepass.xml :  Es el nombre que quieres que tenga el archivo con tus contraseñas convertidas a formato XML de KeePassX.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Ahora tan solo debemos Importar las contraseñas en KeePassX, para esto solo abrimos la aplicacion y nos vamos
a Fichero - Importar desde… - KeePassX XML (*.xml)  Y elegimos nuestro archivo exportado que en nuestro
caso se llama contraseñaskeepass.xml&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ya con esto tendras tus contraseñas de LastPass almacenadas en KeePassX y desde ahora podras administrarla
desde este ultimo teniendo la seguridad de que solo tu eres el que las puedes ver y tocar :-)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Actualizacion: 22-02-2011:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;El repositorio en Github donde se encontraba la aplicacion lastpass2keepass.py ya no esta disponible a la fecha, por tal motivo copio a continuacion el codigo que compone la aplicacion:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c&quot;&gt;# lastpass2keepass&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Supports:&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Keepass XML - keepassxml&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# USAGE: python lastpass2keepass.py exportedTextFile&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# The LastPass Export format;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# url,username,password,1extra,name,grouping(\ delimited),last_touch,launch_count,fav&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;csv&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;datetime&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;itertools&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;re&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Toolkit&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;xml.etree.ElementTree&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;ET&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Saves data, easier to type&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Strings&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;fileError&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;You either need more permissions or the file does not exist.&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;lineBreak&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;____________________________________________________________&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;formattedPrint&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lineBreak&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lineBreak&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Files&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Check for existence/read/write.&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;inputFile&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;except&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;formattedPrint&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;USAGE: python lastpass2keepass.py exportedTextFile&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inputFile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;except&lt;/span&gt; &lt;span class=&quot;ne&quot;&gt;IOError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;formattedPrint&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Cannot read file: &amp;#39;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%s&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39; Error: &amp;#39;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%s&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;&amp;quot;&amp;quot; % (inputFile, fileError) )&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Create XML file.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;outputFile&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inputFile&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;.export.xml:&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;outputFile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;w&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Clean.&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;w&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;outputFile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;aw&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;except&lt;/span&gt; &lt;span class=&quot;ne&quot;&gt;IOError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;formattedPrint&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Cannot write to disk... exiting. Error: &amp;#39;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%s&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fileError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Parser&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Create a csv dialect and extract the data to a reader object.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;dialect&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;csv&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Sniffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sniff&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1024&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seek&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;csv&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dialect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Create a list of the entries, allow us to manipulate it.&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Can&amp;#39;t be done with reader object.&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;allEntries&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;allEntries&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;allEntries&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Remove LP format string.&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Close the read file.&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Keepass XML generator&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Add doctype to head, clear file.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&amp;lt;!DOCTYPE KEEPASSX_DATABASE&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Generate Creation date&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Form current time expression.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;now&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;datetime&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;datetime&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;formattedNow&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strftime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;%Y-%m-&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%d&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;T%H:%M&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Initialize tree&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# build a tree structure&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;page&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;database&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;doc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ElementTree&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Dictionary of failed entries&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;failed&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;formattedPrint&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;DEBUG of &amp;#39;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%s&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39; file conversion to the KeePassXML format, outputing to the &amp;#39;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%s&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39; file.&amp;quot;&amp;quot; %(inputFile,outputFile))&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# A dictionary, organising the categories.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;resultant&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Parses allEntries into a resultant.&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;allEntries&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;categories&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;re&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;r&amp;quot;[/&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;]&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Grab final category.&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;categories&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;resultant&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setdefault&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;categories&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[])&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Sort by categories.&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;except&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;# Catch illformed entries&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;# Grab entryElement position&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;allEntries&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;failed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Failed to format entryElement at line &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%s&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Initilize and loop through all entries&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;category&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;categoryEntries&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;resultant&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;iteritems&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;

 &lt;span class=&quot;c&quot;&gt;# Create head of group elements&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;headElement&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SubElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;group&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SubElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;headElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;title&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;category&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SubElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;headElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;icon&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;0&amp;quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Lastpass does not retain icons.&lt;/span&gt;

 &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;categoryEntries&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;# entryElement information&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;# Each entryElement&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;entryElement&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SubElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;headElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;entry&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;# entryElement tree&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SubElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entryElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;title&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SubElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entryElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;username&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SubElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entryElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;password&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SubElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entryElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;url&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SubElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entryElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;comment&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SubElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entryElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;icon&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;0&amp;quot;&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SubElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entryElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;creation&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;formattedNow&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SubElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entryElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;lastaccess&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SubElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entryElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;lastmod&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;ET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SubElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entryElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;expire&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Never&amp;quot;&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;except&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;# Catch illformed entries&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;# Grab entry position&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;allEntries&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;failed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Failed to format entry at line &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%d&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Check if it was a clean conversion.&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;failed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;c&quot;&gt;# Create a failed list.&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;failedList&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%d&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%s&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;decode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;failed&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;items&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()]&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;formattedPrint&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;The conversion was not clean.&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;You need to manually import the below entries from the &amp;#39;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%s&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39; file, as listed by below.&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inputFile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;formattedPrint&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Line Number : entryElement&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;failedList&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Write out tree&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# wrap it in an ElementTree instance, and save as XML&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lineBreak&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%s&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39; has been succesfully converted to the KeePassXML format.&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inputFile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Converted data can be found in the &amp;#39;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%s&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39; file.&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;outputFile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lineBreak&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Guardelo con el nombre &lt;strong&gt;lastpass2keepass.py&lt;/strong&gt; y continue con el articulo debajo de la nota.&lt;/p&gt;

&lt;p&gt;Existen dos fork en Github, el de &lt;a href=&quot;https://github.com/haridsv/lastpass2keepass&quot;&gt;harisdsv&lt;/a&gt; y el
de &lt;a href=&quot;https://github.com/anirudhjoshi/lastpass2keepass&quot;&gt;anirudhjoshi&lt;/a&gt;, pero en las pruebas que
realice, estos no me funcionaron a la perfección.&lt;/p&gt;

&lt;p&gt;Saludos y Espero les sirva…&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Vuela en internet usando una cache DNS - Dnsmasq en Ubuntu</title>
   <link href="http://blog.jam.net.ve/2010/08/20/vuela-en-internet-usando-una-cache-dns-dnsmasq-en-ubuntu"/>
   <updated>2010-08-20T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2010/08/20/vuela-en-internet-usando-una-cache-dns-dnsmasq-en-ubuntu</id>
   <content type="html">&lt;p&gt;Desde hace unos meses para aca mi internet HSDPA ha estado presentando molestos inconveniente los cuales me obligan a
recargar o solicitar las paginas mas de una vez para que estas puedan presentarse completamente y sin errores por lo que
decidi usar una cache DNS con Dnsmasq para probar como puede esto ayudar a mi conexion y que las paginas cargen a la primera
solicitud y sin problemas.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href=&quot;http://www.thekelleys.org.uk/dnsmasq/doc.html&quot;&gt;Dnsmasq&lt;/a&gt; es un servidor DHCP y  DNS ligero y de bajo impacto
para el sistema que nos permite usarlo cachear las peticiones DNS  hacia internet que realiza nuestro computador
pra resolver la IP de un dominio, de manera que cuando se desee accesar de nuevo a un dominio ya resuelto, no se
tenga que volver a solicitar a los servidores DNS en internet sino que se resuelven en la misma PC ya que esta
conoce de antemano la ip correspondiente.&lt;/p&gt;

&lt;p&gt;Antes de instalar Dnsmasq vemos los tiempos aproximados que se tarda mi conexion en resolver la ip de un dominio:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/CdclQ&quot;&gt;&lt;img src=&quot;http://i.imgur.com/CdclQl.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Para instalar Dnsmasq tan solo debemos ejecutar en la terminal la siguiente orden, pero antes asegurese de tener
activado los repositorios “universe”&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo apt-get install dnsmasq&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Luego de esto pasamos a configurar dnsmasq editando el archivo dnsmasq.conf tecleando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo gedit /etc/dnsmasq.conf&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;descomentamos y modificamos la linea que contiene:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#listen-address=&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;para que quede de esta manera:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;listen-address&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;127.0.0.1&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Luego de esto nos toca editar el cliente DHCP tecleando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo gedit /etc/dhcp3/dhclient.conf&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y nos aseguramos que las siguientes lineas:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;prepend domain-name-servers 127.0.0.1&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
request subnet-mask, broadcast-address, &lt;span class=&quot;nb&quot;&gt;time&lt;/span&gt;-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;esten descomentada y tenga la IP  127.0.0.1&lt;/p&gt;

&lt;p&gt;Por ultimo nos toca editar el archivo resolv.conf  y agregar la ip de nuestro servidor cache dns local tecleando en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo vim /etc/resolv.conf&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y colocamos nuestra IP local de primero en la lista de modo que quede similar a esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;nameserver 127.0.0.1
nameserver 208.67.222.222
nameserver 208.67.220.220&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;por ultimo reiniciamos dnsmasq para que aplique la configuracion:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sudo /etc/init.d/dnsmasq restart&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Por ultimo consultamos 2 veces el mismo dominio para ver el tiempo que se toma ahora ¿porque dos veces? la primera
para que haga la consulta a internet y permitir que dnsmasq la almacene en cache y la segunda para que se realice
la consulta de manera local ya que dnsmasq conoce ya la ip resultante y no se necesita hacer consultas al exterior.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/hFRl9&quot;&gt;&lt;img src=&quot;http://i.imgur.com/hFRl9l.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;como ven ahora es mucho mas rapido si se realizan consultas locales a dominios ya resueltos con anterioridad.&lt;/p&gt;

&lt;p&gt;Saludos y espero le sirva.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Migrando tu blog Wordpress. Un Metodo mas</title>
   <link href="http://blog.jam.net.ve/2010/03/15/migrando-tu-blog-wordpress-de-hosting-un-metodo-mas"/>
   <updated>2010-03-15T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2010/03/15/migrando-tu-blog-wordpress-de-hosting-un-metodo-mas</id>
   <content type="html">&lt;p&gt;Desde que empece este blog e tenido que aprender por mi cuenta y en ocasiones de mala manera la administracion, uso y configuracion de
Wordpress. Una de las cosas que tube que aprender a hacer y que en un principio siempre me daban fallos al realizarlas es migrar el blog
de hosting. Como ninguno de mis lectores saben y ya han podido leer aqui, hubo un tiempo en el que tenia
&lt;a href=&quot;http://blog.jam.net.ve/2009/08/17/de-nuevo-problemas-con-el-hosting/&quot;&gt;innumerables problemas&lt;/a&gt; con mi anterior proveedor
de hosting el cual me migraba a cada rato de servidor para intentar solventar la situacion.  En esas migraciones el traslado
del contenido del blog y la base de datos se hacia sacando backups con las herramientas del panel de control web cPanel y luego
eran restauradas en el nuevo servidor, No se porque pero siempre me quedaba mal el blog luego de estas migraciones y restauraciones
mediante cPanel.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Uno de los motivos de estos errores me di cuenta que era que al migrar la base de datos esta quedaba con la vieja ruta de la cuenta de
hosting en donde estaba el contenido del blog en el servidor, por lo que en el nuevo servidor si esta ruta no era la misma, se terminaba
el mundo.&lt;/p&gt;

&lt;p&gt;Bien luego de esto y en otro proceso de migracion de servidor mas, me propuse hacerlo yo mismo y a mi modo y paso a explicar:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Primero que nada debemos realizar un respaldo de los archivos del blog, si tu blog esta en una carpeta podemos comprimir esta y
descargarla para luego trasladarla al nuevo servidor. Esto lo podemos hacer por medio del cPanel con la herramienta
“Administrador de Archivos” seleccionamos la carpeta con el contenido del blog y le damos a “Comprimir”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/sfcjt&quot;&gt;&lt;img src=&quot;http://i.imgur.com/sfcjtl.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/lV9ph&quot;&gt;&lt;img src=&quot;http://i.imgur.com/lV9phl.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Luego de esto debemos sacar un respaldo a la Base de Datos del blog, esto lo podemos hacer usando el PhpMyAdmin que esta en el
cPanel, dandole a la pestaña “Exportar” luego seleccionamos la base de datos en el recuadro del lado superior izquierdo y marcamos la
opcion “SQL” en la parte inferior izquierda. Si deseamos comprimir la base de datos la comprimimos seleccionando cualquiera de los dos
formatos disponibles y le damos a continuar. Esto nos iniciara la descarga de la base de datos de nuetro blog.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/Dn9rU&quot;&gt;&lt;img src=&quot;http://i.imgur.com/Dn9rUl.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/L7m68&quot;&gt;&lt;img src=&quot;http://i.imgur.com/L7m68l.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/mmTy0&quot;&gt;&lt;img src=&quot;http://i.imgur.com/mmTy0s.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Antes que nada deberiamos verificar que en el nuevo servidor nuestro directorio home se llame igual que en el servidor anterior, 
esto en cPanel lo podemos verificar en el panel superior izquierda en donde dice “Directorio Home” si es el mismo podemos pasar a
importar la base de datos en el nuevo servidor por medio de phpMyAdmin, de lo contrario debemos editar la base de datos como explico
a continuacion.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Bien una vez descargada la base de datos pasamos a abrir el archivo .sql en tu editor de codigo favorito
(si usas Windows y la base de datos es de unos cuantos megas no uses el blog de notas, simplemente no esta hecho para esto)
y buscamos la linea en donde este la direccion de nuestro directorio home es algo similar a esto:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/home/usuarioviejoservidor/public_html/blog/&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y cambiamos el nombre de usuario para que quede&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/home/usuarionuevoservidor/public_html/blog/&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;una vez editada la base de datos guardamos los cambios y podemos proceder a importarla en el nuevo servidor por medio de phpMyAdmin
seleccionando la pestaña “Importar” y luego agregando la ruta de la base de datos en nuestra pc por medio del boton
“Browse” le damos al boton “Continuar”&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/KD0fs&quot;&gt;&lt;img src=&quot;http://i.imgur.com/KD0fss.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;si todo a ido bien deberiamos tener importada con exito la base de datos de nuetro blog en el nuevo servidor.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Ahora debemos importar en el nuevo servidor los archivos de nuestro blog, para hacer esto podemos subir el archivo comprimido
por medio de nuestro cliente FTP favorito o tambien por medio de la terminal situandonos en la raiz de nuestra carpeta web
publica (public_html o httpd o html) usando el comando “wget” de este modo:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;wget http://www.tuviejohosting.com/archivos-blog.zip&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;una ves transferido los archivos al nuevo hosting debemos descomprimirlo, para esto podemos usar de nuevo el
“Administrador de archivos” en el cPanel, seleccionamos el archivo compromido y le damos a la opcion “Extraer”&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/lV9ph&quot;&gt;&lt;img src=&quot;http://i.imgur.com/lV9phl.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Bien ahora solo nos falta configurar la nueva conexion entre el blog y la base de datos, para esto debemos crear el usuario
de la base de datos en el nuevo servidor y otorgarles sus respectivos privilegios, esto lo podemos hacer en el mismo cPanel
en la opcion “MySql Basesde Datos”.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;http://imgur.com/ftMQd&quot;&gt;&lt;img src=&quot;http://i.imgur.com/ftMQdl.png&quot; title=&quot;Hosted by imgur.com&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Como nombre de usuarios puedes usar los mismos que tenias en el anterior hosting, al igual que la contraseña
(aunque es aconsejable cambiarla para mayor seguridad).  Tambien en esta misma seccion del cPanel debemos añadir el usuario
que acabas de crear a la base de datos que acabamos de importar para que este sea el que tenga privilegios de uso
de esa base de datos en especifico.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Bien por ultimo ya solo debemos  editar el archivo wp-config.php de nuestro blog y agregar los nuevos datos de conexion
como el nombre de la base de datos, el usuario y la contraseña.  Una vez listo tan solo debemos subirlo y remplazarlo por
el que ya estaba en el nuevo hosting con la informacion del viejo servidor.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bien para este momento ya deberia estar todo bien y funcionando correctamente, pero si como yo tienes las url de
los permalinks (enlaces permanentes) personalizadas, deberas apuntar tu viejo dominio a el nuevo hosting y esperar
a que los cambios en los DNS se rieguen por todo internet para poder ver correctamente el contendido del blog y
para que puedan funcionar los enlaces. Esto por lo general dura como mucho unas horas o mas, pero tambien puede
que este en mucho menos tiempo, asi que tan solo queda esperar y listo.&lt;/p&gt;

&lt;p&gt;Saludos y espero que les haya servido tanto como a mi.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Instalando drivers Madwifi en Ubuntu - Atheros AR928</title>
   <link href="http://blog.jam.net.ve/2009/12/14/instalando-drivers-madwifi-en-ubuntu-9-10-atheros-ar928x"/>
   <updated>2009-12-14T00:00:00-04:30</updated>
   <id>http://blog.jam.net.ve/2009/12/14/instalando-drivers-madwifi-en-ubuntu-9-10-atheros-ar928x</id>
   <content type="html">&lt;p&gt;Hace unas semanas atras estaba comentando que habia instalado Ubuntu 9.10 en mi laptop y que estaba intentando colocar el chip inalambrico en modo monitor para hacer auditorias wifi (contra mi router), Por fin e logrado instalar los drivers Madwifi para mi tarjeta inalambrica la cual es una Atheros AR5009 o como en la web de Madwifi se conoce como AR928X.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Despues de buscar un manual o explicacion para instalarlos, la verdad encontre demasiadas formas de hacerlo, ademas de 3 drivers distintos que podia usar (compat-wireless-2.6.31-rc7, madwifi-hal-0.10.5.6-r4100-20090929 y el madwifi-0.9.4-current) me fui por la explicacion de la pagina &lt;a title=&quot;Drivers para Ath9k&quot; href=&quot;http://linuxwireless.org/en/users/Drivers/ath9k&quot; target=&quot;_blank&quot;&gt;LinuxWireless&lt;/a&gt; e instale el driver madwifi-hal-0.10.5.6-r4100-20090929  ya que me parecio el mas completo de los tres (en realidad es el mas pesado 4.2Mb).&lt;/p&gt;

&lt;p&gt;Para instalarlo solo:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Descague el Drivers desde el &lt;a href=&quot;http://snapshots.madwifi-project.org/&quot; target=&quot;_blank&quot;&gt;Snapshot de Madwifi&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Luego Descomprimimos y abrimos la carpeta en la terminal&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;madwifi-hal-0.10.5.6-r4100-20090929&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;-Ahora  compilamos.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo make&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y ahora instalamos&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo make install&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;con esto ya deberia de tener corrctamente instalado los drivers.&lt;/p&gt;

&lt;p&gt;pero como ando buscando es colocarlo en modo monitor entonces instale el Aircrack-ng:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo apt-get install aircrack-ng&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;y configure la inalambrica en modo monitor en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;airmon-ng start wlan0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;con esto deberia de haber activado el modo monitor, para comprobarlo teclee en la terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;iwconfig&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;el cual me devolvio algo como esto:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;lo        no wireless extensions.
eth0      no wireless extensions.
wlan0     IEEE 802.11abgn  ESSID:&lt;span class=&quot;p&quot;&gt;&amp;amp;&lt;/span&gt;quot&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;Mi Router&lt;span class=&quot;p&quot;&gt;&amp;amp;&lt;/span&gt;quot&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
 Mode:Managed  Frequency:2.437 GHz  Access Point: XX:XX:XX:XX:XX:XX
 Bit &lt;span class=&quot;nv&quot;&gt;Rate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;54&lt;/span&gt; Mb/s   Tx-Power&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;20&lt;/span&gt; dBm
 Retry  long limit:7   RTS thr:off   Fragment thr:off
 Power Management:on
 Link &lt;span class=&quot;nv&quot;&gt;Quality&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;70/70  Signal &lt;span class=&quot;nv&quot;&gt;level&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;-31 dBm
 Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
 Tx excessive retries:0  Invalid misc:0   Missed beacon:0

mon0      IEEE 802.11abgn  Mode:Monitor  Frequency:2.437 GHz  Tx-Power&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;20&lt;/span&gt; dBm
 Retry  long limit:7   RTS thr:off   Fragment thr:off
 Power Management:on&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;notese que se agrego una nueva interfaz el cual se llama “mon0”  esta es la interfaz que se utilizara para trabajar en modo monitor, capturar e inyectar paquetes.&lt;/p&gt;

&lt;p&gt;solo resta ahora instalar algunas otras herramientas al gusto de cada quien, en mi caso aparte de Aircrack instale Kismet el cual me instalo a la vez el WireShark. Con este ultimo puedo usar la interfaz mon0 como interfaz de captura para (valga la rebusnancia ) capturar paquetes.&lt;/p&gt;

&lt;p&gt;Espero que les sirva esta info tanto como a mi.&lt;/p&gt;

&lt;p&gt;Saludos.&lt;/p&gt;
</content>
 </entry>
 

</feed>
