<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>neverbyte.net</title>
	
	<link>http://www.neverbyte.net</link>
	<description>Blog técnico de Iván Alonso</description>
	<lastBuildDate>Wed, 24 Feb 2010 10:20:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/neverbyte" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="neverbyte" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Permitir el hotlinking desde Google Reader con htaccess</title>
		<link>http://www.neverbyte.net/archivo/permitir-el-hotlinking-desde-google-reader-con-htaccess/</link>
		<comments>http://www.neverbyte.net/archivo/permitir-el-hotlinking-desde-google-reader-con-htaccess/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 10:14:09 +0000</pubDate>
		<dc:creator>Iván Alonso</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[hotlinking]]></category>
		<category><![CDATA[htaccess]]></category>

		<guid isPermaLink="false">http://www.neverbyte.net/?p=596</guid>
		<description><![CDATA[Es decir, que quienes estén leyendo tus posts desde Google Reader puedan ver las imágenes aún cuando tengas activado un anti-hotlinking que impide verlas desde fuera de tu propia página.
En el archivo .htaccess del directorio raíz de tu blog, añadiremos:

&#60;IfModule mod_rewrite.c&#62;
RewriteEngine On
RewriteCond %&#123;HTTP_REFERER&#125; !^$
RewriteCond %&#123;HTTP_REFERER&#125; !neverbyte.net &#91;NC&#93;
# Allow Google Reader Access
RewriteCond %&#123;HTTP_REFERER&#125; !^http&#40;s&#41;?://www.google.&#40;com&#124;es&#41;/reader/&#40;m/&#41;?view/.*$ &#91;NC&#93;
RewriteRule .*.&#40;jpg&#124;jpeg&#124;gif&#124;bmp&#124;png&#41;$ [...]]]></description>
			<content:encoded><![CDATA[<p>Es decir, que quienes estén leyendo tus posts desde <strong>Google Reader</strong> puedan ver las imágenes aún cuando tengas activado un <em>anti-hotlinking</em> que impide verlas desde fuera de tu propia página.</p>
<p>En el archivo <em>.htaccess</em> del directorio raíz de tu blog, añadiremos:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>IfModule mod_rewrite.c<span style="color: #000000; font-weight: bold;">&gt;</span>
RewriteEngine On
RewriteCond <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>HTTP_REFERER<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">!</span>^$
RewriteCond <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>HTTP_REFERER<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">!</span>neverbyte.net <span style="color: #7a0874; font-weight: bold;">&#91;</span>NC<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #666666; font-style: italic;"># Allow Google Reader Access</span>
RewriteCond <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>HTTP_REFERER<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">!</span>^http<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span>?:<span style="color: #000000; font-weight: bold;">//</span>www.google.<span style="color: #7a0874; font-weight: bold;">&#40;</span>com<span style="color: #000000; font-weight: bold;">|</span>es<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span>reader<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>m<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>?view<span style="color: #000000; font-weight: bold;">/</span>.<span style="color: #000000; font-weight: bold;">*</span>$ <span style="color: #7a0874; font-weight: bold;">&#91;</span>NC<span style="color: #7a0874; font-weight: bold;">&#93;</span>
RewriteRule .<span style="color: #000000; font-weight: bold;">*</span>.<span style="color: #7a0874; font-weight: bold;">&#40;</span>jpg<span style="color: #000000; font-weight: bold;">|</span>jpeg<span style="color: #000000; font-weight: bold;">|</span>gif<span style="color: #000000; font-weight: bold;">|</span>bmp<span style="color: #000000; font-weight: bold;">|</span>png<span style="color: #7a0874; font-weight: bold;">&#41;</span>$ - <span style="color: #7a0874; font-weight: bold;">&#91;</span>F<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>IfModule<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Esto permite la lectura de imágenes desde tu propia página (<strong>neverbyte.net</strong> en este caso) así como desde Google Reader, mediante una expresión regular que permite obtener cualquier dirección de Google Reader: mediante protocolo http o https (seguro), mediante navegador web o móvil (/m/) y desde la versión internacional o la española de Google (.com o .es).</p>
<p>Lógicamente, esto puede personalizarse mucho más, pero como introducción para empezar nos vale. <a href="http://www.nvcc.edu/home/drodgers/ceu/resources/test_regexp.asp">Aquí</a> podéis probar vuestras expresiones regulares fácilmente, y en <a href="http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html">askapache </a>podéis encontrar algunos trucos interesantes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neverbyte.net/archivo/permitir-el-hotlinking-desde-google-reader-con-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>¿Dónde está el cliente telnet en Windows Vista/7?</title>
		<link>http://www.neverbyte.net/archivo/%c2%bfdonde-esta-el-cliente-telnet-en-windows-vista7/</link>
		<comments>http://www.neverbyte.net/archivo/%c2%bfdonde-esta-el-cliente-telnet-en-windows-vista7/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 10:04:47 +0000</pubDate>
		<dc:creator>Iván Alonso</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[telnet]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.neverbyte.net/archivo/%c2%bfdonde-esta-el-cliente-telnet-en-windows-vista7/</guid>
		<description><![CDATA[Por alguna oscura razón no puede encontrarse ni lanzarse desde línea de comandos (ni desde el menú inicio, ejecutar). Es necesario abrir el Panel de control, Programas, Activar o desactivar las características de Windows, y en la nueva ventana, marcar el checkbox de Cliente Telnet.
A partir de ese momento, el cliente ya estará disponible.
]]></description>
			<content:encoded><![CDATA[<p>Por alguna oscura razón no puede encontrarse ni lanzarse desde línea de comandos (ni desde el menú inicio, ejecutar). Es necesario abrir el <b><i>Panel de control</i></b>, <b><i>Programas</i></b>, <i><b>Activar o desactivar las características de Windows</b></i>, y en la nueva ventana, marcar el <i>checkbox</i> de <b><i>Cliente Telnet</i></b>.</p>
<p>A partir de ese momento, el cliente ya estará disponible.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neverbyte.net/archivo/%c2%bfdonde-esta-el-cliente-telnet-en-windows-vista7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You have advanced to level 1</title>
		<link>http://www.neverbyte.net/archivo/you-have-advanced-to-level-1/</link>
		<comments>http://www.neverbyte.net/archivo/you-have-advanced-to-level-1/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 12:58:10 +0000</pubDate>
		<dc:creator>Iván Alonso</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[programación]]></category>
		<category><![CDATA[Proyecto Euler]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.neverbyte.net/?p=587</guid>
		<description><![CDATA[He estado resolviendo algunos problemas del Proyecto Euler y, tras conseguir los primeros veinticinco, me ha sorprendido con esto:

Parece que esté avanzando en un videojuego. Ya estoy dentro del veinte por ciento de usuarios que han hecho algo más que resolver los dos primeros (algo que hice hace un par de años). Ha costado volver [...]]]></description>
			<content:encoded><![CDATA[<p>He estado resolviendo algunos problemas del <a href="http://projecteuler.net">Proyecto Euler</a> y, tras conseguir los primeros veinticinco, me ha sorprendido con esto:</p>
<p style="text-align: center;"><a href="http://www.neverbyte.net/wp-content/uploads/2010/01/project-euler.png"><img class="size-full wp-image-588  aligncenter" title="project-euler" src="http://www.neverbyte.net/wp-content/uploads/2010/01/project-euler.png" alt="" width="543" height="144" /></a></p>
<p>Parece que esté avanzando en un videojuego. Ya estoy dentro del veinte por ciento de usuarios que han hecho algo más que resolver los dos primeros (algo que hice hace un par de años). Ha costado volver a ponerme con el tema, pero estoy aprovechando que quería conseguir algo más de soltura con <em>Python</em> para, en vez de ponerme a hacer tutoriales insípidos, practicar con problemas de otro tipo.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neverbyte.net/archivo/you-have-advanced-to-level-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problema con algunos botones en Eclipse con Ubuntu 9.10</title>
		<link>http://www.neverbyte.net/archivo/problema-con-algunos-botones-en-eclipse-con-ubuntu-9-10/</link>
		<comments>http://www.neverbyte.net/archivo/problema-con-algunos-botones-en-eclipse-con-ubuntu-9-10/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 13:39:12 +0000</pubDate>
		<dc:creator>Iván Alonso</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[errores]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.neverbyte.net/archivo/problema-con-algunos-botones-en-eclipse-con-ubuntu-9-10/</guid>
		<description><![CDATA[Si estás utilizando la última versión de Ubuntu (9.10 Karmic Koala) y la última versión de Eclipse (descargada de su propia página web, no la que se obtiene de los repositorios de Ubuntu), es posible que des con un error en el que algunos botones de determinados menús no reaccionan a las pulsaciones del ratón [...]]]></description>
			<content:encoded><![CDATA[<p>Si estás utilizando la última versión de Ubuntu (9.10 Karmic Koala) y la última versión de Eclipse (descargada de su propia página web, no la que se obtiene de los repositorios de Ubuntu), es posible que des con un error en el que algunos botones de determinados menús no reaccionan a las pulsaciones del ratón como deberían (aunque sí a las combinaciones de teclas <i>Alt-letra</i>, por ejemplo). Parece estar debido a algunos &#8220;trucos&#8221; gráficos que hace eclipse para saltarse algunas cosas del <i>gdk</i>, y para solucionarlo lo que hay que hacer es lanzar eclipse desde un script como este:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GDK_NATIVE_WINDOWS</span>=<span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>eclipse-<span style="color: #000000;">3.5</span><span style="color: #000000; font-weight: bold;">/</span>eclipse</pre></div></div>

<p>Cambiando el <i>path</i> último por aquél en el que resida la instalación de Eclipse, claro.</p>
<p>Solución encontrada en <a href="http://www.norio.be/blog/2009/10/problems-eclipse-buttons-ubuntu-910">norio.be</a>. Otra opción es utilizar la versión de Eclipse del repositorio de Ubuntu, con esa versión el error no aparece.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neverbyte.net/archivo/problema-con-algunos-botones-en-eclipse-con-ubuntu-9-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DNS-323: Utilizar Tucan Manager desde línea de comandos</title>
		<link>http://www.neverbyte.net/archivo/dns-323-utilizar-tucan-manager-desde-linea-de-comandos-rapidshare-megaupload-etc/</link>
		<comments>http://www.neverbyte.net/archivo/dns-323-utilizar-tucan-manager-desde-linea-de-comandos-rapidshare-megaupload-etc/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 20:13:11 +0000</pubDate>
		<dc:creator>Iván Alonso</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[DNS-323]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tucan Manager]]></category>

		<guid isPermaLink="false">http://www.neverbyte.net/archivo/dns-323-utilizar-tucan-manager-desde-linea-de-comandos-rapidshare-megaupload-etc/</guid>
		<description><![CDATA[Vamos a instalar en nuestra máquina DLink DNS-323 la aplicación Tucan Manager, un software capaz de realizar descargas de servidores como Rapidshare, Megaupload, etc. Dado que Tucan Manager está desarrollada en Python, lo primero que haremos será instalar el intérprete de este lenguaje:

wget http://www.drak0.com/files/dns323/Python-2.5.2-2.tgz
funpkg -i Python-2.5.2-2.tgz

Tras esto nos descargamos e instalamos Tucan Manager, mediante:

wget http://forja.rediris.es/frs/download.php/1470/tucan-0.3.9.tar.gz
gzip [...]]]></description>
			<content:encoded><![CDATA[<p>Vamos a instalar en nuestra máquina <i>DLink DNS-323</i> la aplicación <i>Tucan Manager</i>, un software capaz de realizar descargas de servidores como Rapidshare, Megaupload, etc. Dado que <i><b>Tucan Manager</b></i> está desarrollada en <i>Python</i>, lo primero que haremos será instalar el intérprete de este lenguaje:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.drak0.com<span style="color: #000000; font-weight: bold;">/</span>files<span style="color: #000000; font-weight: bold;">/</span>dns323<span style="color: #000000; font-weight: bold;">/</span>Python-2.5.2-2.tgz
funpkg <span style="color: #660033;">-i</span> Python-2.5.2-2.tgz</pre></div></div>

<p>Tras esto nos descargamos e instalamos <i>Tucan Manager</i>, mediante:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>forja.rediris.es<span style="color: #000000; font-weight: bold;">/</span>frs<span style="color: #000000; font-weight: bold;">/</span>download.php<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1470</span><span style="color: #000000; font-weight: bold;">/</span>tucan-0.3.9.tar.gz
<span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #660033;">-d</span> tucan-0.3.9.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvf</span> tucan-0.3.9.tar
<span style="color: #7a0874; font-weight: bold;">cd</span> tucan-0.3.9<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>Y con esto los <i>scripts</i> de <i>Python</i> estarán disponibles donde deben. Si intentamos ejecutar la aplicación esta no funcionará (al menos en un sistema <i>DNS-323</i>). Si comprobamos la cabecera de cualquiera de los archivos, veremos que indica que para ejecutarse utilizará:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#! /usr/bin/env python</span></pre></div></div>

<p>Que es un directorio que no existe. Lo solucionamos con:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">env</span></pre></div></div>

<p>Tendremos nuestro <i>script</i> en <i>/usr/local/bin</i>, y desde allí podríamos teóricamente lanzarlo mediante</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>tucan</pre></div></div>

<p>Pero eso nos devolverá un error ya que estará intentando lanzarse con el interfaz gráfico (y nos dirá que no encuentra el paquete <i>pygtk</i>). La forma de ignorar esto es lanzar tucan con el parámetro <i>&#8211;cli</i> (y para eso no podemos utilizar <i>env</i>, debemos lanzarlo con el intérprete de <i>python</i>):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">python <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>tucan <span style="color: #660033;">--cli</span></pre></div></div>

<p>Aquí tenéis un <a href="http://forums.tucaneando.com/viewtopic.php?f=6&amp;t=200&amp;p=540#p540">manual de todas las opciones que tenéis para usar tucan desde línea de comandos</a>, donde la más interesante será utilizarlo como un demonio que se descargue todos los enlaces incluidos en un archivo de texto (un enlace por línea), y que se ocupe de las descargas de modo completamente transparente. Comenzaremos a utilizar la aplicación con:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">tucan <span style="color: #660033;">-w</span> updates
tucan <span style="color: #660033;">-c</span> <span style="color: #660033;">-i</span> archivo.txt</pre></div></div>

<p>Si tenemos un error de <i>No module named ImageFile</i>, podemos solucionarlo descargándonos la librería <i>pil</i> (<i>Python image library</i>) e instalándola:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>effbot.org<span style="color: #000000; font-weight: bold;">/</span>downloads<span style="color: #000000; font-weight: bold;">/</span>Imaging-1.1.6.tar.gz
<span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #660033;">-d</span> Imaging-1.1.6.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvf</span> Imaging-1.1.6.tar
<span style="color: #7a0874; font-weight: bold;">cd</span> Imaging-1.1.6<span style="color: #000000; font-weight: bold;">/</span>
python setup.py <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>Tras esta compilación e instalación (que tardará un rato), aún nos faltan algunos otros proyectos que darán lugar a errores futuros si no los tenemos instalados. Primero instalaremos la librería <b>tesseract-OCR</b>, que tenemos disponible mediante el sistema de instalación de <i>optware</i> &#8211; <i>ipkg</i> (si no lo tenéis configurado, podéis hacerlo con el <a href="http://wiki.dns323.info/howto:optware">este tutorial</a> con apenas media docena de instrucciones). Instalaremos la librería (y todas sus dependencias automáticamente), mediante:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ipkg <span style="color: #c20cb9; font-weight: bold;">install</span> tesseract-ocr
ipkg <span style="color: #c20cb9; font-weight: bold;">install</span> tesseract-ocr-lang-eng</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.neverbyte.net/archivo/dns-323-utilizar-tucan-manager-desde-linea-de-comandos-rapidshare-megaupload-etc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mejorando el uso de MLDonkey en un DNS-323</title>
		<link>http://www.neverbyte.net/archivo/mejorando-el-uso-de-mldonkey-en-un-dns-323/</link>
		<comments>http://www.neverbyte.net/archivo/mejorando-el-uso-de-mldonkey-en-un-dns-323/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 11:40:10 +0000</pubDate>
		<dc:creator>Iván Alonso</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[DLink DNS-323]]></category>
		<category><![CDATA[MLDonkey]]></category>
		<category><![CDATA[shell scripts]]></category>

		<guid isPermaLink="false">http://www.neverbyte.net/archivo/mejorando-el-uso-de-mldonkey-en-un-dns-323/</guid>
		<description><![CDATA[Encontré un script de ejecución para MLDonkey mejor que el incluye el sistema de fonz por defecto, en el blog Writings on the wall. No me funcionaba tal y como estaba escrito, así que tuve que cambiar un par de cosas y ahora parece que hace lo que debe.
Ahora, puede especificarse en el arranque si [...]]]></description>
			<content:encoded><![CDATA[<p>Encontré un <i>script</i> de ejecución para <i>MLDonkey</i> mejor que el incluye el sistema de <i>fonz</i> por defecto, en el blog <a href="http://bfg100k.blogspot.com/2008/02/enhanced-mldonkey-script-for-your-dns.html">Writings on the wall</a>. No me funcionaba tal y como estaba escrito, así que tuve que cambiar un par de cosas y ahora parece que hace lo que debe.</p>
<p>Ahora, puede especificarse en el arranque si quieres que la máquina se pare cuando terminen de descargarse todos los archivos de <i>MLDonkey</i>, o si sólo quieres que sea el propio <i>MLDonkey</i> el que se cierre, gracias a una tarea en el <i>crontab</i> que comprueba periódicamente el estado del servidor.</p>
<p>El <i>script</i> es el siguiente, sólo teniendo que cambiar la contraseña de tu usuario administrador de <i>MLDonkey</i> (para poder conectarte al servidor de descargas y poder pedirle su estado actual):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Found in:</span>
<span style="color: #666666; font-style: italic;"># http://bfg100k.blogspot.com/2008/02/enhanced-mldonkey-script-for-your-dns.html</span>
<span style="color: #666666; font-style: italic;"># Some things changed by Ivan Alonso (www.neverbyte.net)</span>
<span style="color: #666666; font-style: italic;">#  - Changed the pattern searched in the mldonkey downloads status</span>
<span style="color: #666666; font-style: italic;">#  - Changed FUNSH variable with SHELL</span>
<span style="color: #666666; font-style: italic;">#  - Some minor changes in the echo messages</span>
<span style="color: #666666; font-style: italic;">#  - Some paths changed to fit with the default installation paths</span>
<span style="color: #666666; font-style: italic;">#    (fonz fun plug and shadowandy mldonkey versions)</span>
&nbsp;
<span style="color: #666666; font-style: italic;">###################################################################</span>
<span style="color: #666666; font-style: italic;"># author: Sidney Chong (bfg100k[at]gmail[dot]com)                 #</span>
<span style="color: #666666; font-style: italic;"># version: 0.2                                                    #</span>
<span style="color: #666666; font-style: italic;"># date: 18/02/2008                                                #</span>
<span style="color: #666666; font-style: italic;">#                                                                 #</span>
<span style="color: #666666; font-style: italic;"># Version History                                                 #</span>
<span style="color: #666666; font-style: italic;"># ---------------                                                 #</span>
<span style="color: #666666; font-style: italic;"># v0.1 - expanded ShadowAndy(http://www.shadowandy.net) script    #</span>
<span style="color: #666666; font-style: italic;">#        to be more robust on startup as well as added functions  #</span>
<span style="color: #666666; font-style: italic;">#        to check status, stop, restart and auto-stop when        #</span>
<span style="color: #666666; font-style: italic;">#        downloads are completed.                                 #</span>
<span style="color: #666666; font-style: italic;"># v0.2 - added option to shutdown the DNS-323 when downloads are  #</span>
<span style="color: #666666; font-style: italic;">#        completed. By default, the script only stops the         #</span>
<span style="color: #666666; font-style: italic;">#        mldonkey process when there are no more active downloads.#</span>
<span style="color: #666666; font-style: italic;">#                                                                 #</span>
<span style="color: #666666; font-style: italic;">###################################################################</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #800000;">${SHELL}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #666666; font-style: italic;">#setup the ENV variables if not found</span>
  <span style="color: #666666; font-style: italic;">#this can happen when running from crontab</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Environment variables not found, including fun_plug defaults.&quot;</span>
  . <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>HD_a2<span style="color: #000000; font-weight: bold;">/</span>ffp<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>profile
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">MLDONKEY_DIR</span>=<span style="color: #ff0000;">&quot;/mnt/HD_a2/mldonkey&quot;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TMPDIR</span>=<span style="color: #ff0000;">&quot;/mnt/HD_a2/mldonkey/temp&quot;</span>
&nbsp;
<span style="color: #007800;">MLNETBINDIR</span>=<span style="color: #ff0000;">&quot;/mnt/HD_a2/ffp/bin&quot;</span>
<span style="color: #007800;">MLNETLOG</span>=<span style="color: #ff0000;">&quot;/mnt/HD_a2/mldonkey/mlnet.log&quot;</span>
<span style="color: #007800;">TMP_CRONTAB</span>=<span style="color: #ff0000;">&quot;/mnt/HD_a2/ffp/var/log/crontab.tmp&quot;</span>
<span style="color: #007800;">TMP_DL_STATUS</span>=<span style="color: #ff0000;">&quot;/mnt/HD_a2/ffp/var/log/dl.status.tmp&quot;</span>
<span style="color: #007800;">ADMIN_PSWD</span>=<span style="color: #ff0000;">&quot;PUT HERE YOUR MLDONKEY ADMIN PASSWD&quot;</span>
&nbsp;
mlnet_start<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Starting mlnet startup sequence... &quot;</span>
  <span style="color: #666666; font-style: italic;">#check if mlnet is already running. if yes, do nothing</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">`</span>mlnet_status<span style="color: #000000; font-weight: bold;">`</span> = <span style="color: #ff0000;">&quot;running&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;INFO: mldonkey already running! Nothing to do.&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">return</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
  <span style="color: #666666; font-style: italic;">#check for inproper clean up from the past</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #800000;">${MLDONKEY_DIR}</span><span style="color: #000000; font-weight: bold;">/</span>mlnet.pid <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #800000;">${MLDONKEY_DIR}</span><span style="color: #000000; font-weight: bold;">/</span>mlnet.pid
  <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${MLDONKEY_DIR}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;mldonkey directory found.&quot;</span>
  <span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;mldonkey directory (<span style="color: #007800;">${MLDONKEY_DIR}</span>) not found. Creating one...&quot;</span>
    <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #800000;">${MLDONKEY_DIR}</span>
    <span style="color: #666666; font-style: italic;">#change ownership of the folder to the user account we will use to run mlnet</span>
    <span style="color: #666666; font-style: italic;">#chown 504:703 ${MLDONKEY_DIR}</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
  <span style="color: #666666; font-style: italic;">#chmod 664 ${MLDONKEY_DIR}/*</span>
  <span style="color: #800000;">${MLNETBINDIR}</span><span style="color: #000000; font-weight: bold;">/</span>mlnet <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #800000;">${MLNETLOG}</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&amp;</span>
  <span style="color: #666666; font-style: italic;">#${MLNETBINDIR}/mlnet -run_as_useruid 504 &gt; ${MLNETLOG} 2&gt;&amp;1 &amp;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${MLDONKEY_DIR}</span>/incoming&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">777</span> <span style="color: #800000;">${MLDONKEY_DIR}</span><span style="color: #000000; font-weight: bold;">/</span>incoming<span style="color: #000000; font-weight: bold;">/</span>
    <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">777</span> <span style="color: #800000;">${MLDONKEY_DIR}</span><span style="color: #000000; font-weight: bold;">/</span>incoming<span style="color: #000000; font-weight: bold;">/*</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
  _mlnet_setup_softstop stop_when_done
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;mlnet startup sequence completed.&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Check <span style="color: #007800;">${MLNETLOG}</span> for more details.&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
mlnet_stop<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Stopping mlnet... &quot;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">`</span>mlnet_status<span style="color: #000000; font-weight: bold;">`</span> = <span style="color: #ff0000;">&quot;running&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Killing mlnet process... &quot;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #800000;">${MLDONKEY_DIR}</span><span style="color: #000000; font-weight: bold;">/</span>mlnet.pid <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
      <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${MLDONKEY_DIR}</span><span style="color: #000000; font-weight: bold;">/</span>mlnet.pidxargs <span style="color: #c20cb9; font-weight: bold;">kill</span>
    <span style="color: #000000; font-weight: bold;">else</span>
      <span style="color: #c20cb9; font-weight: bold;">pidof</span> mlnet  <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #c20cb9; font-weight: bold;">kill</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done. All mlnet processes killed.&quot;</span>
  <span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;INFO: mlnet not running! Nothing to kill.&quot;</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
  _mlnet_setup_softstop
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;mlnet stop sequence completed.&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># this routine checks to see if mlnet is still alive</span>
<span style="color: #666666; font-style: italic;"># and if there are any downloads active.</span>
<span style="color: #666666; font-style: italic;"># if no downloads are active, it attempts to stop mlnet.</span>
<span style="color: #666666; font-style: italic;"># if &quot;off_when_done&quot; option is specified, it will attempt to</span>
<span style="color: #666666; font-style: italic;"># shutdown the DNS-323 as well.</span>
_mlnet_softstop<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`date`</span>: Checking downloads... &quot;</span>
  <span style="color: #666666; font-style: italic;">#touch ${TMP_DL_STATUS}</span>
  <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-O</span> <span style="color: #800000;">${TMP_DL_STATUS}</span> <span style="color: #660033;">-q</span> <span style="color: #ff0000;">&quot;http://admin:<span style="color: #007800;">${ADMIN_PSWD}</span>@127.0.0.1:4080/submit?q=vd&quot;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-q</span> <span style="color: #ff0000;">'&lt;td class=&quot;dl al np&quot;&gt;R&lt;/td&gt;'</span> <span style="color: #800000;">${TMP_DL_STATUS}</span>
  <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;downloads are still active!&quot;</span>
  <span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;no active downloads found!&quot;</span>
    mlnet_stop
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${1}</span>&quot;</span> = <span style="color: #ff0000;">&quot;off_when_done&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;attempting to shutdown the DNS-323 now. Bye Bye!&quot;</span>
      <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>shutdown
    <span style="color: #000000; font-weight: bold;">fi</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
  <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #800000;">${TMP_DL_STATUS}</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># this routine sets up softstop as a cron job that runs every half hour</span>
<span style="color: #666666; font-style: italic;"># to ADD the cron job, pass &quot;add&quot; into the routine,</span>
<span style="color: #666666; font-style: italic;"># to ADD the cron job with shutdown option, pass &quot;off_when_done&quot;,</span>
<span style="color: #666666; font-style: italic;"># any other values (or no value) means REMOVE by default</span>
_mlnet_setup_softstop<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Setting up softstop on crontab... &quot;</span>
  crontab <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #800000;">${TMP_CRONTAB}</span>
  <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'/mlnet.sh softstop/d'</span> <span style="color: #800000;">${TMP_CRONTAB}</span>
  <span style="color: #007800;">TMP_NAME</span>=<span style="color: #ff0000;">&quot;&quot;</span>
  <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
    stop_when_done<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #007800;">TMP_NAME</span>=<span style="color: #ff0000;">&quot;softstop&quot;</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;INFO: This job will stop mldonkey when all downloads are completed.&quot;</span>
    <span style="color: #000000; font-weight: bold;">;;</span>
    off_when_done<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #007800;">TMP_NAME</span>=<span style="color: #ff0000;">&quot;softstop_off&quot;</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;INFO: This job will attempt to shutdown the DNS-323 when all downloads are completed.&quot;</span>
    <span style="color: #000000; font-weight: bold;">;;</span>
    <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Removing job from crontab... &quot;</span>
    <span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">esac</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMP_NAME}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #666666; font-style: italic;"># sanity check - do not allow adding any job if mlnet is not already running</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">`</span>mlnet_status<span style="color: #000000; font-weight: bold;">`</span> = <span style="color: #ff0000;">&quot;running&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Adding cron job to run every half hour... &quot;</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;0,30 * * * * /mnt/HD_a2/ffp/start/mlnet.sh <span style="color: #007800;">${TMP_NAME}</span> &gt;&gt; /mnt/HD_a2/mldonkey/mlnet.log 2&gt;&amp;1&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${TMP_CRONTAB}</span>
      <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'/^\s*$/d'</span> <span style="color: #800000;">${TMP_CRONTAB}</span>
    <span style="color: #000000; font-weight: bold;">else</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: mlnet is not running. NOT adding job to crontab.&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
  crontab <span style="color: #800000;">${TMP_CRONTAB}</span>
  <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #800000;">${TMP_CRONTAB}</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done.&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
mlnet_restart<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  mlnet_stop
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Waiting 10 secs before starting daemon...&quot;</span>
  <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">10</span>
  mlnet_start
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
mlnet_status<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(pidof mlnet)</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;running&quot;</span>
  <span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;stopped&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
  stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    mlnet_stop
    <span style="color: #000000; font-weight: bold;">;;</span>
  softstop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    _mlnet_softstop
    <span style="color: #000000; font-weight: bold;">;;</span>
  softstop_off<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    _mlnet_softstop off_when_done
    <span style="color: #000000; font-weight: bold;">;;</span>
  set_off_when_done<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    _mlnet_setup_softstop off_when_done
    <span style="color: #000000; font-weight: bold;">;;</span>
  set_stop_when_done<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    _mlnet_setup_softstop stop_when_done
    <span style="color: #000000; font-weight: bold;">;;</span>
  restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    mlnet_restart
    <span style="color: #000000; font-weight: bold;">;;</span>
  status<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    mlnet_status
    <span style="color: #000000; font-weight: bold;">;;</span>
  start<span style="color: #ff0000;">''</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    mlnet_start
    <span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: $0 start | stop | restart | status | set_off_when_done | set_stop_when_done&quot;</span>
    <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.neverbyte.net/archivo/mejorando-el-uso-de-mldonkey-en-un-dns-323/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Buscar y reemplazar en línea de comandos</title>
		<link>http://www.neverbyte.net/archivo/buscar-y-reemplazar-en-linea-de-comandos/</link>
		<comments>http://www.neverbyte.net/archivo/buscar-y-reemplazar-en-linea-de-comandos/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 14:51:30 +0000</pubDate>
		<dc:creator>Iván Alonso</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[administración]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.neverbyte.net/archivo/buscar-y-reemplazar-en-linea-de-comandos/</guid>
		<description><![CDATA[Tras trastear un rato con sed y distinta posibilidades de búsqueda de archivos para poder aplicarlo a varios de ellos, he encontrado esta única instrucción en perl que acaba siendo mucho más sencilla:

perl -pi -w -e 's/texto viejo/texto nuevo/g;' *.php

En las secciones a buscar y reemplazar hay que acordarse de escapar con la barra invertida [...]]]></description>
			<content:encoded><![CDATA[<p>Tras trastear un rato con <i>sed</i> y distinta posibilidades de búsqueda de archivos para poder aplicarlo a varios de ellos, he encontrado esta única instrucción en <i>perl</i> que acaba siendo mucho más sencilla:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">perl <span style="color: #339933;">-</span>pi <span style="color: #339933;">-</span>w <span style="color: #339933;">-</span>e <span style="color: #ff0000;">'s/texto viejo/texto nuevo/g;'</span> <span style="color: #339933;">*.</span>php</pre></div></div>

<p>En las secciones a buscar y reemplazar hay que acordarse de escapar con la barra invertida (&#8216;\&#8217;) determinados caracteres, como paréntesis, barras, etc.</p>
<p><b>Actualizado</b>: para hacerlo recursivo desde un determinado directorio, la mejor solución que he encontrado ha sido:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">perl <span style="color: #339933;">-</span>pi <span style="color: #339933;">-</span>w <span style="color: #339933;">-</span>e <span style="color: #ff0000;">'s/oldstring/newstring/g;'</span> <span style="color: #ff0000;">`grep -ril oldstring *`</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.neverbyte.net/archivo/buscar-y-reemplazar-en-linea-de-comandos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Siguiendo con el rediseño</title>
		<link>http://www.neverbyte.net/archivo/siguiendo-con-el-rediseno/</link>
		<comments>http://www.neverbyte.net/archivo/siguiendo-con-el-rediseno/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 16:52:39 +0000</pubDate>
		<dc:creator>Iván Alonso</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[diseño]]></category>
		<category><![CDATA[neverbyte.net]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.neverbyte.net/archivo/siguiendo-con-el-rediseno/</guid>
		<description><![CDATA[Hace ya unos meses que había comenzado a rediseñar esta página, pero me había quedado parado tras terminar la cabecera y un par de detalles más. He hecho un par de cosas nuevas y lo he traducido todo a un theme de WordPress, para poder ponerlo en pruebas en la página y así poder ir [...]]]></description>
			<content:encoded><![CDATA[<p>Hace ya unos meses que <a href="http://www.neverbyte.net/archivo/creando-una-nueva-cabecera-para-la-web/">había comenzado a rediseñar esta página</a>, pero me había quedado parado tras terminar la cabecera y un par de detalles más. He hecho un par de cosas nuevas y lo he traducido todo a un theme de WordPress, para poder ponerlo en pruebas en la página y así poder ir trabajando sobre algo visible.</p>
<p>Está en permanente construcción, como todo en Internet&#8230;&nbsp;&nbsp;</p>
<p style="text-align: center;"><img src="http://www.neverbyte.net/wp-content/uploads/2009/12/Captura-de-pantalla-2009-12-21-a-las-17.51.54.png" width="480" height="268" alt="Captura de pantalla 2009-12-21 a las 17.51.54.png" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neverbyte.net/archivo/siguiendo-con-el-rediseno/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Primeros pasos con OpenGL (con GLUT)</title>
		<link>http://www.neverbyte.net/archivo/primeros-pasos-con-opengl-con-glut/</link>
		<comments>http://www.neverbyte.net/archivo/primeros-pasos-con-opengl-con-glut/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 09:39:32 +0000</pubDate>
		<dc:creator>Iván Alonso</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[GLUT]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[programación]]></category>

		<guid isPermaLink="false">http://www.neverbyte.net/archivo/primeros-pasos-con-opengl-con-glut/</guid>
		<description><![CDATA[Vamos a por nuestro primer ejemplo con OpenGL. Tras las explicaciones del anterior post sobre OpenGL, la única puntualización necesaria sería sobre qué es eso de GLUT que pone en el título del post. GLUT es el acrónimo de openGL Utility Toolkit, y viene a ser poco más que un wrapper para facilitar las tareas [...]]]></description>
			<content:encoded><![CDATA[<p>Vamos a por nuestro primer ejemplo con <em>OpenGL</em>. Tras las explicaciones del <a href="http://www.neverbyte.net/archivo/%c2%bfopengl/">anterior post</a> sobre <em>OpenGL</em>, la única puntualización necesaria sería sobre qué es eso de GLUT que pone en el título del post. GLUT es el acrónimo de <a href="http://www.opengl.org/resources/libraries/glut/">openGL Utility Toolkit</a>, y viene a ser poco más que un <em>wrapper</em> para facilitar las tareas más comunes, con llamadas algo más sencillas. <em>A los desarrolladores de OpenGL debería decirles algo el hecho de que este tipo de productos existan y sean tan ampliamente utilizados.</em> Como veremos, también incluye algunas facilidades para el uso del teclado y ratón.</p>
<blockquote><p>Nosotros lo utilizaremos únicamente para este primer ejemplo, para afianzar conceptos básicos&#8230; porque con él estamos perdiendo una gran cantidad de productos potenciales en lo que ejecutar nuestro código (<em>GLUT</em> únicamente existe para los sistemas principales, pero no para consolas, específicamente para productos <em>homebrew</em> que no disponen de <em>SDKs</em> oficiales, ni para el <em>iPhone</em>). Además se dejó de trabajar en <a href="http://en.wikipedia.org/wiki/OpenGL_Utility_Toolkit">GLUT</a> hace tiempo, ahora habría que utilizar <a href="http://en.wikipedia.org/wiki/Freeglut">freeglut</a> y <em>blablabla</em>&#8230; conclusión: no lo vamos a utilizar en el futuro.</p></blockquote>
<p>Lo primero que haremos será crear un nuevo proyecto, de tipo <em>Command Line Tool</em>, para C++, al que pondremos como nombre lo que más rabia nos dé (a mi se me ha ocurrido <em>Demo01</em>, en un arranque de originalidad):</p>
<p style="text-align: center;"><img src="http://www.neverbyte.net/wp-content/uploads/2009/12/Captura-de-pantalla-2009-11-17-a-las-11.04.11.png" alt="Captura de pantalla 2009-11-17 a las 11.04.11.png" width="480" height="317" /></p>
<p>Se creará un proyecto con un único archivo de código (<em>main.cpp</em>). La siguiente tarea a realizar será añadir las referencias a los <em>frameworks</em>/librerías que vamos a utilizar, en este caso <em>OpenGL</em>. Esto lo haremos haciendo click derecho sobre el proyecto, <em>Add, Existing Frameworks</em>:</p>
<p style="text-align: center;"><img src="http://www.neverbyte.net/wp-content/uploads/2009/12/Captura-de-pantalla-2009-11-17-a-las-11.07.48.png" alt="Captura de pantalla 2009-11-17 a las 11.07.48.png" width="480" height="276" /></p>
<p>Otra de las buenas cosas de los Mac es que todo está localizado donde debe. Así que todos los <em>frameworks</em> instalados en el sistema se mostrarán en una lista de la que tan sólo hemos de escoger <em>OpenGL.framework</em> y <em>GLUT.framework</em> (<em>OpenGL Utility Toolkit</em>) y añadirlos al proyecto.</p>
<p><span id="more-534"></span></p>
<p style="text-align: center;"><img src="http://www.neverbyte.net/wp-content/uploads/2009/12/Captura-de-pantalla-2009-11-17-a-las-11.15.59.png" alt="Captura de pantalla 2009-11-17 a las 11.15.59.png" width="231" height="209" /></p>
<p>Los <em>frameworks</em> aparecerán ahora dentro del árbol del proyecto, y podremos ver todos los archivos de cabeceras para consultar el prototipo de cualquier función que podamos necesitar.</p>
<p style="text-align: center;"><img src="http://www.neverbyte.net/wp-content/uploads/2009/12/Captura-de-pantalla-2009-11-17-a-las-11.19.39.png" alt="Captura de pantalla 2009-11-17 a las 11.19.39.png" width="239" height="429" /></p>
<p style="text-align: left;">Sustituimos ahora el código de nuestro <em>main.cpp</em> por el siguiente código, que es una modificación de <a href="http://www.csse.monash.edu.au/~jonmc/CSE3313/Resources/SampleCode/Code/text.c">un ejemplo de Jon McCormark</a>, al que he añadido/traducido varios comentarios, y he modificado el control desde teclado, para que tengáis más ejemplos:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">// Ejemplo basado originalmente en</span>
<span style="color: #666666;">// http://www.csse.monash.edu.au/~jonmc/CSE3313/Resources/SampleCode/Code/text.c</span>
&nbsp;
<span style="color: #339900;">#include &lt;stdlib.h&gt;</span>
<span style="color: #339900;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #339900;">#ifdef __APPLE__</span>
<span style="color: #339900;">#include &lt;GLUT/glut.h&gt;</span>
<span style="color: #339900;">#else</span>
<span style="color: #339900;">#include &lt;GL/glut.h&gt;</span>
<span style="color: #339900;">#endif</span>
&nbsp;
<span style="color: #339900;">#define MESSAGE	&quot;Hola Mundo&quot;</span>
<span style="color: #339900;">#define WINDOW_WIDTH 300</span>
<span style="color: #339900;">#define WINDOW_HEIGHT 300</span>
&nbsp;
<span style="color: #0000ff;">static</span> GLfloat rotate <span style="color: #000080;">=</span> <span style="color:#800080;">0.0</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">static</span> GLfloat x_pos <span style="color: #000080;">=</span> WINDOW_WIDTH<span style="color: #000040;">/</span><span style="color:#800080;">2.0</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">static</span> GLfloat y_pos <span style="color: #000080;">=</span> WINDOW_HEIGHT<span style="color: #000040;">/</span><span style="color:#800080;">2.0</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">void</span> drawText<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span> message<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #ff0000; font-style: italic;">/* raster pos sets the current raster position
	 * mapped via the modelview and projection matrices
	 */</span>
	glRasterPos2f<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>GLfloat<span style="color: #008000;">&#41;</span><span style="color: #0000dd;">0</span>, <span style="color: #008000;">&#40;</span>GLfloat<span style="color: #008000;">&#41;</span><span style="color: #000040;">-</span>WINDOW_HEIGHT<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #ff0000; font-style: italic;">/*
	 * write using bitmap and stroke chars
	 */</span>
	<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">*</span>message<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		glutBitmapCharacter<span style="color: #008000;">&#40;</span>GLUT_BITMAP_HELVETICA_12, <span style="color: #000040;">*</span>message<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		glutStrokeCharacter<span style="color: #008000;">&#40;</span>GLUT_STROKE_ROMAN,<span style="color: #000040;">*</span>message<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">/*
 * display
 *
 * This function is called by the GLUT to display the graphics
 * In this case it clears the screen then calls the function &quot;drawText&quot;
 * which will draw some text using GLUT
 *
 */</span>
<span style="color: #0000ff;">void</span> display<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #ff0000; font-style: italic;">/* set matrix mode to modelview */</span>
    glMatrixMode<span style="color: #008000;">&#40;</span>GL_MODELVIEW<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    glLoadIdentity<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #ff0000; font-style: italic;">/* transformations to scale the stroke text -
     * notice how these only change stroke and raster text
     * differently...
     */</span>
    glScalef<span style="color: #008000;">&#40;</span><span style="color:#800080;">0.001</span>, <span style="color:#800080;">0.001</span>, <span style="color:#800080;">0.001</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    glRotatef<span style="color: #008000;">&#40;</span>rotate, <span style="color: #0000dd;">0</span>, <span style="color: #0000dd;">0</span>, <span style="color:#800080;">1.0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #ff0000; font-style: italic;">/* glTranslatef(-180, -180, 0.0); */</span>
&nbsp;
    glClear<span style="color: #008000;">&#40;</span> GL_COLOR_BUFFER_BIT <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    drawText<span style="color: #008000;">&#40;</span>MESSAGE<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    glFlush<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #ff0000; font-style: italic;">/* force OpenGL output */</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> keyboard<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> k, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">switch</span> <span style="color: #008000;">&#40;</span>k<span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">case</span> <span style="color: #FF0000;">'q'</span><span style="color: #008080;">:</span>
		<span style="color: #0000ff;">case</span> <span style="color: #FF0000;">'Q'</span><span style="color: #008080;">:</span>
		<span style="color: #0000ff;">case</span> <span style="color: #0000dd;">27</span><span style="color: #008080;">:</span> <span style="color: #666666;">// tecla escape</span>
			<span style="color: #0000dd;">exit</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">default</span><span style="color: #008080;">:</span>
			<span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> keyboard_special<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> k, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">char</span> changed <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">switch</span> <span style="color: #008000;">&#40;</span>k<span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #666666;">// Cursor arriba</span>
		<span style="color: #0000ff;">case</span> GLUT_KEY_UP<span style="color: #008080;">:</span>
			y_pos <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color:#800080;">1.0</span><span style="color: #008080;">;</span>
			changed <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
&nbsp;
		<span style="color: #666666;">// Cursor abajo</span>
		<span style="color: #0000ff;">case</span> GLUT_KEY_DOWN<span style="color: #008080;">:</span>
			y_pos <span style="color: #000040;">-</span><span style="color: #000080;">=</span> <span style="color:#800080;">1.0</span><span style="color: #008080;">;</span>
			changed <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
&nbsp;
		<span style="color: #666666;">// Cursor izqda</span>
		<span style="color: #0000ff;">case</span> GLUT_KEY_LEFT<span style="color: #008080;">:</span>
			x_pos <span style="color: #000040;">-</span><span style="color: #000080;">=</span> <span style="color:#800080;">1.0</span><span style="color: #008080;">;</span>
			changed <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
&nbsp;
		<span style="color: #666666;">// Cursor abajo</span>
		<span style="color: #0000ff;">case</span> GLUT_KEY_RIGHT<span style="color: #008080;">:</span>
			x_pos <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color:#800080;">1.0</span><span style="color: #008080;">;</span>
			changed <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
&nbsp;
		<span style="color: #0000ff;">default</span><span style="color: #008080;">:</span>
			<span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
&nbsp;
	<span style="color: #666666;">// Si hemos cambiado la posicion,</span>
	<span style="color: #666666;">// forzamos el repintado</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>changed<span style="color: #008000;">&#41;</span>
		glutPostRedisplay<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> mouse<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> btn, <span style="color: #0000ff;">int</span> state, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
     <span style="color: #666666;">// Boton izquierdo</span>
     <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>btn<span style="color: #000080;">==</span>GLUT_LEFT_BUTTON <span style="color: #000040;">&amp;</span>amp<span style="color: #008080;">;</span><span style="color: #000040;">&amp;</span>amp<span style="color: #008080;">;</span> state <span style="color: #000080;">==</span> GLUT_DOWN<span style="color: #008000;">&#41;</span>
		rotate <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color:#800080;">20.0</span><span style="color: #008080;">;</span>
&nbsp;
     <span style="color: #666666;">// Boton central, volvemos a la posicion inicial</span>
     <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>btn<span style="color: #000080;">==</span>GLUT_MIDDLE_BUTTON <span style="color: #000040;">&amp;</span>amp<span style="color: #008080;">;</span><span style="color: #000040;">&amp;</span>amp<span style="color: #008080;">;</span> state <span style="color: #000080;">==</span> GLUT_DOWN<span style="color: #008000;">&#41;</span>
		rotate <span style="color: #000080;">=</span> <span style="color:#800080;">0.0</span><span style="color: #008080;">;</span>
&nbsp;
     <span style="color: #666666;">// Boton derecho</span>
     <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>btn<span style="color: #000080;">==</span>GLUT_RIGHT_BUTTON <span style="color: #000040;">&amp;</span>amp<span style="color: #008080;">;</span><span style="color: #000040;">&amp;</span>amp<span style="color: #008080;">;</span> state <span style="color: #000080;">==</span> GLUT_DOWN<span style="color: #008000;">&#41;</span>
		rotate <span style="color: #000040;">-</span><span style="color: #000080;">=</span> <span style="color:#800080;">20.0</span><span style="color: #008080;">;</span>
&nbsp;
     <span style="color: #666666;">// Informamos de que debemos redibujar</span>
     glutPostRedisplay<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>   
&nbsp;
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span> <span style="color: #000040;">**</span>argv<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #666666;">// glutInit es la primera llamada, antes que cualquier otra</span>
    <span style="color: #666666;">// funcion de OpenGL o GLUT</span>
    glutInit<span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>argc, argv<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #666666;">// Modo de video inicial, por ahora no nos preocuparemos de esto</span>
    glutInitDisplayMode<span style="color: #008000;">&#40;</span>GLUT_RGB<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    glutInitWindowSize<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">300</span>, <span style="color: #0000dd;">300</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    glutCreateWindow<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;OpenGL/GLUT Demo 01&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #666666;">// Funciones de callback que GLUT llamara cuando sea necesario</span>
    glutDisplayFunc<span style="color: #008000;">&#40;</span>display<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>          <span style="color: #666666;">// Pintar la pantalla</span>
    glutReshapeFunc<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>             <span style="color: #666666;">// Tamaño de la ventana</span>
    glutIdleFunc<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    glutKeyboardFunc<span style="color: #008000;">&#40;</span>keyboard<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>        <span style="color: #666666;">// Teclas ASCII del teclado</span>
    glutSpecialFunc<span style="color: #008000;">&#40;</span>keyboard_special<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// Teclas especiales del teclado</span>
    glutMouseFunc<span style="color: #008000;">&#40;</span>mouse<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>              <span style="color: #666666;">// Raton</span>
&nbsp;
    <span style="color: #666666;">// Y algunas llamadas directamente a OpenGL</span>
    <span style="color: #666666;">// Color para limpiar la pantalla</span>
    glClearColor<span style="color: #008000;">&#40;</span><span style="color:#800080;">1.0</span>, <span style="color:#800080;">0.2</span>, <span style="color:#800080;">1.0</span>, <span style="color:#800080;">1.0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
&nbsp;
    <span style="color: #666666;">// Color para las fuentes</span>
    glColor3f<span style="color: #008000;">&#40;</span><span style="color:#800080;">0.0</span>, <span style="color:#800080;">0.0</span>, <span style="color:#800080;">0.0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #666666;">// Comenzamos la ejecucion</span>
    glutMainLoop<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.neverbyte.net/archivo/primeros-pasos-con-opengl-con-glut/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter tiene sus cosas</title>
		<link>http://www.neverbyte.net/archivo/twitter-tiene-sus-cosas/</link>
		<comments>http://www.neverbyte.net/archivo/twitter-tiene-sus-cosas/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 12:59:45 +0000</pubDate>
		<dc:creator>Iván Alonso</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[humor]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.neverbyte.net/archivo/twitter-tiene-sus-cosas/</guid>
		<description><![CDATA[
Vía Nunca me entero de nada
]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img src="http://www.neverbyte.net/wp-content/uploads/2009/12/200912181358.jpg" width="480" height="385" alt="200912181358.jpg" /></p>
<p style="text-align: center;">Vía <a href="http://quimicefa.tumblr.com/post/279081254/do-want-now-etc-via-hydrahyde">Nunca me entero de nada</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neverbyte.net/archivo/twitter-tiene-sus-cosas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
