<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Aldrin Martoq - Technical Weblog</title>
	<atom:link href="http://aldrin.martoq.cl/techblog/feed/" rel="self" type="application/rss+xml" />
	<link>http://aldrin.martoq.cl/techblog</link>
	<description>Where I put my code and related stuff to share with the world</description>
	<lastBuildDate>Sat, 16 Jul 2011 08:13:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Los problemas informáticos con el tiempo</title>
		<link>http://aldrin.martoq.cl/techblog/2011/03/los-problemas-informaticos-con-el-tiempo/</link>
		<comments>http://aldrin.martoq.cl/techblog/2011/03/los-problemas-informaticos-con-el-tiempo/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 15:42:11 +0000</pubDate>
		<dc:creator>Aldrin Martoq</dc:creator>
				<category><![CDATA[En Español]]></category>

		<guid isPermaLink="false">http://aldrin.martoq.cl/techblog/?p=340</guid>
		<description><![CDATA[Esta es la continuación al artículo anterior &#8220;El tiempo y los sistemas informáticos&#8220;, en el que intento explicar cómo se maneja la hora local y mundial en los sistemas informáticos actuales. Recomiendo leer dicho artículo antes de continuar, pero aquí un largo resumen: Existe un tiempo universal llamado UTC que se basa en relojes atómicos. [...]]]></description>
			<content:encoded><![CDATA[<p>Esta es la continuación al artículo anterior &#8220;<a title="El tiempo y los sistemas informáticos" href="http://aldrin.martoq.cl/techblog/2011/03/el-tiempo-y-los-sistemas-informaticos/" target="_blank">El tiempo y los sistemas informáticos</a>&#8220;, en el que intento explicar cómo se maneja la hora local y mundial en los sistemas informáticos actuales. Recomiendo leer dicho artículo antes de continuar, pero aquí un largo resumen:</p>
<ul>
<li>Existe un tiempo universal llamado UTC que se basa en relojes atómicos.</li>
<li>Por razones astronómicas UTC agrega/quita segundos a años arbitrarios.</li>
<li>El protocolo NTP permite sincronizar la hora UTC vía Internet con una gran precisión.</li>
<li>UTC sirve de referencia a la zona horaria de cada país/región. Ej: la hora estándar de Chile es CLT ó UTC-04.</li>
<li>Muchos países tienen un cambio de hora o horario de verano. Ej: la hora de verano de Chile es CLST ó UTC-03.</li>
<li>Por razones políticas/económicas/etc cada país ha variado el tiempo de referencia UTC antojadizamente. Este año (2011), Chile movió el cambio de hora en 3 semanas.</li>
<li>La base de datos Olson contiene la información de qué zona horaria es válida para distintos rangos de fechas. Esta base de datos es continuamente actualizada por un grupo de voluntarios en una lista de correo.</li>
<li>NTP no contiene información de zonas horarias ni actualiza el cambio de hora. Los cambios deben hacerse manualmente.</li>
<li>En el mundo globalizado de hoy, los informáticos deben entender cómo manejar el tiempo mundialmente. Por ejemplo, es recomendable usar el formato ISO-8601</li>
</ul>
<p>En el presente artículo intentaré explicar los problemas implicados por el (mal) manejo del tiempo. También la forma en que se resuelven y cuales aún no están resueltos. La idea es generar discusión y (ojalá) generar soluciones (que son bastante obvias) para cada problema en particular.</p>
<p><span id="more-340"></span></p>
<h2>El error de ignorar el problema</h2>
<p>Mucha gente cree que el problema se reduce a eliminar las modificaciones al cambio de horario invierno/verano. Que siempre sea la segunda semana de Marzo/Octubre y ya está. Creen que el tema se soluciona pidiendo a los gobiernos que dejen de ser tan desordenados y que, por favor, paren con mover el cambio de hora apenas dos semanas antes de que ocurra.</p>
<p>Para recalcar que los cambios de horas son inevitables, aquí un resumen del número de cambios al archivo tzdata de la base de datos Olson:</p>

<table id="wp-table-reloaded-id-1-no-1" class="wp-table-reloaded wp-table-reloaded-id-1">
<thead>
	<tr class="row-1 odd">
		<th class="column-1">Año</th><th class="column-2"># versiones</th>
	</tr>
</thead>
<tbody>
	<tr class="row-2 even">
		<td class="column-1">2011</td><td class="column-2">4 (a la fecha)</td>
	</tr>
	<tr class="row-3 odd">
		<td class="column-1">2010</td><td class="column-2">15</td>
	</tr>
	<tr class="row-4 even">
		<td class="column-1">2009</td><td class="column-2">20</td>
	</tr>
	<tr class="row-5 odd">
		<td class="column-1">2008</td><td class="column-2">9</td>
	</tr>
	<tr class="row-6 even">
		<td class="column-1">2007</td><td class="column-2">11</td>
	</tr>
	<tr class="row-7 odd">
		<td class="column-1">2006</td><td class="column-2">14</td>
	</tr>
	<tr class="row-8 even">
		<td class="column-1">2005</td><td class="column-2">17</td>
	</tr>
	<tr class="row-9 odd">
		<td class="column-1">2004</td><td class="column-2">4</td>
	</tr>
	<tr class="row-10 even">
		<td class="column-1">2003</td><td class="column-2">5</td>
	</tr>
	<tr class="row-11 odd">
		<td class="column-1">2002</td><td class="column-2">5</td>
	</tr>
</tbody>
</table>

<p>Cada versión nueva del archivo tzdata incluye mayoritariamente una o más modificaciones a zonas horarias hechas por gobiernos de todo el mundo. Incluso, si los gobiernos dejaran de cambiar la hora antojadizamente, tenemos el problema latente de los segundos intercalares (&#8220;<em>leap seconds</em>&#8220;).</p>
<p>Pero pedir a los gobiernos de todo el mundo que dejen de modificar los cambios de hora es completamente irreal. Aún si nos escucharan, tenemos el caso latente de los segundos intercalares. Sería como pedir a la gente que deje de tener accidentes vehiculares, pues los autos no tienen cinturones de seguridad. O pedir al planeta que gire siempre con la misma velocidad. La informática debe adaptarse a la realidad, no al revés.</p>
<p>De la tabla, observamos que hay al menos 5 cambios por año, pero sin embargo los informáticos gritan, pelean y se preocupan con suerte una o dos veces al año. Lo que sucede es que este cambio es increíblemente complicado y costoso (veremos esto a continuación). Y cada sitio se preocupa exclusivamente de la hora local en el país en que está, por ejemplo en Chile a nadie le interesa actualizar un cambio de zona horaria en Afganistán. Es por esto que Google y muchos servicios &#8220;en la nube&#8221; están mostrando mal los calendarios que quedaron agendados estas semanas en Chile: es muy complicado/es muy caro/que lo resuelvan los usuarios. En resumen, a nadie le importa.</p>
<p>&nbsp;</p>
<h2>Por qué es tan costoso modificar el cambio de hora invierno/verano</h2>
<p>Primero, por un tema de volumen. La cantidad de aparatos y sistemas informáticos no paran de crecer. Cada vez se hacen más invisibles, pero estamos rodeados de sistemas y aparatos: un scanner médico, tu celular, el cajero automático, el reloj del control horario, y un largo etc..</p>
<p>Segundo, por un tema de diversidad: la hora es entregada por el sistema operativo y no todos los aparatos usan el mismo sistema operativo. Luego, el procedimiento es distinto para cada tipo de aparato o sistema informático. Peor aún, <span style="text-decoration: underline;">la gran mayoría de los sistemas no tiene incorporado la funcionalidad para realizar una modificación al cambio de hora</span>. Es un problema aún no resuelto en el mundo de la informática. Es decir, aparte de realizar la modificación, tendremos que analizar los datos del sistema para que ahora estén correctos con el nuevo horario.</p>
<p>Esto significa que cada modificación al cambio de hora se transforma en un <span style="text-decoration: underline;">mega proyecto</span> informático que involucra a <span style="text-decoration: underline;">todos los computadores de cada instalación</span> y a <span style="text-decoration: underline;">todos los sistemas informáticos</span>. Y los gobiernos anuncian la hora con apenas un par de semanas antes de la fecha en que ocurre el cambio de hora automático. <span style="text-decoration: underline;">Un par de semanas antes de que ocurra el cambio es insuficiente para un cambio de esta envergadura</span>. Ninguna empresa está preparada para tremendo proyecto en un par de semanas.</p>
<p>Lo que sucede en la práctica es que la gran mayoría de sistemas falla y presenta una hora incorrecta o información incorrecta.</p>
<p>Además, la precisión o calidad con que los sistemas manejan la hora local/mundial varía bastante. Por ejemplo, el soporte a UTC de los sistemas operativos Microsoft es bastante deficiente: modifican la hora del PC en vez de tener el reloj en UTC y cambiar la representación (esto es fatal para que NTP calcule correctamente la desviación respecto a los relojes atómicos) y no tienen soporte a segundos intercalares. Es probablemente por esto que nunca verás un sistema Windows manejando aparatos que requieren exactitud en este tema, como aparatos astronómicos, de navegación, etc.</p>
<p>Debido a que muchos sistemas operativos lo hacen de manera deficiente, hay mucho software que no usa lo que trae el sistema operativo e incluyen el código de Olson. La máquina virtual de java, servidores MySQL, PHP y un largo etcétera tienen su propio sistema con su propio archivo basado en tzdata. Es decir, para realizar el cambio debemos asegurarnos cada una de las siguientes capas:</p>
<ol>
<li>En el sistema operativo</li>
<li>En cada uno de los subsistemas y plataformas: bases de datos, plataformas de desarrollo, API&#8217;s y middleware</li>
<li>En las aplicaciones</li>
<li>En los datos que tienen las aplicaciones</li>
</ol>
<p>Actualmente, los sistemas UNIX resuelven sólo la primera capa, el sistema operativo: las actualizaciones al archivo tzdata se pueden automatizar sin mucha dificultad. Esta modificación sigue siendo bastante costosa (y muchas veces es simplemente imposible), pero la automatización facilita bastante. Pero las capas 2, 3 y 4 no están contempladas por nadie actualmente. La mayoría de las veces simplemente se ignoran.</p>
<p>Finamente, un par de semanas es insuficiente para que cada proveedor genere un parche a los sistemas. En UNIX usualmente este parche está disponible entre 1 o 2 semanas después de anunciado el cambio de manera oficial, lo que en la práctica implica que el mismo día del cambio se están parchando todos los servidores. Los parches de Microsoft se demoran 1 o 2 meses en salir, en la práctica no hay parche oficial y se debe realizar modificaciones al sistema de manera manual. Apple demora 3 a 4 meses en liberar un parche, tu iPhone se quedará con la hora incorrecta simplemente.</p>
<h2>Las soluciones &#8220;obvias&#8221;</h2>
<ol>
<li>Exigir a los gobiernos que los cambios de hora deben ser anunciados con al menos 8 semanas de anticipación. Esto permite que los proveedores generen un parche a tiempo. Esto no quita el costo, sino que nos permite alcanzar los aparatos y sistemas que simplemente se ignoran cuando un cambio es repentino. Recuerden que esto toca a todos los aparatos y sistemas informáticos.</li>
</ol>
<p>&nbsp;</p>
<h2>Nota de borrador</h2>
<p>Este artículo está en borrador y he decidido lanzarla antes, debido a la urgencia que tenemos hoy en que el Gobierno de Chile intenta mover el cambio de hora a solo 5 días de que este ocurra.</p>
<p>Invito a las autoridades que me inviten a su despacho, yo personalmente les puedo explicar con detalles la gravedad del problema.</p>
]]></content:encoded>
			<wfw:commentRss>http://aldrin.martoq.cl/techblog/2011/03/los-problemas-informaticos-con-el-tiempo/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>El tiempo y los sistemas informáticos</title>
		<link>http://aldrin.martoq.cl/techblog/2011/03/el-tiempo-y-los-sistemas-informaticos/</link>
		<comments>http://aldrin.martoq.cl/techblog/2011/03/el-tiempo-y-los-sistemas-informaticos/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 22:43:08 +0000</pubDate>
		<dc:creator>Aldrin Martoq</dc:creator>
				<category><![CDATA[En Español]]></category>

		<guid isPermaLink="false">http://aldrin.martoq.cl/techblog/?p=315</guid>
		<description><![CDATA[Ante una nueva modificación al horario de invierno en Chile, nuevamente vuelvo a escuchar pequeños y grandes errores respecto a cómo se maneja el tiempo y hora en los sistemas informáticos. Estuve buscando algún artículo que explicara bien el tema en completitud, pero no lo encontré. La idea de este artículo es cubrir esta necesidad. Me [...]]]></description>
			<content:encoded><![CDATA[<p>Ante una nueva modificación al horario de invierno en Chile, nuevamente vuelvo a escuchar pequeños y grandes errores respecto a cómo se maneja el tiempo y hora en los sistemas informáticos. Estuve buscando algún artículo que explicara bien el tema en completitud, pero no lo encontré. La idea de este artículo es cubrir esta necesidad.</p>
<p>Me interesa hablar de los siguientes temas:</p>
<ol>
<li>Muchos sistemas no están preparados para trabajar con distintas zonas horarias. En un mundo globalizado, creo que es inaceptable.</li>
<li>Peor aún, creo que ninguno contempla las (irremediables) modificaciones a los cambios de hora arbitrarios.</li>
<li>El tiempo de referencia oficial no es GMT, sino que UTC.</li>
<li>Existen minutos con más de 60 segundos (y eventualmente con 59 segundos).</li>
<li>NTP no tiene nada que ver con el cambio de hora, la zona horaria ni el horario de invierno/verano.</li>
<li>Los sistemas deben dejar de usar el formato DD/MM/YY.</li>
<li>Este es un problema aún no resuelto, pero se puede mejorar en varios aspectos.</li>
</ol>
<p>Si le asombra una o más de las sentencias de arriba, lo invito a seguir leyendo.</p>
<p><span id="more-315"></span></p>
<h2>El tiempo, unidad de medida continua y regular</h2>
<p>El primer supuesto que toma la mayoría de sistemas informáticos es que el tiempo es completamente continuo y uniforme en todo el universo. Esto no es cierto (ya tendremos problemas cuando los viajes espaciales se hagan habituales), pero por ahora asumiremos esto.</p>
<p>Al tomar el tiempo de esta forma, podemos suponer que en cualquier parte del mundo es la misma hora. Podemos definir una &#8220;<em>hora universal</em>&#8220;. Cada país puede tener su hora oficial en referencia a la hora universal, y es lo que nos permite coordinar una reunión en Chile a las 09:00 hrs por la mañana con gente en Finlandia a las 14:00 hrs en la tarde. ¡Fácil y bonito! ¿No?</p>
<p>Bueno, no tanto, pues ahora comienzan las complicaciones&#8230;</p>
<h2>Es UTC, no GMT&#8230; por favor</h2>
<div class="wp-caption alignright" style="width: 435px"><a href="http://es.wikipedia.org/wiki/GMT"><img class="thumbimage " src="http://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/LengthOfDay_1974_2005.png/425px-LengthOfDay_1974_2005.png" alt="" width="425" height="205" /></a><p class="wp-caption-text">Variación día solar medio (fuente: Wikipedia)</p></div>
<p>Desde 1880+ la hora universal era calculada en base al tiempo solar medio. Esto es: se observa astronómicamente cuánto demora la tierra en dar una vuelta completa sobre si misma. Ese tiempo lo dividimos en 86400 segundos y ya está, tenemos hora oficial con la cual todos podemos sincronizarnos. Esto es lo que se conoce como GMT, pues es la hora en el meridiano de Greenwich.</p>
<p>El problema es que el tiempo solar medio es bastante irregular, no es para nada una medida estable. Si observan el gráfico, en general cada año la tierra gira mas lento y los días se van alargando, pero hay distintos fenómenos que modifican la velocidad en ambos sentidos (por ejemplo, los terremotos).</p>
<p>Esta variación en la medida de tiempo es inaceptable para muchas aplicaciones y sistemas. ¡Imaginen tener que parchar continuamente sus sistemas para redefinir el largo de un segundo!</p>
<p>Desde 1972, GMT es reemplazado por un nuevo estándar de tiempo universal: UTC que en inglés reza <em>&#8220;Coordinated Universal Time&#8221;</em> y en francés: <em>&#8220;Temps Universel Coordonné&#8221;.</em> O sea, no lograron ponerse de acuerdo en las siglas.</p>
<p>En UTC el largo de un segundo siempre es el mismo, pues está basado en relojes atómicos. Esto es muy ventajoso, nos permite tener muchos sistemas sincronizados con muy poco error, incluso a la milésima de segundo. Ya no es necesario ajustar los sistemas a los caprichos del tiempo solar medio. ¡Menos mal!</p>
<p>Lo relevante es que hoy en día UTC es el tiempo universal usado como referencia por todos los países. Esto es importante por las triquiñuelas que tiene, veamos.</p>
<h2>Segundos intercalares o en sintonía con la tierra</h2>
<p>En UTC tenemos segundos (y milisegundos, microsegundos, etc) estables. El problema de tener un segundo estable es que la tierra cada vez gira mas lento. A lo largo de los años, las 12:00pm de nuestro sistema informático será muy distinta a las 12:00pm astronómica. UTC resuelve esto haciendo que la duración de los minutos, horas y días sea variable.</p>
<p>Bueno, la mayoría de los días tiene 86400 segundos, pero hay días que tienen 1 segundo adicional. El último minuto, de la última hora del día en vez de 60 puede tener 61 segundos, y este segundo extra es llamado &#8220;<em>segundo intercalar</em>&#8221; (<em>leap second</em> en inglés). Es decir, el 31 de Diciembre de 2008 a las 23:59:<span style="text-decoration: underline;">60</span> UTC es una fecha válida.</p>
<p>No es tan raro si piensan que tenemos algo muy parecido con los días: Febrero 29 para los años bisiestos.</p>
<p>Puedes ver una <a href="http://en.wikipedia.org/wiki/Leap_second">lista de los segundos que han sido agregados en wikipedia</a>, ya van 24 a la fecha. Como recordarán, la tierra cambia de velocidad irregularmente, no es algo que se pueda pre-calcular. Luego, se han agregado segundos intercalares arbitrariamente según observaciones astronómicas del movimiento de la tierra. También está contemplado que existan minutos con menos de 60 segundos, por si se diera el caso que la tierra gire más rápido, cosa que no ha ocurrido.</p>
<div class="wp-caption alignright" style="width: 310px"><a href="http://en.wikipedia.org/wiki/Leap_second"><img class="thumbimage " src="http://upload.wikimedia.org/wikipedia/en/thumb/5/54/Leapsecond.png/300px-Leapsecond.png" alt="" width="300" height="95" /></a><p class="wp-caption-text">Ejemplo de segundo intercalar (Wikipedia)</p></div>
<p>Notar en la imagen que el segundo adicional es agregado a las 23:59:59 de la hora universal, pero localmente el segundo adicional será a medio día, a las 4 de la tarde, etc dependiendo de tu zona horaria.</p>
<p>Esto tiene <strong>enormes implicancias en los sistemas informáticos</strong>. Por ejemplo, si tu aplicación suma 60*60*24*30 segundos para decir &#8220;30 días a partir de hoy&#8221; lo estás haciendo mal, el resultado puede caer en el día 29 si te topas con el segundo adicional.</p>
<p>Es por esto que <strong>siempre debes utilizar un API</strong> que maneje segundos, días, meses y años &#8220;<strong>gregorianos</strong>&#8220;. Por favor, no lo hagas tú manualmente. Y espera, que el manejo del tiempo se complica más. Aún no terminamos.</p>
<h2>Sincronizando el tiempo</h2>
<p>El siguiente problema a resolver es cómo mantener nuestros sistemas sincronizados, esto es, con la misma hora y con la menor diferencia posible. Para esto existe el protocolo NTP (<em>Network Time Protocol</em>), el cual consiste en servidores que dan la hora y clientes que intentan sincronizarse con dichos servidores.</p>
<p>Si bien esto parece trivial, no lo es. De partida, la latencia variable en internet hace que los paquetes lleguen desordenados y varios milisegundos después (una vuelta completa desde Chile a EE.UU es al menos 150ms). El protocolo NTP debe compensar este hecho. Luego, es más complicado que copiar la hora de un servidor a otro (¡como muchos lo hacen!), pues el error se amplifica rápidamente.</p>
<p>Tal vez encuentres que un segundo no es tanto y para qué tanto escándalo. Pero hay muchas, demasiadas aplicaciones que no funcionan bien si no tienes relojes muy, muy bien sincronizados. Y en el resto, lo deseable es que la diferencia sea a lo más de unos 100 milisegundos. Si eres un administrador de sistemas, querrás por muchas razones tener los servidores y dispositivos con la misma fecha y hora.</p>
<p>El tema es tan importante, que el cliente NTP no llega y copia la hora del servidor. Sucede que el reloj de tu computador no es tan exacto comparado con un reloj atómico, por lo que tiene un error (supongamos -10 milisegundos cada 30 días). Entonces, el cliente NTP lo que hace es calcular ese error.</p>
<p>Puedes programar que tu computador inunde de consultas el servidor NTP y copie la hora (esto se llama SNTP), pero tendrás una precisión muy, muy mala y no es lo recomendado.</p>
<div class="wp-caption alignright" style="width: 210px"><a href="http://en.wikipedia.org/wiki/Network_Time_Protocol"><img class=" " src="http://upload.wikimedia.org/wikipedia/commons/thumb/c/c9/Network_Time_Protocol_servers_and_clients.svg/200px-Network_Time_Protocol_servers_and_clients.svg.png" alt="" width="200" height="179" /></a><p class="wp-caption-text">NTP stratum (fuente: Wikipedia)</p></div>
<p>Tal vez te estás preguntado cómo los servidores principales mantienen la hora tan bien. Los computadores que están conectados directamente a un reloj atómico están en <em>Stratum 0</em>. Luego están los servidores NTP conectados a ellos, y son <em>Stratum 1</em>. Y luego los servidores que consultan a los anteriores, que son <em>Stratum 2</em> y etcétera.</p>
<p>Lo ideal es que tengas en tu datacenter un servidor NTP que hable directamente con ntp.shoa.cl (la hora oficial en Chile), y luego todos tus servidores/computadores/etc se conectan a este servidor. Tendrás diferencias muy pequeñas dentro de tu red y no saturarás al servidor oficial.</p>
<p>Por último, el protocolo NTP sólo da la hora universal (UTC, <span style="text-decoration: underline;">incluyendo</span> segundos intercalares). Pero <strong>NTP</strong> no tiene <strong>nada que ver </strong>con la <strong>hora local</strong> de tu país ni si estamos en el <strong>horario de verano</strong>. Este problema lo veremos a continuación.</p>
<h2>La hora en el mundo</h2>
<p>Hasta ahora tenemos una hora oficial (UTC), correcciones arbitrarias (segundos intercalares) y un mecanismo de sincronización (NTP). Podemos definir distintas zonas horarias respecto a la hora universal UTC.</p>
<div class="wp-caption alignright" style="width: 410px"><a href="http://es.wikipedia.org/wiki/TZ_Database"><img class="thumbimage  " src="http://upload.wikimedia.org/wikipedia/commons/thumb/9/9f/Tz_map_world2009r_efeledotnet.png/400px-Tz_map_world2009r_efeledotnet.png" alt="" width="400" height="204" /></a><p class="wp-caption-text">Zonas Horarias según base de datos TZ (fuente: Wikipedia)</p></div>
<p>Debemos considerar que las zonas horarias están definidas por límites políticos y no por el meridiano que nos corresponda. La diferencia horaria se escoge antojadizamente y no tiene relación con la &#8220;real&#8221;. En el caso de Chile, por longitud estamos dentro de la zona UTC-5, pero la hora estándar en Chile continental es UTC-4. Hay países que tienen más de una zona horaria: por ejemplo, Chile tiene además hora insular UTC-6, México tiene 3 zonas, etc.</p>
<p>Hoy en un mundo globalizado, una gran mayoría de sistemas informáticos almacenan y trabajan la hora en formato UTC. Esto garantiza que un evento se pueda mostrar en distintas zonas horarias del mundo. Por ejemplo, si tenemos una reunión el Lunes 9 de Mayo de 2011 a las 09:00 am CLT (UTC-4), el sistema almacena el evento con fecha Lunes 9 de Mayo de 2011 a las 13:00 pm UTC. Si el usuario está en Chile, se despliega la hora de la reunión restando 4 horas a la hora UTC; o en Ciudad de México la reunión se desplegará Lunes 9 de Mayo de 2011 a las 07:00 am CST (UTC-6).</p>
<p>Aparte de almacenar la hora UTC de un evento, otra opción válida es almacenar la hora local incluyendo la zona actual. Por ejemplo Lunes 9 de Mayo de 2011 a las 09:00 am CLT (notar CLT, que indica que la hora local está a UTC-4). Les debo la explicación de por qué esto es mejor que guardar UTC-4 o traducir a UTC.</p>
<h2>Arbitrariedad y el Horario de verano</h2>
<p>Esto no sería nada de grave si hubiéramos llegado hasta aquí. El problema es que la definición de zona horaria <span style="text-decoration: underline;">es, ha sido y será antojadiza</span>. Chile ha tenido zonas horarias UTC-5, UTC-4 y UTC-3 (pueden leer <a href="http://www.horaoficial.cl/horaof.htm">historia de la hora oficial</a>). Por distintas razones económicas, políticas o las que sean. Lo <span style="text-decoration: underline;">único seguro es que seguirán cambiando</span>, así como <span style="text-decoration: underline;">habrán más segundos intercalares</span> en el futuro y <span style="text-decoration: underline;">no sabemos cuándo</span>.</p>
<p>Además, tenemos el concepto de horario de verano que es usado por muchos países. Cada año en Octubre se modifica la zona horaria a UTC-3 (CLST o <em>Chile Summer Time</em>) y se restaura en Marzo a UTC-4 (CLT o <em>Chile Time</em>). Esta modificación de zona también es antojadiza y es susceptible a cambios repentinos.</p>
<p>Todo esto es un gran dolor de cabeza para toda la gente que administra sistemas informáticos. Para comparar, cuenta en tu hogar los aparatos que manejan fecha y hora: celulares, computadores, microondas, televisores, cable satelital, etc. Y relojes, por supuesto. Imagina que debes tener todo sincronizado y lo engorroso que es, pues cada uno se configura de manera distinta. Ahora multiplica el número por 10, 100 e incluso 1000 y te darás cuenta de lo problemático que es.</p>
<p>Chile no es el único país que realiza estos cambios antojadizos. Son muchos los países y los cambios ocurren periódicamente. Es decir, si tienes una aplicación como un Calendario y tienes usuarios de todos los países, deberías estar pendiente de actualizar esta información periódicamente (¿Aló Google?).</p>
<p>Afortunadamente, hay gente que ha trabajado en una solución.</p>
<h2>Olson y la base de datos TZ</h2>
<p>La <a href="http://www.twinsun.com/tz/tz-link.htm">base de datos TZ</a> o <em>base de datos Olson</em> es una iniciativa iniciada por Arthur David Olson, que consiste en código fuente y archivos con todas las modificaciones arbitrarias conocidas hasta el momento; es decir: segundos intercalares, zonas horarias, horario de verano/invierno y el historial de los cambios.</p>
<p>Un extracto del archivo que describe a Chile es el siguiente:</p>
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># From Glenn Eychaner (2011-03-02): [geychaner@mac.com]</span><br />
<span style="color: #666666; font-style: italic;"># It appears that the Chilean government has decided to postpone the</span><br />
<span style="color: #666666; font-style: italic;"># change from summer time to winter time again, by three weeks to April</span><br />
<span style="color: #666666; font-style: italic;"># 2nd:</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># http://www.emol.com/noticias/nacional/detalle/detallenoticias.asp?idnoticia=467651</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># This is not yet reflected in the offical &quot;cambio de hora&quot; site, but</span><br />
<span style="color: #666666; font-style: italic;"># probably will be soon:</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># http://www.horaoficial.cl/cambio.htm</span><br />
<span style="color: #666666; font-style: italic;"># </span><br />
<br />
<span style="color: #666666; font-style: italic;"># From Arthur David Olson (2011-03-02):</span><br />
<span style="color: #666666; font-style: italic;"># The emol.com article mentions a water shortage as the cause of the</span><br />
<span style="color: #666666; font-style: italic;"># postponement, which may mean that it's not a permanent change.</span><br />
<span style="color: #666666; font-style: italic;"># Rule &nbsp;NAME &nbsp; &nbsp;FROM &nbsp; &nbsp;TO &nbsp; &nbsp; &nbsp;TYPE &nbsp; &nbsp;IN &nbsp; &nbsp; &nbsp;ON &nbsp; &nbsp; &nbsp;AT &nbsp; &nbsp; &nbsp;SAVE &nbsp; &nbsp;LETTER/S</span><br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1927</span> &nbsp; &nbsp;<span style="color: #000000;">1932</span> &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Sep &nbsp; &nbsp; &nbsp;<span style="color: #000000;">1</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">0</span>:00 &nbsp; &nbsp;<span style="color: #000000;">1</span>:00 &nbsp; &nbsp;S<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1928</span> &nbsp; &nbsp;<span style="color: #000000;">1932</span> &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Apr &nbsp; &nbsp; &nbsp;<span style="color: #000000;">1</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">0</span>:00 &nbsp; &nbsp;<span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1942</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Jun &nbsp; &nbsp; &nbsp;<span style="color: #000000;">1</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">4</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1942</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Aug &nbsp; &nbsp; &nbsp;<span style="color: #000000;">1</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">5</span>:00u &nbsp; <span style="color: #000000;">1</span>:00 &nbsp; &nbsp;S<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1946</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Jul &nbsp; &nbsp; <span style="color: #000000;">15</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">4</span>:00u &nbsp; <span style="color: #000000;">1</span>:00 &nbsp; &nbsp;S<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1946</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Sep &nbsp; &nbsp; &nbsp;<span style="color: #000000;">1</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span>:00 &nbsp; &nbsp;-<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1947</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Apr &nbsp; &nbsp; &nbsp;<span style="color: #000000;">1</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">4</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1968</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Nov &nbsp; &nbsp; &nbsp;<span style="color: #000000;">3</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">4</span>:00u &nbsp; <span style="color: #000000;">1</span>:00 &nbsp; &nbsp;S<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1969</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Mar &nbsp; &nbsp; <span style="color: #000000;">30</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1969</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Nov &nbsp; &nbsp; <span style="color: #000000;">23</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">4</span>:00u &nbsp; <span style="color: #000000;">1</span>:00 &nbsp; &nbsp;S<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1970</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Mar &nbsp; &nbsp; <span style="color: #000000;">29</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1971</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Mar &nbsp; &nbsp; <span style="color: #000000;">14</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1970</span> &nbsp; &nbsp;<span style="color: #000000;">1972</span> &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Oct &nbsp; &nbsp; Sun<span style="color: #000000; font-weight: bold;">&gt;</span>=<span style="color: #000000;">9</span> &nbsp;<span style="color: #000000;">4</span>:00u &nbsp; <span style="color: #000000;">1</span>:00 &nbsp; &nbsp;S<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1972</span> &nbsp; &nbsp;<span style="color: #000000;">1986</span> &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Mar &nbsp; &nbsp; Sun<span style="color: #000000; font-weight: bold;">&gt;</span>=<span style="color: #000000;">9</span> &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1973</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Sep &nbsp; &nbsp; <span style="color: #000000;">30</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">4</span>:00u &nbsp; <span style="color: #000000;">1</span>:00 &nbsp; &nbsp;S<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1974</span> &nbsp; &nbsp;<span style="color: #000000;">1987</span> &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Oct &nbsp; &nbsp; Sun<span style="color: #000000; font-weight: bold;">&gt;</span>=<span style="color: #000000;">9</span> &nbsp;<span style="color: #000000;">4</span>:00u &nbsp; <span style="color: #000000;">1</span>:00 &nbsp; &nbsp;S<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1987</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Apr &nbsp; &nbsp; <span style="color: #000000;">12</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1988</span> &nbsp; &nbsp;<span style="color: #000000;">1989</span> &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Mar &nbsp; &nbsp; Sun<span style="color: #000000; font-weight: bold;">&gt;</span>=<span style="color: #000000;">9</span> &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1988</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Oct &nbsp; &nbsp; Sun<span style="color: #000000; font-weight: bold;">&gt;</span>=<span style="color: #000000;">1</span> &nbsp;<span style="color: #000000;">4</span>:00u &nbsp; <span style="color: #000000;">1</span>:00 &nbsp; &nbsp;S<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1989</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Oct &nbsp; &nbsp; Sun<span style="color: #000000; font-weight: bold;">&gt;</span>=<span style="color: #000000;">9</span> &nbsp;<span style="color: #000000;">4</span>:00u &nbsp; <span style="color: #000000;">1</span>:00 &nbsp; &nbsp;S<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1990</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Mar &nbsp; &nbsp; <span style="color: #000000;">18</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1990</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Sep &nbsp; &nbsp; <span style="color: #000000;">16</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">4</span>:00u &nbsp; <span style="color: #000000;">1</span>:00 &nbsp; &nbsp;S<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1991</span> &nbsp; &nbsp;<span style="color: #000000;">1996</span> &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Mar &nbsp; &nbsp; Sun<span style="color: #000000; font-weight: bold;">&gt;</span>=<span style="color: #000000;">9</span> &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1991</span> &nbsp; &nbsp;<span style="color: #000000;">1997</span> &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Oct &nbsp; &nbsp; Sun<span style="color: #000000; font-weight: bold;">&gt;</span>=<span style="color: #000000;">9</span> &nbsp;<span style="color: #000000;">4</span>:00u &nbsp; <span style="color: #000000;">1</span>:00 &nbsp; &nbsp;S<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1997</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Mar &nbsp; &nbsp; <span style="color: #000000;">30</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1998</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Mar &nbsp; &nbsp; Sun<span style="color: #000000; font-weight: bold;">&gt;</span>=<span style="color: #000000;">9</span> &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1998</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Sep &nbsp; &nbsp; <span style="color: #000000;">27</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">4</span>:00u &nbsp; <span style="color: #000000;">1</span>:00 &nbsp; &nbsp;S<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1999</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Apr &nbsp; &nbsp; &nbsp;<span style="color: #000000;">4</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">1999</span> &nbsp; &nbsp;max &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; Oct &nbsp; &nbsp; Sun<span style="color: #000000; font-weight: bold;">&gt;</span>=<span style="color: #000000;">9</span> &nbsp;<span style="color: #000000;">4</span>:00u &nbsp; <span style="color: #000000;">1</span>:00 &nbsp; &nbsp;S<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">2000</span> &nbsp; &nbsp;<span style="color: #000000;">2007</span> &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Mar &nbsp; &nbsp; Sun<span style="color: #000000; font-weight: bold;">&gt;</span>=<span style="color: #000000;">9</span> &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
<span style="color: #666666; font-style: italic;"># N.B.: the end of March 29 in Chile is March 30 in Universal time,</span><br />
<span style="color: #666666; font-style: italic;"># which is used below in specifying the transition.</span><br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">2008</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Mar &nbsp; &nbsp; <span style="color: #000000;">30</span> &nbsp; &nbsp; &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">2009</span> &nbsp; &nbsp;only &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Mar &nbsp; &nbsp; Sun<span style="color: #000000; font-weight: bold;">&gt;</span>=<span style="color: #000000;">9</span> &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">2010</span> &nbsp; &nbsp;<span style="color: #000000;">2011</span> &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; Apr &nbsp; &nbsp; Sun<span style="color: #000000; font-weight: bold;">&gt;</span>=<span style="color: #000000;">1</span> &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
Rule &nbsp; &nbsp;Chile &nbsp; <span style="color: #000000;">2012</span> &nbsp; &nbsp;max &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; Mar &nbsp; &nbsp; Sun<span style="color: #000000; font-weight: bold;">&gt;</span>=<span style="color: #000000;">9</span> &nbsp;<span style="color: #000000;">3</span>:00u &nbsp; <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; -<br />
<br />
<span style="color: #666666; font-style: italic;"># IATA SSIM anomalies: (1992-02) says 1992-03-14;</span><br />
<span style="color: #666666; font-style: italic;"># (1996-09) says 1998-03-08. &nbsp;Ignore these.</span><br />
<span style="color: #666666; font-style: italic;"># Zone &nbsp;NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GMTOFF &nbsp;RULES &nbsp; FORMAT &nbsp;[UNTIL]</span><br />
Zone America<span style="color: #000000; font-weight: bold;">/</span>Santiago &nbsp; -<span style="color: #000000;">4</span>:<span style="color: #000000;">42</span>:<span style="color: #000000;">46</span> - &nbsp; &nbsp; &nbsp;LMT &nbsp; &nbsp; <span style="color: #000000;">1890</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -<span style="color: #000000;">4</span>:<span style="color: #000000;">42</span>:<span style="color: #000000;">46</span> - &nbsp; &nbsp; &nbsp;SMT &nbsp; &nbsp; <span style="color: #000000;">1910</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># Santiago Mean Time</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -<span style="color: #000000;">5</span>:00 &nbsp; - &nbsp; &nbsp; &nbsp; CLT &nbsp; &nbsp; <span style="color: #000000;">1916</span> Jul &nbsp;<span style="color: #000000;">1</span> <span style="color: #666666; font-style: italic;"># Chile Time</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -<span style="color: #000000;">4</span>:<span style="color: #000000;">42</span>:<span style="color: #000000;">46</span> - &nbsp; &nbsp; &nbsp;SMT &nbsp; &nbsp; <span style="color: #000000;">1918</span> Sep &nbsp;<span style="color: #000000;">1</span> <span style="color: #666666; font-style: italic;"># Santiago Mean Time</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -<span style="color: #000000;">4</span>:00 &nbsp; - &nbsp; &nbsp; &nbsp; CLT &nbsp; &nbsp; <span style="color: #000000;">1919</span> Jul &nbsp;<span style="color: #000000;">1</span> <span style="color: #666666; font-style: italic;"># Chile Time</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -<span style="color: #000000;">4</span>:<span style="color: #000000;">42</span>:<span style="color: #000000;">46</span> - &nbsp; &nbsp; &nbsp;SMT &nbsp; &nbsp; <span style="color: #000000;">1927</span> Sep &nbsp;<span style="color: #000000;">1</span> <span style="color: #666666; font-style: italic;"># Santiago Mean Time</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -<span style="color: #000000;">5</span>:00 &nbsp; Chile &nbsp; CL<span style="color: #000000; font-weight: bold;">%</span>sT &nbsp; <span style="color: #000000;">1947</span> May <span style="color: #000000;">22</span> <span style="color: #666666; font-style: italic;"># Chile Time</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -<span style="color: #000000;">4</span>:00 &nbsp; Chile &nbsp; CL<span style="color: #000000; font-weight: bold;">%</span>sT<br />
Zone Pacific<span style="color: #000000; font-weight: bold;">/</span>Easter &nbsp; &nbsp; -<span style="color: #000000;">7</span>:<span style="color: #000000;">17</span>:<span style="color: #000000;">44</span> - &nbsp; &nbsp; &nbsp;LMT &nbsp; &nbsp; <span style="color: #000000;">1890</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -<span style="color: #000000;">7</span>:<span style="color: #000000;">17</span>:<span style="color: #000000;">28</span> - &nbsp; &nbsp; &nbsp;EMT &nbsp; &nbsp; <span style="color: #000000;">1932</span> Sep &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># Easter Mean Time</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -<span style="color: #000000;">7</span>:00 &nbsp; Chile &nbsp; EAS<span style="color: #000000; font-weight: bold;">%</span>sT &nbsp;<span style="color: #000000;">1982</span> Mar <span style="color: #000000;">13</span> <span style="color: #000000;">21</span>:00 <span style="color: #666666; font-style: italic;"># Easter I Time</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -<span style="color: #000000;">6</span>:00 &nbsp; Chile &nbsp; EAS<span style="color: #000000; font-weight: bold;">%</span>sT</div></div></div>
<p>Una de las ventajas de la base de datos Olson es que declaró las regiones o zonas de manera &#8220;sencilla&#8221; para cualquier persona. Por ejemplo, la zona correspondiente a Chile continental es &#8220;<em>America/Santiago</em>&#8221; y su descripción es &#8220;<em>Most locations</em>&#8221; y para Chile insular &#8220;<em>Pacific/Easter</em>&#8221; con descripción &#8220;<em>Easter Island &amp; Sala y Gomez</em>&#8220;. Si has visto estas descripciones al escoger tu zona horaria, tu sistema usa la base de datos Olson.</p>
<p>Cabe hacer notar que todas las modificaciones a esta base de datos no es información oficial. Es solo gente común que por el bien de todos mantiene dicha información lo más veraz y actualizada posible. Basta contactarse en la lista de correos de la iniciativa, cualquiera de nosotros puede hacerlo.</p>
<p>Hoy muchos sistemas UNIX, bases de datos y plataformas utilizan la base de datos Olson para manejar correctamente zonas horarias, segundos intercalares y horario de verano. Sí, también las modificaciones arbitrarias a última hora.</p>
<p>Pero este sistema está lejos de ser perfecto, pues esta base de datos no está disponible en línea como el servicio NTP. Debe ser actualizada manualmente por cada computador, plataforma o sistema que use los archivos y muchas veces el archivo no es único sino que está varias veces en un mismo sistema.</p>
<p>Es por esto que una modificación al cambio de hora es un dolor de cabeza para los administradores de sistemas: Debemos actualizar: Sistema Operativo, Bases de datos (ej: MySQL), Lenguajes y Frameworks (ej: PHP y Java) y un largo etcétera.</p>
<h2>Representaciones de fecha</h2>
<p>Debo reiterar que es imperativo en el mundo de hoy hacer sistemas informáticos globalizados.</p>
<p>Lo que quiero recalcar ahora es la representación de las fechas. Lamentablemente el formato de fecha de Chile es distinto que el de EE.UU., por ejemplo. Ya saben: DD/MM/YY versus MM/DD/YY. Es algo trivial, pero genera confusión tanto a las personas como al software para expresar y leer una fecha como 02/03/04.</p>
<p>La solución a esto es el estándar <a href="http://es.wikipedia.org/wiki/ISO_8601">ISO 8601</a>, el cual define un formato del estilo YYYY-MM-DD y por supuesto incluye cosas como la zona horaria. Les ruego que lean al menos el artículo de Wikipedia, completo. Notar que el estándar también define intervalos y períodos, por ejemplo 1 vez al mes es &#8220;P1M&#8221;, algo muy útil y que mucho software sabe generar y leer (parser) actualmente.</p>
<p>Sé que muchos de sus clientes encuentran que la fecha &#8220;2011-03-08 19:29:34&#8243; es horrible, incorrecta y debe mostrarse como &#8220;19:29:34 08/03/11&#8243;. Enseñen, por favor,  que en el mundo de hoy debemos pensar globalizadamente.</p>
<p style="text-align: center;">§</p>
<h2>Conclusiones y los problemas no resueltos</h2>
<p>No he terminado de levantar todos los temas, pero espero haber logrado destacar que el tema del tiempo es un problema complicado de manejar en informática.</p>
<p>Como norma es obligatorio utilizar algún API para trabajar con fechas y hora. Hacerlo manualmente es muy difícil y probablemente tu sistema tenga errores inesperados.</p>
<p>Espero hablar de los problemas actuales en un próximo artículo, pues este ya quedó demasiado extenso&#8230; Por el mismo canal y, tal vez, a la misma hora.</p>
<p style="text-align: center;">§</p>
<p>Nota 1: Es muy posible que tenga más de un error en este artículo, por favor no dude en enviarme su corrección. ¡Gracias!</p>
<p>Nota 2: Usualmente escribo en inglés en este blog, por hacerme el <em>cool</em> y enfocarme en audiencia global en vez de local. Esta es una excepción, pues me interesa que localmente se genere una discusión y ojalá se gestionen mejoras.</p>
<p style="text-align: center;">§</p>
<p><strong>Actualizaciones 2011-03-10</strong></p>
<ul>
<li>correcciones sugeridas por Alejandro Weinstein; errores menores de redacción, gramática, etc.</li>
<li>correcciones sugeridas por Álvaro Herrera.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://aldrin.martoq.cl/techblog/2011/03/el-tiempo-y-los-sistemas-informaticos/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How to start programming in rails 3, in windows</title>
		<link>http://aldrin.martoq.cl/techblog/2010/11/how-to-start-programming-in-rails-3-in-windows/</link>
		<comments>http://aldrin.martoq.cl/techblog/2010/11/how-to-start-programming-in-rails-3-in-windows/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 16:47:51 +0000</pubDate>
		<dc:creator>Aldrin Martoq</dc:creator>
				<category><![CDATA[Ruby on Rails 3]]></category>

		<guid isPermaLink="false">http://aldrin.martoq.cl/techblog/?p=289</guid>
		<description><![CDATA[I really, really liked rails 3. So much, I tried really hard to use it in another project&#8230; and failed. Well, among other things, most people use Microsoft Windows out there. And they find extremely difficult unix-style installations. For me, it&#8217;s natural the solution of installing libssl-dev and rebuilding ruby when &#8220;gem install&#8221; fails because [...]]]></description>
			<content:encoded><![CDATA[<p>I really, really liked rails 3. So much, I tried really hard to use it in another project&#8230; and failed.</p>
<p>Well, among other things, most people use Microsoft Windows out there. And they find extremely difficult unix-style installations. For me, it&#8217;s natural the solution of installing libssl-dev and rebuilding ruby when &#8220;gem install&#8221; fails because an error ocurrs in net/https. But normal people don&#8217;t.</p>
<p>So, if you are running Windows this howto is for you.</p>
<h2><span id="more-289"></span>Installing rails 3</h2>
<p>Because Windows doesn&#8217;t have a system wide ruby installation (like Mac OS or Linux), it doesn&#8217;t make sense to use something atop like RVM. We just need to install ruby 1.9.2 and then go up.</p>
<p>Go to <a href="http://rubyforge.org/projects/rubyinstaller/">http://rubyforge.org/projects/rubyinstaller/</a> and download latest ruby release, I&#8217;m using ruby <a href="http://rubyforge.org/frs/?group_id=167&amp;release_id=44412">1.9.2-p0</a>.</p>
<p>Just follow the wizard, but in the 3rd screen select &#8220;Add Ruby to PATH&#8221;.</p>
<p><a href="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/11/ruby.png" rel="shadowbox[post-289];player=img;"><img class="aligncenter size-full wp-image-301" title="ruby" src="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/11/ruby.png" alt="" width="503" height="388" /></a></p>
<p>Ruby will be installed inside C:\Ruby192. To check everything is ok, open a console and run &#8220;ruby -v&#8221;, you should see &#8220;ruby 1.9.2p0 (2010-08-18) [i386-mingw32]&#8220;.</p>
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\&gt; ruby -v<br />
ruby 1.9.2p0 <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2010</span>-08-<span style="color: #cc66cc;">18</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#91;</span>i386-mingw32<span style="color: #66cc66;">&#93;</span><br />
<br />
C:\&gt; gem install rails<br />
C:\&gt; rails -v<br />
Rails 3.0.3</div></div></div>
<h2>Creating &amp; running a test application</h2>
<p>Now create a new application</p>
<div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\&gt; rails new testapp &amp;&amp; <a href="http://www.ss64.com/nt/cd.html"><span style="color: #b1b100; font-weight: bold;">cd</span></a> testapp</div></div></div>
<p>And start the server. It should fail (like in unix) because sqlite3-ruby is not installed:</p>
<div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; rails s<br />
Could <a href="http://www.ss64.com/nt/not.html"><span style="color: #000000; font-weight: bold;">not</span></a> find gem 'sqlite3-ruby <span style="color: #66cc66;">&#40;</span>&amp;&gt;= 0, runtime<span style="color: #66cc66;">&#41;</span>' <a href="http://www.ss64.com/nt/in.html"><span style="color: #00b100; font-weight: bold;">in</span></a> any of the gem sources.<br />
Try running `bundle install`.</div></div></div>
<p>Instead of running “gem install foo bar”, rails 3 comes with bundle: when you get a new project, run bundle to check dependencies and install missing gems. You can specify your own dependencies in the “Gemfile”.</p>
<div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; bundle</div></div></div>
<p>If you try to run the server again, you&#8217;ll get an error:</p>
<p><a href="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/11/sqlite3-error.png" rel="shadowbox[post-289];player=img;"><img class="aligncenter size-full wp-image-309" title="sqlite3 error" src="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/11/sqlite3-error.png" alt="" width="677" height="342" /></a></p>
<p>Go to <a href="http://www.sqlite.org/download.html">http://www.sqlite.org/download.html</a> and below &#8220;Precompiled Binaries For Windows&#8221; download both sqlite-3*.zip and sqlitedll-3*.zip the &#8220;Precompiled Binaries For Windows&#8221; (I&#8217;m using <a href="http://www.sqlite.org/sqlite-3_7_3.zip">sqlite-3_7_3.zip</a> and <a href="http://www.sqlite.org/sqlitedll-3_7_3.zip">sqlitedll-3_7_3.zip</a>).</p>
<p>Extract all files (sqlite3.exe, sqlite3.dll and sqlite3.def) to the C:\Ruby192\bin folder. Now finally the server starts.</p>
<pre><div id="wpshdo_6" class="wp-synhighlighter-outer"><div id="wpshdt_6" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_6"></a><a id="wpshat_6" class="wp-synhighlighter-title" href="#codesyntax_6"  onClick="javascript:wpsh_toggleBlock(6)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_6" onClick="javascript:wpsh_code(6)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_6" onClick="javascript:wpsh_print(6)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_6" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; rails s<br />
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2010</span>-<span style="color: #cc66cc;">11</span>-<span style="color: #cc66cc;">19</span><span style="color: #66cc66;">&#93;</span> 06:<span style="color: #cc66cc;">48</span>:<span style="color: #cc66cc;">58</span><span style="color: #66cc66;">&#93;</span> INFO &nbsp;WEBrick::HTTPSERVER#start: pid=<span style="color: #cc66cc;">1836</span> port=<span style="color: #cc66cc;">3000</span></div></div></div></pre>
<p>Check <a href="http://localhost:3000/">http://localhost:3000/</a>.</p>
<h2>Installing git</h2>
<p>Download <a href="http://code.google.com/p/msysgit/downloads/list">msysgit</a>. I&#8217;m using <a href="http://code.google.com/p/msysgit/downloads/detail?name=Git-1.7.3.1-preview20101002.exe&amp;can=2&amp;q=">Git-1.7.3.1-preview20101002.exe</a>.</p>
<p>On the 4th screen, check everything:</p>
<p><a href="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/11/git04.png" rel="shadowbox[post-289];player=img;"><img class="aligncenter size-full wp-image-302" title="git04" src="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/11/git04.png" alt="" width="503" height="388" /></a></p>
<p>On the 6th screen, select &#8220;Run Git from the Windows Command Prompt&#8221;:</p>
<p><a href="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/11/git06.png" rel="shadowbox[post-289];player=img;"><img class="aligncenter size-full wp-image-303" title="git06" src="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/11/git06.png" alt="" width="503" height="388" /></a></p>
<p>On the 7th screen, select &#8220;Checkout as-is, commit Unix-style line endings&#8221;:</p>
<p><a href="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/11/git07.png" rel="shadowbox[post-289];player=img;"><img class="aligncenter size-full wp-image-304" title="git07" src="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/11/git07.png" alt="" width="503" height="388" /></a></p>
<p>Once msysgit is installed, open a new cmd console and configure your name and email<br />
<div id="wpshdo_7" class="wp-synhighlighter-outer"><div id="wpshdt_7" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_7"></a><a id="wpshat_7" class="wp-synhighlighter-title" href="#codesyntax_7"  onClick="javascript:wpsh_toggleBlock(7)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_7" onClick="javascript:wpsh_code(7)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_7" onClick="javascript:wpsh_print(7)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_7" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; git config --global user.name &quot;Juan Perez&quot;<br />
C:\testapp&gt; git config --global user.email &quot;juan.perez<span style="color: #33cc33;">@</span>example.com&quot;</div></div></div></p>
<p>You can get help about any git command by typing the command and &#8211;help:</p>
<div id="wpshdo_8" class="wp-synhighlighter-outer"><div id="wpshdt_8" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_8"></a><a id="wpshat_8" class="wp-synhighlighter-title" href="#codesyntax_8"  onClick="javascript:wpsh_toggleBlock(8)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_8" onClick="javascript:wpsh_code(8)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_8" onClick="javascript:wpsh_print(8)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_8" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; git config --help</div></div></div>
<p>Git will be really important later, don&#8217;t skip this step. Do your first commit:</p>
<div id="wpshdo_9" class="wp-synhighlighter-outer"><div id="wpshdt_9" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_9"></a><a id="wpshat_9" class="wp-synhighlighter-title" href="#codesyntax_9"  onClick="javascript:wpsh_toggleBlock(9)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_9" onClick="javascript:wpsh_code(9)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_9" onClick="javascript:wpsh_print(9)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_9" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; git init<br />
C:\testapp&gt; git add .<br />
C:\testapp&gt; git commit -m &quot;project started&quot;</div></div></div>
<h2>Create a new CRUD model, controller, view</h2>
<p>Rails is based on MVC and &#8220;scaffolding&#8221; is what they call to create a simple controller, model and view for a very basic and useful CRUD template.<br />
<div id="wpshdo_10" class="wp-synhighlighter-outer"><div id="wpshdt_10" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_10"></a><a id="wpshat_10" class="wp-synhighlighter-title" href="#codesyntax_10"  onClick="javascript:wpsh_toggleBlock(10)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_10" onClick="javascript:wpsh_code(10)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_10" onClick="javascript:wpsh_print(10)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_10" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; rails g scaffold product <a href="http://www.ss64.com/nt/title.html"><span style="color: #b1b100; font-weight: bold;">title</span></a>:string desc:string price:integer<br />
C:\testapp&gt; rake db:migrate</div></div></div></p>
<p>Now go to http://localhost:3000/products/ and try it. Don&#8217;t forget to commit:<br />
<span style="font-family: monospace;"><div id="wpshdo_11" class="wp-synhighlighter-outer"><div id="wpshdt_11" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_11"></a><a id="wpshat_11" class="wp-synhighlighter-title" href="#codesyntax_11"  onClick="javascript:wpsh_toggleBlock(11)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_11" onClick="javascript:wpsh_code(11)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_11" onClick="javascript:wpsh_print(11)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_11" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; git add .<br />
C:\testapp&gt; git commit -m &quot;created product mantainer&quot;</div></div></div></p>
<h2>Upload your app to heroku</h2>
<p>This is <span style="text-decoration: underline;">really, really cool</span>, you can upload and update your app for free in <a href="http://heroku.com/">heroku</a> using nothing but the command line!</p>
<p>First, upload your ssh keys to your home folder (something like C:\Users\Aldrin\.ssh\). If you don&#8217;t have a key, press the right button on the testapp folder and select &#8220;GIT Bash Here&#8221;.</p>
<p style="text-align: center;"><a href="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/11/git-bash-here.png" rel="shadowbox[post-289];player=img;"><img class="aligncenter size-full wp-image-305" title="git bash here" src="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/11/git-bash-here.png" alt="" width="449" height="359" /></a></p>
<p>Create your key with the following command:</p>
<div id="wpshdo_12" class="wp-synhighlighter-outer"><div id="wpshdt_12" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_12"></a><a id="wpshat_12" class="wp-synhighlighter-title" href="#codesyntax_12"  onClick="javascript:wpsh_toggleBlock(12)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_12" onClick="javascript:wpsh_code(12)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_12" onClick="javascript:wpsh_print(12)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_12" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; ssh-keygen.exe -t dsa -C &quot;juan.perez<span style="color: #33cc33;">@</span>example.com&quot;</div></div></div>
<p>Now, register in <a href="http://api.heroku.com/signup">http://api.heroku.com/signup</a> &#8230; After creating your account and uploading your ssh keys, install heroku and create a new app:</p>
<div id="wpshdo_13" class="wp-synhighlighter-outer"><div id="wpshdt_13" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_13"></a><a id="wpshat_13" class="wp-synhighlighter-title" href="#codesyntax_13"  onClick="javascript:wpsh_toggleBlock(13)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_13" onClick="javascript:wpsh_code(13)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_13" onClick="javascript:wpsh_print(13)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_13" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; gem install heroku<br />
C:\testapp&gt; heroku create<br />
Uploading ssh public key C:\Users\test/.ssh/id_dsa.pub<br />
Creating electric-sunset-57.... done<br />
Created http://electric-sunset-57.heroku.com/ | git<span style="color: #33cc33;">@</span>heroku.com:electric-sunset-57.git<br />
Git remote heroku added<br />
C:\testapp&gt; git push heroku master</div></div></div>
<p>The last line is all the magic: whenever you push to the heroku repository, your app is redeployed&#8230; deployment has never been so easy!</p>
<p>Go to your application url (like in http://electric-sunset-57.heroku.com/products/). It should fail because we need to setup a database in heroku servers&#8230; You can upload your current development sqlite3 database with:<br />
<div id="wpshdo_14" class="wp-synhighlighter-outer"><div id="wpshdt_14" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_14"></a><a id="wpshat_14" class="wp-synhighlighter-title" href="#codesyntax_14"  onClick="javascript:wpsh_toggleBlock(14)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_14" onClick="javascript:wpsh_code(14)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_14" onClick="javascript:wpsh_print(14)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_14" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; gem install taps<br />
C:\testapp&gt; heroku db:push</div></div></div></p>
<p>If still fails, you can check heroku logs:<br />
<div id="wpshdo_15" class="wp-synhighlighter-outer"><div id="wpshdt_15" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_15"></a><a id="wpshat_15" class="wp-synhighlighter-title" href="#codesyntax_15"  onClick="javascript:wpsh_toggleBlock(15)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_15" onClick="javascript:wpsh_code(15)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_15" onClick="javascript:wpsh_print(15)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_15" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; heroku logs</div></div></div></p>
<p>I&#8217;ve found out that heroku didn&#8217;t find sqlite3 (which is not be available in their production environment), so I&#8217;ve changed the Gemfile to this:<br />
<div id="wpshdo_16" class="wp-synhighlighter-outer"><div id="wpshdt_16" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_16"></a><a id="wpshat_16" class="wp-synhighlighter-title" href="#codesyntax_16"  onClick="javascript:wpsh_toggleBlock(16)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_16" onClick="javascript:wpsh_code(16)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_16" onClick="javascript:wpsh_print(16)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_16" class="wp-synhighlighter-inner" style="display: block;"><div class="ruby" style="font-family:monospace;">group <span style="color:#ff3333; font-weight:bold;">:development</span>, <span style="color:#ff3333; font-weight:bold;">:test</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; gem <span style="color:#996600;">'sqlite3-ruby'</span>, :<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'sqlite3'</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div></div></p>
<p>Commit your changes and push them to heroku.</p>
<div id="wpshdo_17" class="wp-synhighlighter-outer"><div id="wpshdt_17" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_17"></a><a id="wpshat_17" class="wp-synhighlighter-title" href="#codesyntax_17"  onClick="javascript:wpsh_toggleBlock(17)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_17" onClick="javascript:wpsh_code(17)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_17" onClick="javascript:wpsh_print(17)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_17" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; git add .<br />
C:\testapp&gt; git commit -m 'bugfix: sqlite3 only <a href="http://www.ss64.com/nt/in.html"><span style="color: #00b100; font-weight: bold;">in</span></a> dev,test'<br />
C:\testapp&gt; git push heroku master</div></div></div>
<p>Now check http://deep-planet-58.heroku.com/products/. For removing the app in heroku:</p>
<div id="wpshdo_18" class="wp-synhighlighter-outer"><div id="wpshdt_18" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_18"></a><a id="wpshat_18" class="wp-synhighlighter-title" href="#codesyntax_18"  onClick="javascript:wpsh_toggleBlock(18)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_18" onClick="javascript:wpsh_code(18)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_18" onClick="javascript:wpsh_print(18)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_18" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; heroku destroy --app deep-planet-<span style="color: #cc66cc;">58</span></div></div></div>
<h2>Bonus: TextMate like editor</h2>
<p>Many tutorials you&#8217;ll see use TextMate for programming in rails, which is only available in Mac OS X. Try the following alternatives:</p>
<p>First, download <a href="http://java.sun.com/">java</a> for windows. Now, install redcar (this will take a while&#8230;):</p>
<div id="wpshdo_19" class="wp-synhighlighter-outer"><div id="wpshdt_19" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_19"></a><a id="wpshat_19" class="wp-synhighlighter-title" href="#codesyntax_19"  onClick="javascript:wpsh_toggleBlock(19)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_19" onClick="javascript:wpsh_code(19)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_19" onClick="javascript:wpsh_print(19)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_19" class="wp-synhighlighter-inner" style="display: block;"><div class="dos" style="font-family:monospace;">C:\testapp&gt; gem install redcar<br />
C:\testapp&gt; redcar install<br />
C:\testapp&gt; redcar .</div></div></div>
<p>You may run redcar directly from C:\Ruby192\bin\redcar.bat .</p>
<p>That&#8217;s all for now.</p>
]]></content:encoded>
			<wfw:commentRss>http://aldrin.martoq.cl/techblog/2010/11/how-to-start-programming-in-rails-3-in-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Announcing: Mirror and Projects page</title>
		<link>http://aldrin.martoq.cl/techblog/2010/10/announcing-mirror-and-projects-page/</link>
		<comments>http://aldrin.martoq.cl/techblog/2010/10/announcing-mirror-and-projects-page/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 04:02:24 +0000</pubDate>
		<dc:creator>Aldrin Martoq</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://aldrin.martoq.cl/techblog/?p=277</guid>
		<description><![CDATA[I have finished publishing my first opensource Mac OS X app: Mirror. Full source code is available at github instead of my private repo. I have also created a Projects page in this blog, so any other app or anything will appear in one central page. Hope you find useful, &#8211; Aldrin]]></description>
			<content:encoded><![CDATA[<p>I have finished publishing my first opensource Mac OS X app: <a href="http://aldrin.martoq.cl/techblog/projects/mirror-app/">Mirror</a>. Full source code is <a href="http://github.com/aldrinmartoq/Mirror">available at github</a> instead of my private repo.</p>
<p>I have also created a <a href="http://aldrin.martoq.cl/techblog/projects/">Projects page in this blog</a>, so any other app or anything will appear in one central page.</p>
<p>Hope you find useful,</p>
<p>&#8211; Aldrin</p>
]]></content:encoded>
			<wfw:commentRss>http://aldrin.martoq.cl/techblog/2010/10/announcing-mirror-and-projects-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to start programming in rails 3</title>
		<link>http://aldrin.martoq.cl/techblog/2010/10/how-to-start-programming-in-rails-3/</link>
		<comments>http://aldrin.martoq.cl/techblog/2010/10/how-to-start-programming-in-rails-3/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 07:45:19 +0000</pubDate>
		<dc:creator>Aldrin Martoq</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Ruby on Rails 3]]></category>

		<guid isPermaLink="false">http://aldrin.martoq.cl/techblog/?p=231</guid>
		<description><![CDATA[Although I have no news about the perfect web application technology quest, I have been experimenting with a lot of frameworks (like Google Web Toolkit and Cappuccino) during the last 6 months&#8230; just didn&#8217;t got the time to post about my findings or even start the sample application. Last week I started a REAL project [...]]]></description>
			<content:encoded><![CDATA[<p>Although I have no news about <a href="http://aldrin.martoq.cl/techblog/the-perfect-web-application-technology/">the perfect web application technology</a> quest, I have been experimenting with a lot of frameworks (like <a href="http://code.google.com/webtoolkit/">Google Web Toolkit</a> and <a href="http://cappuccino.org/">Cappuccino</a>) during the last 6 months&#8230; just didn&#8217;t got the time to post about my findings or even start the sample application.</p>
<p>Last week I started a REAL project using <a href="http://rubyonrails.org/">Ruby on Rails 3</a>. The first two hours was quite exciting, but after a while I realized that all examples/docs/podcasts/guides were made with the 2.x versions in mind. Everything requires several adjustments for the new 3.0 rails version.</p>
<p>So, I&#8217;m beginning to document step-by-step instructions on how to start programming in the shiny new rails 3.<span id="more-231"></span></p>
<h2>Prerequisites</h2>
<p><strong>Update:</strong> You&#8217;ll need to install the following:</p>
<p>Ubuntu 10.10 -</p>
<div id="wpshdo_20" class="wp-synhighlighter-outer"><div id="wpshdt_20" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_20"></a><a id="wpshat_20" class="wp-synhighlighter-title" href="#codesyntax_20"  onClick="javascript:wpsh_toggleBlock(20)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_20" onClick="javascript:wpsh_code(20)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_20" onClick="javascript:wpsh_print(20)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_20" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> curl zlib1g-dev libsqlite3-dev libssl-dev</div></div></div>
<h2>Installing Rails 3</h2>
<p>Thanks to  <a href="http://rvm.beginrescueend.com/rvm/install/">RVM</a>, this is quite easy: RVM will download, compile and install everything inside a sandbox directory ($HOME/.rvm/), no need to touch your system libraries or becoming root. You can install many versions of ruby, or go back to your system wide installation. Easy and reliable.</p>
<p>First, run the <a href="http://rvm.beginrescueend.com/rvm/install/">RVM install script</a> and then include RVM in your .bashrc or .profile:</p>
<div id="wpshdo_21" class="wp-synhighlighter-outer"><div id="wpshdt_21" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_21"></a><a id="wpshat_21" class="wp-synhighlighter-title" href="#codesyntax_21"  onClick="javascript:wpsh_toggleBlock(21)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_21" onClick="javascript:wpsh_code(21)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_21" onClick="javascript:wpsh_print(21)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_21" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>curl <span style="color: #660033;">-s</span> https:<span style="color: #000000; font-weight: bold;">//</span>rvm.beginrescueend.com<span style="color: #000000; font-weight: bold;">/</span>install<span style="color: #000000; font-weight: bold;">/</span>rvm<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'[[ -s &quot;$HOME/.rvm/scripts/rvm&quot; ]] &amp;&amp; source &quot;$HOME/.rvm/scripts/rvm&quot;'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>.bashrc</div></div></div>
<p>Quit/restart your bash or terminal session. Now install ruby 1.9.2</p>
<div id="wpshdo_22" class="wp-synhighlighter-outer"><div id="wpshdt_22" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_22"></a><a id="wpshat_22" class="wp-synhighlighter-title" href="#codesyntax_22"  onClick="javascript:wpsh_toggleBlock(22)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_22" onClick="javascript:wpsh_code(22)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_22" onClick="javascript:wpsh_print(22)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_22" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ rvm <span style="color: #c20cb9; font-weight: bold;">install</span> 1.9.2<br />
$ rvm <span style="color: #660033;">--default</span> 1.9.2</div></div></div>
<p>Note: If you are in Mac OS X, ruby is not compiled with iconv support (crucial for i18n!)&#8230; run this to install iconv inside the sandbox and reinstall ruby:</p>
<div id="wpshdo_23" class="wp-synhighlighter-outer"><div id="wpshdt_23" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_23"></a><a id="wpshat_23" class="wp-synhighlighter-title" href="#codesyntax_23"  onClick="javascript:wpsh_toggleBlock(23)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_23" onClick="javascript:wpsh_code(23)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_23" onClick="javascript:wpsh_print(23)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_23" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ rvm package <span style="color: #c20cb9; font-weight: bold;">install</span> iconv<br />
$ rvm remove 1.9.2<br />
$ rvm <span style="color: #c20cb9; font-weight: bold;">install</span> 1.9.2 <span style="color: #660033;">-C</span> <span style="color: #660033;">--with-iconv-dir</span>=<span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>usr<br />
$ rvm <span style="color: #660033;">--default</span> 1.9.2</div></div></div>
<p>You can switch between your system wide ruby or the new one inside the sandbox, just run both and keep with the 1.9.2 version:</p>
<div id="wpshdo_24" class="wp-synhighlighter-outer"><div id="wpshdt_24" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_24"></a><a id="wpshat_24" class="wp-synhighlighter-title" href="#codesyntax_24"  onClick="javascript:wpsh_toggleBlock(24)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_24" onClick="javascript:wpsh_code(24)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_24" onClick="javascript:wpsh_print(24)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_24" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ rvm <span style="color: #660033;">--default</span> system <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> ruby <span style="color: #660033;">-v</span><br />
ruby 1.8.7 <span style="color: #7a0874; font-weight: bold;">&#40;</span>2009-06-12 patchlevel 174<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>universal-darwin10.0<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
$ rvm <span style="color: #660033;">--default</span> 1.9.2 <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> ruby <span style="color: #660033;">-v</span><br />
ruby 1.9.2p0 <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2010</span>-08-<span style="color: #000000;">18</span> revision <span style="color: #000000;">29036</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>x86_64-darwin10.4.0<span style="color: #7a0874; font-weight: bold;">&#93;</span></div></div></div>
<p>Install rails 3 with gem (it may take a while) and check:</p>
<div id="wpshdo_25" class="wp-synhighlighter-outer"><div id="wpshdt_25" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_25"></a><a id="wpshat_25" class="wp-synhighlighter-title" href="#codesyntax_25"  onClick="javascript:wpsh_toggleBlock(25)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_25" onClick="javascript:wpsh_code(25)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_25" onClick="javascript:wpsh_print(25)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_25" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails<br />
$ rails <span style="color: #660033;">-v</span><br />
Rails 3.0.0</div></div></div>
<h2>Creating &amp; running a test application</h2>
<p>My recommendation is to setup a new directory for all your rails projects:</p>
<div id="wpshdo_26" class="wp-synhighlighter-outer"><div id="wpshdt_26" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_26"></a><a id="wpshat_26" class="wp-synhighlighter-title" href="#codesyntax_26"  onClick="javascript:wpsh_toggleBlock(26)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_26" onClick="javascript:wpsh_code(26)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_26" onClick="javascript:wpsh_print(26)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_26" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>proj<span style="color: #000000; font-weight: bold;">/</span>rails<span style="color: #000000; font-weight: bold;">/</span><br />
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>proj<span style="color: #000000; font-weight: bold;">/</span>rails</div></div></div>
<p>Now create a new rails app called &#8220;testapp&#8221;:</p>
<div id="wpshdo_27" class="wp-synhighlighter-outer"><div id="wpshdt_27" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_27"></a><a id="wpshat_27" class="wp-synhighlighter-title" href="#codesyntax_27"  onClick="javascript:wpsh_toggleBlock(27)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_27" onClick="javascript:wpsh_code(27)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_27" onClick="javascript:wpsh_print(27)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_27" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ rails new testapp <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">cd</span> testapp</div></div></div>
<p>And start the server&#8230; it should fail because sqlite3-ruby is not installed:</p>
<div id="wpshdo_28" class="wp-synhighlighter-outer"><div id="wpshdt_28" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_28"></a><a id="wpshat_28" class="wp-synhighlighter-title" href="#codesyntax_28"  onClick="javascript:wpsh_toggleBlock(28)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_28" onClick="javascript:wpsh_code(28)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_28" onClick="javascript:wpsh_print(28)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_28" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ rails s<br />
Could not <span style="color: #c20cb9; font-weight: bold;">find</span> gem <span style="color: #ff0000;">'sqlite3-ruby (&amp;&gt;= 0, runtime)'</span> <span style="color: #000000; font-weight: bold;">in</span> any of the gem sources.<br />
Try running <span style="color: #000000; font-weight: bold;">`</span>bundle <span style="color: #c20cb9; font-weight: bold;">install</span><span style="color: #000000; font-weight: bold;">`</span>.</div></div></div>
<p>Instead of running &#8220;gem install foo bar&#8221;, rails 3 comes with bundle: when you get a new project, run bundle to check dependencies and install missing gems. You can specify your own dependencies in the &#8220;Gemfile&#8221;.</p>
<div id="wpshdo_29" class="wp-synhighlighter-outer"><div id="wpshdt_29" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_29"></a><a id="wpshat_29" class="wp-synhighlighter-title" href="#codesyntax_29"  onClick="javascript:wpsh_toggleBlock(29)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_29" onClick="javascript:wpsh_code(29)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_29" onClick="javascript:wpsh_print(29)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_29" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ bundle</div></div></div>
<p>And now we can start the server!</p>
<p><span style="font-family: monospace;"><div id="wpshdo_30" class="wp-synhighlighter-outer"><div id="wpshdt_30" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_30"></a><a id="wpshat_30" class="wp-synhighlighter-title" href="#codesyntax_30"  onClick="javascript:wpsh_toggleBlock(30)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_30" onClick="javascript:wpsh_code(30)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_30" onClick="javascript:wpsh_print(30)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_30" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ rails s<br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2010</span>-<span style="color: #000000;">10</span>-03 02:<span style="color: #000000;">35</span>:<span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> INFO &nbsp;WEBrick::HTTPServer<span style="color: #666666; font-style: italic;">#start: pid=50672 port=3000</span></div></div></div></p>
<p>Check <a href="http://localhost:3000/">http://localhost:3000/</a>.</p>
<h2>Setup git</h2>
<p>If you don&#8217;t know <a href="http://git-scm.com/">git</a>, you should <a href="http://book.git-scm.com/book.pdf">learn the basics right now</a> <img src='http://aldrin.martoq.cl/techblog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Git will be really important later, don&#8217;t skip this step. For starters, run inside your rail project:</p>
<p><span style="font-family: monospace;"><div id="wpshdo_31" class="wp-synhighlighter-outer"><div id="wpshdt_31" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_31"></a><a id="wpshat_31" class="wp-synhighlighter-title" href="#codesyntax_31"  onClick="javascript:wpsh_toggleBlock(31)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_31" onClick="javascript:wpsh_code(31)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_31" onClick="javascript:wpsh_print(31)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_31" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ git init<br />
$ git add .<br />
$ git commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;first import!&quot;</span></div></div></div></p>
<h2>Create a new CRUD model, controller, view</h2>
<p>Rails is based on MVC and &#8220;scaffolding&#8221; is what they call to create a simple controller, model and view for a very basic and useful CRUD template.<br />
<span style="font-family: monospace;"><div id="wpshdo_32" class="wp-synhighlighter-outer"><div id="wpshdt_32" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_32"></a><a id="wpshat_32" class="wp-synhighlighter-title" href="#codesyntax_32"  onClick="javascript:wpsh_toggleBlock(32)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_32" onClick="javascript:wpsh_code(32)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_32" onClick="javascript:wpsh_print(32)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_32" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ rails g scaffold product title:string desc:string price:integer<br />
$ rake db:migrate</div></div></div></p>
<p>Now go to http://localhost:3000/products/ and try it. Don&#8217;t forget to commit:<br />
<span style="font-family: monospace;"><div id="wpshdo_33" class="wp-synhighlighter-outer"><div id="wpshdt_33" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_33"></a><a id="wpshat_33" class="wp-synhighlighter-title" href="#codesyntax_33"  onClick="javascript:wpsh_toggleBlock(33)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_33" onClick="javascript:wpsh_code(33)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_33" onClick="javascript:wpsh_print(33)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_33" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ git add .<br />
$ git commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;created product mantainer&quot;</span></div></div></div></p>
<h2>Upload your app to heroku</h2>
<p>This is <span style="text-decoration: underline;">really, really cool</span>, you can upload and update your app for free in <a href="http://heroku.com/">heroku</a> using nothing but the command line!</p>
<p>First, register in <a href="http://api.heroku.com/signup">http://api.heroku.com/signup</a> &#8230; After creating your account, install heroku and create a new app:<br />
<span style="font-family: monospace;"><div id="wpshdo_34" class="wp-synhighlighter-outer"><div id="wpshdt_34" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_34"></a><a id="wpshat_34" class="wp-synhighlighter-title" href="#codesyntax_34"  onClick="javascript:wpsh_toggleBlock(34)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_34" onClick="javascript:wpsh_code(34)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_34" onClick="javascript:wpsh_print(34)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_34" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ gem <span style="color: #c20cb9; font-weight: bold;">install</span> heroku<br />
$ heroku create<br />
Uploading <span style="color: #c20cb9; font-weight: bold;">ssh</span> public key <span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_dsa.pub<br />
Creating deep-planet-58.... <span style="color: #000000; font-weight: bold;">done</span><br />
Created http:<span style="color: #000000; font-weight: bold;">//</span>deep-planet-58.heroku.com<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">|</span> git<span style="color: #000000; font-weight: bold;">@</span>heroku.com:deep-planet-58.git<br />
Git remote heroku added<br />
$ git push heroku master</div></div></div></p>
<p>The last line is all the magic: whenever you push to the heroku repository, your app is redeployed&#8230; deployment has never been so easy!</p>
<p>Go to your application url (like in http://deep-planet-58.heroku.com/products/). It should fail because we need to setup a database in heroku servers&#8230; You can upload your current development sqlite3 database with:<br />
<span style="font-family: monospace;"><div id="wpshdo_35" class="wp-synhighlighter-outer"><div id="wpshdt_35" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_35"></a><a id="wpshat_35" class="wp-synhighlighter-title" href="#codesyntax_35"  onClick="javascript:wpsh_toggleBlock(35)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_35" onClick="javascript:wpsh_code(35)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_35" onClick="javascript:wpsh_print(35)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_35" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ gem <span style="color: #c20cb9; font-weight: bold;">install</span> taps<br />
$ heroku db:push</div></div></div></p>
<p>Now check http://deep-planet-58.heroku.com/products/. For removing the app in heroku:</p>
<div id="wpshdo_36" class="wp-synhighlighter-outer"><div id="wpshdt_36" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_36"></a><a id="wpshat_36" class="wp-synhighlighter-title" href="#codesyntax_36"  onClick="javascript:wpsh_toggleBlock(36)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_36" onClick="javascript:wpsh_code(36)" title="Show code only"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_36" onClick="javascript:wpsh_print(36)" title="Print code"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://aldrin.martoq.cl/techblog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_36" class="wp-synhighlighter-inner" style="display: block;"><div class="bash" style="font-family:monospace;">$ heroku destroy <span style="color: #660033;">--app</span> deep-planet-<span style="color: #000000;">58</span></div></div></div>
<h2>Important things to remember</h2>
<ul>
<li>Don&#8217;t run any command as root because everything is installed inside $HOME/.rvm/</li>
<li>I repeat: never run sudo!</li>
<li>Declare dependencies in the Gemfile and run &#8220;bundle&#8221; to install required gems. Heroku will do the same, so get used to it</li>
<li>Setup git from the start and use it constantly</li>
<li>You can deploy your app in heroku, don&#8217;t forget to push your database</li>
</ul>
<p>That&#8217;s all for now.</p>
]]></content:encoded>
			<wfw:commentRss>http://aldrin.martoq.cl/techblog/2010/10/how-to-start-programming-in-rails-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The perfect web application technology, part 3: the test application</title>
		<link>http://aldrin.martoq.cl/techblog/2010/02/the-perfect-web-application-technology-part-3-the-test-application/</link>
		<comments>http://aldrin.martoq.cl/techblog/2010/02/the-perfect-web-application-technology-part-3-the-test-application/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 13:42:50 +0000</pubDate>
		<dc:creator>Aldrin Martoq</dc:creator>
				<category><![CDATA[Quests]]></category>

		<guid isPermaLink="false">http://aldrin.martoq.cl/techblog/?p=154</guid>
		<description><![CDATA[Well, I gave up and ended using balsamiq (free) web interface. In the mean time, I realized that finding the perfect web application technology could easily become a huge, really really huge project (Leo say something like &#8216;I was trying to fix the world&#8217;&#8230; that sounds huge!). And my fears of not finishing it all [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I gave up and ended using balsamiq (free) web interface.</p>
<p>In the mean time, I realized that finding <a href="http://aldrin.martoq.cl/techblog/the-perfect-web-application-technology/">the perfect web application technology</a> could easily become a huge, really really huge project (<a href="http://blog.leosoto.com">Leo</a> say something like &#8216;I was trying to fix the world&#8217;&#8230; that sounds huge!). And my fears of not finishing it all by myself in my spare/free/study/procastination time just appeared. So, I&#8217;m taking two strategies for this:</p>
<ol>
<li>So many girls, so little time! I&#8217;ll start with something small, then grow as necessary: I mean, I will start with only one of the major functionalities I have in my mind for the test application, later I will cover the rest or improve the existing ones.</li>
<li>Ask for help: Please, you are already invited into this quest: talk to me, send me patches, re-create this application in the technology of your choice, fixs my bugs or find better ways of doing things, etc. Thanks!</li>
</ol>
<p>So, functional requirements: here we go!</p>
<p><span id="more-154"></span></p>
<h3>Functional requirements (version 2010-01-02)</h3>
<p>The test application is a rich internet application for clients of a fictional bank. The clients of the bank can do the following tasks: see a balance report of their saving/deposit/whatever accounts, transfer money to other accounts, and chat directly with an executive, if they are available.</p>
<p>The six major functional requirements of the test applications are:</p>
<ol>
<li>Layout of the web page that makes easy to compare a technology with others.</li>
<li>A very secure login and logout, user-password based.</li>
<li>Balance reports of different type of accounts, including excel and chart exporting.</li>
<li>Money transfer to other accounts of the same bank.</li>
<li>An embedded calculator, with bank-related functionality included.</li>
<li>A live chat with your executive, if she/he is available.</li>
</ol>
<p>Remember the &#8216;so many girls, so little time&#8217; phrase: I&#8217;m trying to meet as much sexy (and ugly!) girls/technology first rather than know them very well. So, in this version we are covering only the first two requirements. It will be long, however, take your notes!</p>
<h4>Requirement 1: Layout of the webpage</h4>
<p>This is easy, the layout of the page has to be something similar to this:</p>
<p><a href="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/layout.png" rel="shadowbox[post-154];player=img;"><img class="alignnone size-full wp-image-200" title="layout" src="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/layout.png" alt="" width="647" height="510" /></a></p>
<p>Let me explain each section of the layout:</p>
<p><strong>1.1 Top-left section</strong>:</p>
<ul>
<li>first line is &#8220;the perfect web application technology&#8221; linking to this page</li>
<li>second line is the number of the test (ex: &#8220;technology 05&#8243;) and the name of technologies used (ex: &#8220;gwt, java servlets&#8221;)</li>
<li>third line is an about page, linking to a page with notes about this version of the application (who made it, where is the code, licensing, etc)</li>
</ul>
<p><strong>1.2 Top-right section</strong>:</p>
<ul>
<li>first line is the name of the connected user, only if she/he is already connected to the application</li>
<li>second line is the roles available to the user, ONLY if the user has more roles other than &#8220;bank client&#8221;</li>
<li>third line is a logout link</li>
</ul>
<p><strong>1.3 Evaluation accordion</strong>: The right column is a summary of evaluation points. The interface is an <a href="http://en.wikipedia.org/wiki/Accordion_(GUI)">accordion widget</a>, and the titles should indicate the number of issues found for a given requirement. For example: &#8220;Logon (4/10)&#8221; means that logon functionality has a total of 10 requirements, and 4 of them has issues in the current implementation&#8221;.</p>
<p>If the user clicks on a requirement, a new floating window should appear (inside the browser! <a href="http://famspam.com/facebox/">example</a>) with the page fragment of the evaluation page. Note that &#8220;the evaluation page&#8221; will be a post on this blog.</p>
<p><a href="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/layout-01.png" rel="shadowbox[post-154];player=img;"><img class="alignnone size-full wp-image-201" title="layout-01" src="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/layout-01.png" alt="" width="647" height="510" /></a></p>
<p>This will allows us to see the evaluation of a technology without leaving the same application. Bonus if the application reads the evaluation post and updates the accordion automatically (ie: no database or code to keep the count of issues!).</p>
<p><strong>1.4 Link bar</strong>: just above the content pane, there should be a link bar with all the functionality for this application. Of course, if the user is not logged in, it must be forced to logon.</p>
<p><strong>1.5 Content pane</strong>: It can&#8217;t based on frames, that sucks for many reasons. It should have vertical scrollbar and an horizontal scrollbar only if needed.</p>
<p><strong>1.6 Expected web page behavior</strong>:</p>
<ul>
<li>The back, forward and reload browser buttons should work with your application. Not sure how to explain this, so I&#8217;ll do it later&#8230;</li>
<li>Copy and paste should work, and also mouse scrolling (both horizontal and vertical)</li>
</ul>
<h4>Requirement 2: Login</h4>
<p><strong>2.1 User accounts</strong>: Because this is a bank, there is no account creation via web. We&#8217;ll may cover an administration interface later. All user accounts consist of an user and (strong) password.</p>
<p><strong>2.2 Login interface</strong>: it should be something like this:</p>
<p><a href="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/login-00.png" rel="shadowbox[post-154];player=img;"><img class="alignnone size-full wp-image-204" title="login-00" src="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/login-00.png" alt="" width="647" height="510" /></a></p>
<p>Note that the top-right section is empty.</p>
<p><strong>2.3 Login failure</strong>: if the user fails, a message should appear below indicating the number of attempts left before the account will be locked (1). The failed attempts are by hour, and reseted if the login is successful. If the user has failed within the hour, a link to recover your password must appear (2).</p>
<h4><span style="font-weight: normal;"><strong>﻿<a href="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/login-01.png" rel="shadowbox[post-154];player=img;"><img class="alignnone size-full wp-image-206" title="login-01" src="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/login-01.png" alt="" width="647" height="510" /></a></strong></span></h4>
<p><span style="font-weight: normal;"><strong>2.4 Lost password</strong>: if the user click the &#8216;lost your password?&#8217; link, a dialog should appear asking for the username or email of the account.</span></p>
<p><span style="font-weight: normal;"><a href="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/login-02.png" rel="shadowbox[post-154];player=img;"><img class="alignnone size-full wp-image-207" title="login-02" src="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/login-02.png" alt="" width="647" height="510" /></a></span></p>
<p>When the user press the &#8216;Sent me instructions&#8217; button, an email will arrive with a link to reactivate the account (if it was locked) and to create a new password. The confirmation message should look like this:</p>
<p><a href="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/login-03.png" rel="shadowbox[post-154];player=img;"><img class="alignnone size-full wp-image-208" title="login-03" src="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/login-03.png" alt="" width="647" height="510" /></a></p>
<p>The user has 1 hour to recover its password, after that the link sent is expired and must not work again. Besides that, the user cannot send new instructions until the recover links expires. Instead, it gets a message like this:</p>
<p><a href="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/login-04.png" rel="shadowbox[post-154];player=img;"><img class="alignnone size-full wp-image-209" title="login-04" src="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/login-04.png" alt="" width="647" height="510" /></a></p>
<p><strong>2.5 Account locking</strong>: if there are too many login attempts in the period of an hour, the account must be locked and the user must not be able to login after a pause of X minutes.</p>
<p><a href="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/login-05.png" rel="shadowbox[post-154];player=img;"><img class="alignnone size-full wp-image-210" title="login-05" src="http://aldrin.martoq.cl/techblog/wp-content/uploads/2010/02/login-05.png" alt="" width="647" height="510" /></a></p>
<p>A clock should appear, with the minutes:seconds left until the user is able to try login again, once the counter reach zero, the account dialog must disappear and reveal the login. Account locking is an standard in the bank, so it must be implemented with functionality supported by remote services.</p>
<p><strong>2.6 Services</strong>: The following remote services are available to build all the above functionality. These services can be made available in the protocol of your choice (from EJB/RMI to JSON). I will post the API + examples later, once I implement them.</p>
<ul>
<li>login_status remote_login_status(string username);</li>
<li>user_info remote_login(string username, string password) throws login_error;</li>
<li>remote_update_password(string username, string password) throws update_error;</li>
</ul>
<p>Note there are things that must be implemented in the webserver (ie: not available as services), an example is the link to create a password.</p>
<h3>Summary</h3>
<p>To summarize, here is the list of all requirements (including those stated in the previous post). Bonus: If the evaluation accordion extracts the names from here.</p>
<h4>List of requirements</h4>
<p>1. Layout<br />
1.1 Top left<br />
1.2 Top right<br />
1.3 Evaluation accordion<br />
1.4 Link bar<br />
1.5 Content Pane<br />
1.6 Common behavior</p>
<p>2 Login<br />
2.1 User accounts<br />
2.2 Login interface<br />
2.3 Login failure<br />
2.4 Lost password<br />
2.5 Account locking<br />
2.6 Services</p>
<h3>What&#8217;s next</h3>
<p>All following post will talk about the experience of writing the test application implemented under a technology. I&#8217;m keeping a summary of versions and a changelog in <a href="http://aldrin.martoq.cl/techblog/the-perfect-web-application-technology/">the perfect web application technology page</a>, check that regularly for changes and improvements.</p>
]]></content:encoded>
			<wfw:commentRss>http://aldrin.martoq.cl/techblog/2010/02/the-perfect-web-application-technology-part-3-the-test-application/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Web mockups, fast and free?</title>
		<link>http://aldrin.martoq.cl/techblog/2010/01/web-mockups-fast-and-free/</link>
		<comments>http://aldrin.martoq.cl/techblog/2010/01/web-mockups-fast-and-free/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 04:12:08 +0000</pubDate>
		<dc:creator>Aldrin Martoq</dc:creator>
				<category><![CDATA[Howto]]></category>

		<guid isPermaLink="false">http://aldrin.martoq.cl/techblog/?p=160</guid>
		<description><![CDATA[While defining the test application for the perfect web technology quest, I wanted to do mockups. A mockup is an easy and fast way of describing many requirements, it basically says &#8216;it should look like this&#8217;. But I couldn&#8217;t find any useful software in my ubuntu setup, neither on google. It seems the most useful and popular app is [...]]]></description>
			<content:encoded><![CDATA[<p>While defining the test application for <a href="http://aldrin.martoq.cl/techblog/the-perfect-web-application-technology/">the perfect web technology quest</a>, I wanted to do mockups. A mockup is an easy and fast way of describing many requirements, it basically says &#8216;it should look like this&#8217;.</p>
<p>But I couldn&#8217;t find any useful software in my ubuntu setup, <a href="http://www.google.com/search?q=mockup+software+linux">neither on google</a>. It seems the most useful and popular app is <a href="http://www.balsamiq.com/products/mockups">balsamiq</a>, an AIR application that you can <a href="http://www.balsamiq.com/demos/mockups/Mockups.html">try on the web</a> and run on your desktop. It seems really useful, but it costs US $80. I may buy it later, but I was looking for a free and open solution.</p>
<p>Then I looked some web utilities for doing mockups of web pages, but none of them seem up to the task&#8230; And then, it hit me: we are not building web pages anymore, we are building full desktop applications on the web; why I can&#8217;t use the same tools we use for desktop development? So, I tried <a href="http://glade.gnome.org/">Glade</a>. Now, let me show you&#8230;</p>
<p><span id="more-160"></span></p>
<h3>A web browser mockup</h3>
<p>First, I needed a web browser mockup. That&#8217;s included in a tool like balsamiq, but I have to made one from start. In around 5-10 minutes, it was done!</p>
<div id="attachment_163" class="wp-caption alignnone" style="width: 608px"><a href="http://aldrin.martoq.cl/techblog/wp-content/upload/2010/01/Screenshot-mockup-browser.glade_.png" rel="shadowbox[post-160];player=img;"><img class="size-full wp-image-163" title="A browser mockup made with glade" src="http://aldrin.martoq.cl/techblog/wp-content/upload/2010/01/Screenshot-mockup-browser.glade_.png" alt="" width="598" height="319" /></a><p class="wp-caption-text">A browser mockup made with glade, click to view</p></div>
<p>This was exciting! Now, let&#8217;s add some content&#8230; a typical web layout: header, side column and main content with scrolling. First, the layout and header:</p>
<div id="attachment_167" class="wp-caption alignnone" style="width: 687px"><a href="http://aldrin.martoq.cl/techblog/wp-content/upload/2010/01/Screenshot-mockup-browser-test.glade_.png" rel="shadowbox[post-160];player=img;"><img class="size-full wp-image-167 " title="Creating the web header mockup" src="http://aldrin.martoq.cl/techblog/wp-content/upload/2010/01/Screenshot-mockup-browser-test.glade_.png" alt="" width="677" height="368" /></a><p class="wp-caption-text">Creating the web header, it took around 5-8 minutes including the site logo made in gimp</p></div>
<p>Well, it took more than I wanted, mostly because I had to recreate many elements like a breadcrum (in balsamiq, just search that element in the &#8216;Quick add&#8217; text entry).</p>
<p>But there are advantages. The layout of elements is automatic, I don&#8217;t need to set positions or sizes of any element, neither link them together. For example, imagine I forgot to put the name of the logged user and a logout link.</p>
<p>Just add an &#8216;Horizontal Box&#8217; as parent of the &#8216;web site title&#8217; label:</p>
<div id="attachment_168" class="wp-caption alignnone" style="width: 446px"><a href="http://aldrin.martoq.cl/techblog/wp-content/upload/2010/01/Screenshot.png" rel="shadowbox[post-160];player=img;"><img class="size-full wp-image-168" title="Repacking a widget: add a parent horizontal box" src="http://aldrin.martoq.cl/techblog/wp-content/upload/2010/01/Screenshot.png" alt="" width="436" height="256" /></a><p class="wp-caption-text">Repacking a widget: add a parent horizontal box</p></div>
<p>The label will disappear, and glade will ask how many placeholders the horizontal box should have. Let&#8217;s add 3:</p>
<div id="attachment_169" class="wp-caption alignnone" style="width: 446px"><a href="http://aldrin.martoq.cl/techblog/wp-content/upload/2010/01/Screenshot-1.png" rel="shadowbox[post-160];player=img;"><img class="size-full wp-image-169" title="Repacking a widget: select the number of placeholders" src="http://aldrin.martoq.cl/techblog/wp-content/upload/2010/01/Screenshot-1.png" alt="" width="436" height="256" /></a><p class="wp-caption-text">Repacking a widget: select the number of placeholders</p></div>
<p>Now, we have our original widget and got two new placeholders to put new content:</p>
<div id="attachment_170" class="wp-caption alignnone" style="width: 446px"><a href="http://aldrin.martoq.cl/techblog/wp-content/upload/2010/01/Screenshot-2.png" rel="shadowbox[post-160];player=img;"><img class="size-full wp-image-170" title="Repacking a widget: two placeholders ready!" src="http://aldrin.martoq.cl/techblog/wp-content/upload/2010/01/Screenshot-2.png" alt="" width="436" height="256" /></a><p class="wp-caption-text">Repacking a widget: two placeholders ready!</p></div>
<p>After adding two widgets, we are done:</p>
<div id="attachment_171" class="wp-caption alignnone" style="width: 446px"><a href="http://aldrin.martoq.cl/techblog/wp-content/upload/2010/01/Screenshot-3.png" rel="shadowbox[post-160];player=img;"><img class="size-full wp-image-171 " title="Repacking a widget: the final result" src="http://aldrin.martoq.cl/techblog/wp-content/upload/2010/01/Screenshot-3.png" alt="" width="436" height="256" /></a><p class="wp-caption-text">Repacking a widget: the final result</p></div>
<h3>Summary</h3>
<p>Well, glade is not really a mockup tool, so many things are hard and not easy: to change the title of  a label, you have to select the widget, search the text property and <span style="text-decoration: underline;">then</span> change the text (three clicks and two scrolls movements!). It would be easier if you could change it directly from the preview, why it&#8217;s so hard? Also, the packing options (like expand) are hidden behind two more clicks.</p>
<p>Other things are actually hard and very difficult to do. I mean, anything that requires a &#8216;model&#8217;: tables, lists and even text entries required them. It&#8217;s just impossible to do it fast, which is sad because this kind of thing is also required in normal desktop applications.</p>
<p>However, I love the idea of automatic packing of widgets. This is far better than packing elements by myself.</p>
<p>My conclusion: if glade improves this problems, it would became a fantastic tool for making any kind of mockups (and also, it would be easier to modify our desktop apps interface). In the meantime, I&#8217;m not sure if I&#8217;ll continue with this app or will try something different&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://aldrin.martoq.cl/techblog/2010/01/web-mockups-fast-and-free/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The perfect web application technology, part 2: Common Web Apps Requirements</title>
		<link>http://aldrin.martoq.cl/techblog/2010/01/the-perfect-web-application-technology-part-2-common-web-apps-requirements/</link>
		<comments>http://aldrin.martoq.cl/techblog/2010/01/the-perfect-web-application-technology-part-2-common-web-apps-requirements/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 02:39:15 +0000</pubDate>
		<dc:creator>Aldrin Martoq</dc:creator>
				<category><![CDATA[Quests]]></category>

		<guid isPermaLink="false">http://aldrin.martoq.cl/techblog/?p=139</guid>
		<description><![CDATA[So, to find the perfect web technology we need a typical web application. In this post, I&#8217;m trying to figure out the minimal or common requirements of a typical web application. As I said, I think most developers never consider all the gotchas of doing an application using web technologies. The following requirements may look [...]]]></description>
			<content:encoded><![CDATA[<h3><span style="font-weight: normal; font-size: 13px;">So, to find <a href="http://aldrin.martoq.cl/techblog/the-perfect-web-application-technology/">the perfect web technology</a> we need a typical web application. In this post, I&#8217;m trying to figure out the minimal or common requirements of a typical web application.</span></h3>
<h3><span style="font-weight: normal; font-size: 13px;">As I said, I think most developers never consider all the gotchas of doing an application using web technologies. The following requirements may look like a little too much for &#8220;just a web application&#8221;, but I think this is the real minimum of any web application, no matter the &#8216;size&#8217;.</span></h3>
<p><span style="font-weight: normal; font-size: 13px;"><span id="more-139"></span></span></p>
<ul>
<li><strong>Data processing and storage</strong>
<ul>
<li><strong>Everything is UTF-8</strong>: all textual data (including source code) must be stored, processed and displayed in UTF-8 encoding. The reason is that Unicode is the only sane way of handling data in non-english languages. And from all Unicode standards, UTF-8 is the clear winner in terms of usage and acceptance. This simple innocent requirement immediately discards common used software, like Windows XP and PHP. Isn&#8217;t this amusing?</li>
<li><strong>Validation</strong>: it should be natural or at least easy to assign validation rules of data to programming logic. Examples are: not null fields, only numbers/dates or creating a new validation rule like the Chilean &#8220;<a href="http://www.dcc.uchile.cl/~mortega/microcodigos/validarrut/">dígito verificador del rut</a>&#8220;. It doesn&#8217;t need to be a framework: if the language provides a natural solution (ex: a closure/decorator in python) it&#8217;s sufficient. It should do data validation in both client and server sides, kudos if the rules are written only once.</li>
</ul>
</li>
<li><strong>Development</strong>
<ul>
<li><strong>A joy to develop</strong>: editing HTML files is so 90&#8242;s&#8230; Besides, we are not building pages anymore, but full desktop like applications. So, a modern web technology should encapsulate all the details and talks in terms of reusable components. Examples of this are Google Web Toolkit, some IDE&#8217;s with JSF support and some RIA frameworks.</li>
<li><strong>Fast during development</strong>: I&#8217;m kind of tired the waiting in many JavaEE IDE&#8217;s like eclipse. Everything should be easy to test/run/change during development.</li>
<li><strong>Debugging</strong>: it should be a joy to debug, and I mean, real debugging: pause the application, look around traces and variables, setting breakpoints&#8230; you know what I&#8217;m talking, right?</li>
<li><strong>Multi-tier architecture</strong>: the web application should be a thin presentation layer for services that do the real work. Technically, the business logic is running on remotes servers via a remote procedure call protocol of your choice (RMI, CORBA, Hessian, JSON, XML-RPC, Web Services, whatever).</li>
<li><strong>Data exporters</strong>: the technology must facilitate the export of data to other formats besides HTML within the same application. Examples are: PDF, Office Documents, Chart reports, and other common formats.</li>
</ul>
</li>
<li><strong>User experience</strong>
<ul>
<li><strong>Fast and reliable</strong>: the application should load in no time, it must not crash. The user must never see a 500 error page, neither get a trace of what went wrong&#8230; no excuses!</li>
<li><strong>Browser independent</strong>: it should work and look almost the same  in different browser and operating systems. To put names: Internet Explorer, Firefox, Chrome and Safari; Windows, MacOS and Linux.</li>
<li><strong>Desktop class</strong>: the application shouldn&#8217;t look like a page: it should look and behave like a real desktop application does. Bonus if the application can manipulate data offline!</li>
</ul>
</li>
<li><strong>Security and integrity</strong>
<ul>
<li><strong>Authentication and authorization</strong>: the technology must provide a sane and safe way of authentication.The authorization of certain functionality should be available too, and it should be role-based.</li>
<li><strong>Auditing</strong>: it should be easy to generate audit logs, ideally through a declarative approach. The log should have: the action, logged user, and the data associated.</li>
<li><strong>Transactional</strong>: the web application should not be transaction aware, neither transfer transactional state to the business layer. Every service invoked in the business remote servers is required to be transactional: if the remote operation succeed, transactions are committed; if the remote operation fails, transactions are rolled back. Moreover, this means there will be no long running transactions by one or more web page requests.</li>
<li><strong>OWASP</strong>: the used technology should include countermeasures or help to minimize all common security flaws reported by <a href="http://www.owasp.org/index.php/Top_10_2007">2007 OWASP top ten vulnerabilities report</a>, which are:
<ul>
<li>CSS (or XSS) attacks.</li>
<li>Injection attacks, like SQL injection.</li>
<li>Malicious file execution attacks.</li>
<li>Insecure direct object reference.</li>
<li>CSRF (or XSRF) attacks.</li>
<li>Information leakage and improper error handling.</li>
<li>Strong authentication and session managment.</li>
<li>Insecure communications.</li>
<li>Failure to restrict url access.</li>
</ul>
</li>
<li><strong>Error handling</strong>: any error should be informed to the user, without revealing anything about the internal work of the application. Bonus: a ticket should be assigned, so the user problem may be associated to related traces and logs.</li>
<li><strong>Logging</strong>: must not include secure or very private data, like passwords.</li>
</ul>
</li>
<li><strong>Performance and operational</strong>
<ul>
<li><strong>Scalable</strong>: the web layer should be prepared to scale. Given that all business logic is on remote servers, this should not be a real problem. However, there is data that only belongs to the web layer and is common that this data does not allow to scale, an example of this is session data.</li>
<li><strong>Vertical/Horizontal</strong>: It should be relatively easy to scale vertically (adding CPU cores to the server) as horizontally (adding more servers).</li>
<li><strong>Logging</strong>: given the multi-tier architecture, logging will be necessary, both in development and production. Ideally, all messages should be redirected to a central location like syslog.</li>
</ul>
</li>
</ul>
<h3>Summary</h3>
<p>Well, I have put some basic requirements that any application must/should follow. Your technology of choice may excel at some points, but it&#8217;s probably that some points are really bad and some of them it&#8217;s not even considered.</p>
<p>Next post, I will define the test application I&#8217;m going to create in each language and its requirements. Keep tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://aldrin.martoq.cl/techblog/2010/01/the-perfect-web-application-technology-part-2-common-web-apps-requirements/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The perfect web application technology, part 1: Motivation</title>
		<link>http://aldrin.martoq.cl/techblog/2010/01/the-perfect-web-application-technology-part-1-motivation/</link>
		<comments>http://aldrin.martoq.cl/techblog/2010/01/the-perfect-web-application-technology-part-1-motivation/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 17:00:58 +0000</pubDate>
		<dc:creator>Aldrin Martoq</dc:creator>
				<category><![CDATA[Quests]]></category>

		<guid isPermaLink="false">http://aldrin.martoq.cl/techblog/?p=115</guid>
		<description><![CDATA[This will be a big quest: search, understand, test and evaluate all major web technologies available today. In this first post I will try to summarize the motivations for this little project. I will post subsequent entries for each major technology that can be used to build a web application, including source code. You are [...]]]></description>
			<content:encoded><![CDATA[<p>This will be a big quest: search, understand, test and evaluate all major web technologies available today. In this first post I will try to summarize the motivations for this little project.</p>
<p>I will post subsequent entries for each major technology that can be used to build a web application, including source code. You are invited to participate: tell me what technology I&#8217;m missing, send me patches or fixes, or&#8230; whatever you may like to do.</p>
<p><span id="more-115"></span></p>
<h3>Motivation</h3>
<p>For most of my programming life, I&#8217;ve never considered myself a web developer. You may got answered the &#8220;perfect web application technology&#8221; question many years ago, but that&#8217;s not my case. Well, actually I have done real web programming many times, among many many other things. By real web programming, I mean applications that were or are in use and I get paid for, not just something for myself or some toy experiment.</p>
<p>The problem that keep&#8217;s me avoiding web development is that current web is a big, big success&#8230; but the underlying technology is a big, big mess. Current &#8220;Web 2.0&#8243; (and &#8220;normal web&#8221; too) have been used for something it was never designed, neither predicted.</p>
<p>It all started as a simple way to share information, mostly text and sporadicly an image over there. That&#8217;s where the term &#8220;web page&#8221; comes from: it was an electronic analogy of paper based documentation. There was a server and a client. The client requested a web page, and the browser served a file. You were able to interconnect one web page to another by putting links. HTTP and HTML were born under the &#8220;hypertext&#8221; name: just tag your text and your documents will be displayed as an &#8220;interactive&#8221; web page. And it scaled very well, because there was no central database or system; just a missing (404) link if something went wrong.</p>
<p>Then, the madness began. Browsers wars and incompatibilities (imagine your gnome program doesn&#8217;t work as expected or does not look the same in different Linux distributions), mixing presentation with code (argh! I hated every template I&#8217;ve seen), data conversion mega-problems (like &amp;amp; when it should be &amp;, and not to mention all the problems at all levels when your language is not english). Today, we have a mix of disparate usage and technologies, all of them running over the same &#8220;hypertext web page&#8221; system: wiki&#8217;s, blogs, search engines, JavaScript, tag clouds, DOM, XML, JSON, RSS, Web Services, REST&#8230;. including desktop class applications, like gmail.</p>
<p>So, all of this is running on requesting/response of a page. Does it make sense? Nope. Does it work? Sort of, and painfully. In my opinion, the web is far away of the &#8220;it just works&#8221; phrase.</p>
<p>And that&#8217;s the reason why it is so difficult to build a web application: it is not natural. And because it&#8217;s so difficult to do it, it&#8217;s harder to find projects that did it well. I think nearly all current web applications have at least one or more problems because it&#8217;s so difficult to do, that all developers just get to the point when &#8220;it works for me&#8221;, not considering all the implications of simulating a real desktop class application with a request/response webpage model.</p>
<p>So, that&#8217;s the story: it&#8217;s difficult because it wasn&#8217;t mean to be, it&#8217;s wrong because it so difficult that is nearly impossible to cover all the caveats.</p>
<p>And so, I never liked it. But now, I really want to solve this problem, at least for me. Partly, to make the web a little better. Partly, because I think developers are not aware of any of this. And well, it&#8217;s fun to compare and learn technology.</p>
<p>I will look for technologies that have managed or solver almost all of the common problems derived from this wrong model of making applications. Watch out, because my requirements will probably make your current web technology look like crap.</p>
]]></content:encoded>
			<wfw:commentRss>http://aldrin.martoq.cl/techblog/2010/01/the-perfect-web-application-technology-part-1-motivation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting current file position from a running process</title>
		<link>http://aldrin.martoq.cl/techblog/2009/02/getting-current-file-position-from-a-running-process/</link>
		<comments>http://aldrin.martoq.cl/techblog/2009/02/getting-current-file-position-from-a-running-process/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 03:03:40 +0000</pubDate>
		<dc:creator>Aldrin Martoq</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://aldrin.martoq.cl/techblog/?p=76</guid>
		<description><![CDATA[That was my question in the local linux mailinglist. I received some interesting responses, but while I was writing my own solution (a kernel module that dumps the struct *file-&#62;pos) I found that this is already implemented! Just look at the /proc/&#60;pid&#62;/fdinfo/ files&#8230; Here is an example: # cat /proc/1/fdinfo/1 pos: 0 flags: 02 That [...]]]></description>
			<content:encoded><![CDATA[<p>That was my <a href="http://listas.inf.utfsm.cl/pipermail/linux/2009-January/046532.html">question</a> in the local linux mailinglist. I received <a href="http://listas.inf.utfsm.cl/pipermail/linux/2009-January/046534.html">some</a> <a href="http://listas.inf.utfsm.cl/pipermail/linux/2009-January/046589.html">interesting</a> <a href="http://listas.inf.utfsm.cl/pipermail/linux/2009-January/046591.html">responses</a>, but while I was writing <a href="http://listas.inf.utfsm.cl/pipermail/linux/2009-February/046605.html">my own solution</a> (a kernel module that dumps the struct *file-&gt;pos) I found that this is already implemented!</p>
<p><span id="more-76"></span></p>
<p>Just look at the /proc/&lt;pid&gt;/fdinfo/ files&#8230; Here is an example:<br />
<code># cat /proc/1/fdinfo/1<br />
pos:	0<br />
flags:	02</code><br />
That special file does exactly what I was doing: getting the <tt>struct task_struct</tt> for a PID, then getting its <tt>struct files_struct</tt>, and then the <tt>pos</tt> of the <tt>struct file</tt>. The code is in the linux kernel, in the function <tt>proc_fd_info</tt> inside <tt>fs/proc/base.c</tt>.</p>
<p>And here is a python script that helps a lot:<br />
<code lang="python">#!/usr/bin/env python<br />
# Copyright(C) 2009 Aldrin Martoq<br />
# Licensed under GPL v2 http://www.gnu.org/licenses/gpl-2.0.html<br />
# version 20090206-01</p>
<p>import sys, os</p>
<p>skip = 'socket pipe /dev inotify anon_inode'.split()<br />
cols = 'pid cmdline fd pos size % path'.split()<br />
fmts = '%5s %-15.15s %3s %12s %12s %5s %s'.split()<br />
p1 = '/proc/%s/fdinfo/'<br />
p2 = '/proc/%s/fdinfo/%s'<br />
p3 = '/proc/%s/fd/%s'<br />
p4 = '/proc/%s/cmdline'</p>
<p>for i in range(len(fmts)):<br />
print fmts[i] % cols[i],<br />
print</p>
<p>for pid in sys.argv[1:]:<br />
for fd in os.listdir(p1 % pid):<br />
try:<br />
d = dict(tuple(map(str.strip, l.split(':'))) \<br />
for l in open(p2 % (pid, fd)))<br />
d['path'] = os.readlink(p3 % (pid,fd))<br />
# skip irrelevant fd's...<br />
for p in skip:<br />
if d['path'].startswith(p): break<br />
else:<br />
d['fd'] = fd<br />
d['pid'] = pid<br />
d['cmdline'] = open(p4 % pid).readline().strip()<br />
try: d['size'] = str(os.stat(d['path'])[6])<br />
except: d['size'] = '-'<br />
try: d['%'] = '%5.1f' % (100.0 * int(d['pos']) / int(d['size']))<br />
except: d['%'] = '-'<br />
for i in range(len(fmts)):<br />
print fmts[i] % d[cols[i]].replace('\0', ' '),<br />
print<br />
except Exception, e: print 'FIXME: ' + e<br />
</code><br />
Sample usage:<br />
<code><br />
amartoq@videopodcast:~$ sudo ./fdpos.py $(pgrep ^postgres)<br />
pid cmdline          fd          pos         size     % path<br />
13876 /usr/lib/postgr   1        51519        51519 100.0 /var/log/postgresql/postgresql-8.3-main.log<br />
13876 /usr/lib/postgr   2        51519        51519 100.0 /var/log/postgresql/postgresql-8.3-main.log<br />
13891 postgres: write   1        51519        51519 100.0 /var/log/postgresql/postgresql-8.3-main.log<br />
13891 postgres: write   2        51519        51519 100.0 /var/log/postgresql/postgresql-8.3-main.log<br />
13892 postgres: wal w   1        51519        51519 100.0 /var/log/postgresql/postgresql-8.3-main.log<br />
13892 postgres: wal w   2        51519        51519 100.0 /var/log/postgresql/postgresql-8.3-main.log<br />
13893 postgres: autov   1        51519        51519 100.0 /var/log/postgresql/postgresql-8.3-main.log<br />
13893 postgres: autov   2        51519        51519 100.0 /var/log/postgresql/postgresql-8.3-main.log<br />
13894 postgres: stats   1        51519        51519 100.0 /var/log/postgresql/postgresql-8.3-main.log<br />
13894 postgres: stats   2        51519        51519 100.0 /var/log/postgresql/postgresql-8.3-main.log<br />
15921 postgres: amart   1        51519        51519 100.0 /var/log/postgresql/postgresql-8.3-main.log<br />
15921 postgres: amart   2        51519        51519 100.0 /var/log/postgresql/postgresql-8.3-main.log<br />
15921 postgres: amart   3        16384        16384 100.0 /var/lib/postgresql/8.3/main/base/16473/2684<br />
15921 postgres: amart   6        57344        57344 100.0 /var/lib/postgresql/8.3/main/base/16473/2663<br />
15921 postgres: amart   7       303104       311296  97.4 /var/lib/postgresql/8.3/main/base/16473/1249<br />
15921 postgres: amart  10        16384        16384 100.0 /var/lib/postgresql/8.3/main/base/16473/2693<br />
15921 postgres: amart  11         8192        65536  12.5 /var/lib/postgresql/8.3/main/base/16473/2618<br />
15921 postgres: amart  12        65536        90112  72.7 /var/lib/postgresql/8.3/main/base/16473/2689<br />
15921 postgres: amart  13        16384       106496  15.4 /var/lib/postgresql/8.3/main/base/16473/2617<br />
15921 postgres: amart  14        16384        32768  50.0 /var/lib/postgresql/8.3/main/base/16473/2688<br />
15921 postgres: amart  15        49152        57344  85.7 /var/lib/postgresql/8.3/main/base/16473/2690<br />
15921 postgres: amart  16        65536       409600  16.0 /var/lib/postgresql/8.3/main/base/16473/1255<br />
15921 postgres: amart  17        16384        16384 100.0 /var/lib/postgresql/8.3/main/base/16473/2703<br />
15921 postgres: amart  18        16384        57344  28.6 /var/lib/postgresql/8.3/main/base/16473/1247<br />
15921 postgres: amart  19        16384        16384 100.0 /var/lib/postgresql/8.3/main/base/16473/2661<br />
15921 postgres: amart  20         8192        16384  50.0 /var/lib/postgresql/8.3/main/base/16473/2605<br />
15921 postgres: amart  21       147456       327680  45.0 /var/lib/postgresql/8.3/main/base/16473/2691<br />
15921 postgres: amart  22        16384        32768  50.0 /var/lib/postgresql/8.3/main/base/16473/2686<br />
15921 postgres: amart  23        16384        16384 100.0 /var/lib/postgresql/8.3/main/base/16473/2616<br />
15921 postgres: amart  24        16384        16384 100.0 /var/lib/postgresql/8.3/main/base/16473/2654<br />
15921 postgres: amart  25        49152        49152 100.0 /var/lib/postgresql/8.3/main/base/16473/1259<br />
15921 postgres: amart  26         8192         8192 100.0 /var/lib/postgresql/8.3/main/base/16473/2601<br />
15921 postgres: amart  27        16384        16384 100.0 /var/lib/postgresql/8.3/main/base/16473/2678<br />
15921 postgres: amart  28        16384        16384 100.0 /var/lib/postgresql/8.3/main/base/16473/2662<br />
15921 postgres: amart  29         8192         8192 100.0 /var/lib/postgresql/8.3/main/global/1260<br />
15921 postgres: amart  30        16384        16384 100.0 /var/lib/postgresql/8.3/main/global/2676<br />
15921 postgres: amart  31        16384        16384 100.0 /var/lib/postgresql/8.3/main/global/2677<br />
15921 postgres: amart  32         8192         8192 100.0 /var/lib/postgresql/8.3/main/base/16473/2615<br />
15921 postgres: amart  33        16384        16384 100.0 /var/lib/postgresql/8.3/main/base/16473/2685<br />
15921 postgres: amart  34        16384        16384 100.0 /var/lib/postgresql/8.3/main/base/16473/2696<br />
15921 postgres: amart  35         8192        90112   9.1 /var/lib/postgresql/8.3/main/base/16473/2619<br />
15921 postgres: amart  36        49152        57344  85.7 /var/lib/postgresql/8.3/main/base/16473/2704<br />
15921 postgres: amart  37        16384        16384 100.0 /var/lib/postgresql/8.3/main/base/16473/2650<br />
15921 postgres: amart  38         8192         8192 100.0 /var/lib/postgresql/8.3/main/base/16473/2600<br />
15921 postgres: amart  39        73728        73728 100.0 /var/lib/postgresql/8.3/main/base/16473/2659<br />
15921 postgres: amart  40        16384        16384 100.0 /var/lib/postgresql/8.3/main/base/16473/2656<br />
15921 postgres: amart  41         8192         8192 100.0 /var/lib/postgresql/8.3/main/base/16473/2604<br />
15921 postgres: amart  42         8192         8192 100.0 /var/lib/postgresql/8.3/main/base/16473/16666<br />
15921 postgres: amart  43        16384        16384 100.0 /var/lib/postgresql/8.3/main/base/16473/16675<br />
15921 postgres: amart  44        16384        16384 100.0 /var/lib/postgresql/8.3/main/base/16473/16677<br />
</code></p>
<p><strong>Updated 2009-02-06:</strong> Thanks to <a href="http://listas.inf.utfsm.cl/pipermail/linux/2009-February/046653.html">Daniel Serpell</a> for fixing my bugs.</p>
]]></content:encoded>
			<wfw:commentRss>http://aldrin.martoq.cl/techblog/2009/02/getting-current-file-position-from-a-running-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

