<?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>~Nacho/blog &#187; Internet</title>
	<atom:link href="http://criptonita.com/~nacho/blog/category/internet/feed/" rel="self" type="application/rss+xml" />
	<link>http://criptonita.com/~nacho/blog</link>
	<description>the cutting edge of my mind!</description>
	<lastBuildDate>Fri, 22 Apr 2011 14:01:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Local public transportation in my pocket</title>
		<link>http://criptonita.com/~nacho/blog/2011/03/29/local-public-pocket/</link>
		<comments>http://criptonita.com/~nacho/blog/2011/03/29/local-public-pocket/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 12:08:51 +0000</pubDate>
		<dc:creator>Nacho Barrientos</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://criptonita.com/~nacho/blog/?p=417</guid>
		<description><![CDATA[I&#8217;ve lately spent some time developing a webapp for mobile devices to interact with some of the data published by the Gijón City Council. More specifically, data about local public land transportation schedule and live arrivals. The way they are presenting that information for mobile devices at the moment is very very heavy and slow, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve lately spent some time developing a webapp for mobile devices to interact with some of the data published by <a href="http://www.gijon.es">the Gijón City Council</a>. More specifically, data about local public land transportation schedule and live arrivals. The way they are presenting that information for mobile devices at the moment is very very heavy and slow, so I thought it may be useful to do something simpler for personal usage.</p>
<p>Basically, it is a simple web service that intensively caches data (to avoid stressing the data origin with many requests) and a fancy AJAX-powered frontend with some CSS with mobile browsers in mind (works flawlessly on Android&#8217;s browser and Mobile Safari). Additionally, if you add it as a bookmark to your iPhone&#8217;s home screen it behaves like a native application (you know, splash screen, custom icon, taskbar and so on).</p>
<p>I&#8217;m now working on client-side caching using HTML5 caching for offline usage. This way the application will boot way faster. It&#8217;s almost done, but it still needs some debugging.</p>
<p>I don&#8217;t intend to make it public for now. However, if you find it useful feel free to drop me a line. Beta testers are always welcome (but unfortunately won&#8217;t be rewarded).</p>
<p>This is how it looks like at the moment. The source will be released soon.</p>
<p><strong>Update (23:26):</strong> Android screenshots provided by <a href="http://pozueco.net/">Javier Pozueco</a>. Thanks buddy!</p>
<p><a href="http://criptonita.com/~nacho/blog/wp-content/uploads/2011/03/c1.png"><img class="alignleft size-full wp-image-418" title="c1" src="http://criptonita.com/~nacho/blog/wp-content/uploads/2011/03/c1.png" alt="" width="320" height="480" /></a><a href="http://criptonita.com/~nacho/blog/wp-content/uploads/2011/03/c2.png"><img class="alignright size-full wp-image-419" title="c2" src="http://criptonita.com/~nacho/blog/wp-content/uploads/2011/03/c2.png" alt="" width="320" height="480" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://criptonita.com/~nacho/blog/wp-content/uploads/2011/03/c4.png"><img class="alignleft size-full wp-image-448" title="c4" src="http://criptonita.com/~nacho/blog/wp-content/uploads/2011/03/c4.png" alt="" width="320" height="480" /></a><a href="http://criptonita.com/~nacho/blog/wp-content/uploads/2011/03/c5.png"><img class="alignright size-full wp-image-449" title="c5" src="http://criptonita.com/~nacho/blog/wp-content/uploads/2011/03/c5.png" alt="" width="320" height="480" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://criptonita.com/~nacho/blog/wp-content/uploads/2011/03/c3.jpg"><img class="aligncenter size-full wp-image-420" title="c3" src="http://criptonita.com/~nacho/blog/wp-content/uploads/2011/03/c3.jpg" alt="" width="480" height="320" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://criptonita.com/~nacho/blog/2011/03/29/local-public-pocket/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Search term completion using a search tree</title>
		<link>http://criptonita.com/~nacho/blog/2011/03/24/term-completion-using-a-pythonic-search-tree/</link>
		<comments>http://criptonita.com/~nacho/blog/2011/03/24/term-completion-using-a-pythonic-search-tree/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 11:31:36 +0000</pubDate>
		<dc:creator>Nacho Barrientos</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://criptonita.com/~nacho/blog/?p=363</guid>
		<description><![CDATA[*lol* Nowadays it&#8217;s very usual to find websites offering hints while you&#8217;re typing on a search box. Google is a pretty good example of it. But, how could it be implemented? This feature could be implemented either in the client side or in the server side. If the word list is big (usually it is), [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" title="Google search box completion" src="http://s4.hubimg.com/u/2092171_f520.jpg" alt="Google search box completion" width="520" height="378" /></p>
<p><strong>*lol*</strong></p>
<p>Nowadays it&#8217;s very usual to find websites offering hints while you&#8217;re typing on a search box. Google is a pretty good example of it. But, how could it be implemented?</p>
<p>This feature could be implemented either in the client side or in the server side. If the word list is big (usually it is), it&#8217;s recommended to keep the lookup logic in the server side to save some bytes while transferring the page to the client and also to save some computing power using server-side caches (cool when you plan to serve many requests).</p>
<p>Either way, there should be a data structure somewhere containing the word list and an algorithm to do the lookup. The simplest approach may be to use a list to store the words and issue something like this when you want to get a list of hints for a given prefix:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #008000;">filter</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> x: x.<span style="color: black;">startsWith</span><span style="color: black;">&#40;</span>prefix<span style="color: black;">&#41;</span>, word_list<span style="color: black;">&#41;</span></pre></div></div>

<p>That&#8217;s Python&#8217;s <em>filter</em>, but it works the same way the well-known Haskell&#8217;s first-order function <em>filter</em> does. It builds a new list with the elements of the original list (word_list) that match the predicate (the lambda function).</p>
<p>Although the results can (and should) be cached, the very first lookup (or when the cache expires) would be very inefficient because the entire list must be traversed and that operation will take linear time. Not bad, but when the size of the problem gets bigger (i.e. more and more words in the database) the lookup process may be too slow, especially whether you&#8217;re serving several users at the same time. If the list was sorted, the execution time could be improved a little bit by writing a more sophisticated algorithm, but let&#8217;s keep it that way for now.</p>
<p>Fortunately, there are better and faster ways to face the problem. If you don&#8217;t want to write code (usually the best choice) you may use some high-performance indexing engine such as Apache Lucene. But if you prefer the &#8216;do-it-yourself&#8217; way (for learning purposes), a search tree (more specifically, a <em>trie</em> or a prefix tree) is a good approach.</p>
<p>I&#8217;ve poorly benchmarked both alternatives (the list and the tree) and as expected the tree is pretty quicker generating hints. What I did was to feed both data structures with the content of an American English word list holding ~640k words (debian package <em>wamerican-insane</em>).</p>
<p>So, assuming four is a reasonable minimum prefix length, I measured the time it would take to get a list of words prefixed by <em>hous</em> (yes, just one, remember I said this was a poor benchmark? ;). Unsurprisingly, it took around 230 times longer for the list alternative to generate the hints (438.96 ms vs 1.92 ms). Wow.</p>
<p>My implementation of the tree is as follows. The API is quite straightforward, the &#8220;hot&#8221; methods are <em>put</em> and <em>get_hints</em>. I&#8217;ve stripped off the test suite for space reasons.</p>
<p>Usage example:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #66cc66;">&gt;&gt;&gt;</span> tree = HintSearchTree<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> tree.<span style="color: black;">put</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;nacho&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> tree.<span style="color: black;">put</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;nachos&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> tree.<span style="color: black;">put</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;nachete&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> tree.<span style="color: black;">get_hints</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;nach&quot;</span><span style="color: black;">&#41;</span>
<span style="color: black;">&#91;</span><span style="color: #483d8b;">'nachete'</span>, <span style="color: #483d8b;">'nacho'</span>, <span style="color: #483d8b;">'nachos'</span><span style="color: black;">&#93;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> tree.<span style="color: black;">get_hints</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;nacho&quot;</span><span style="color: black;">&#41;</span>
<span style="color: black;">&#91;</span><span style="color: #483d8b;">'nacho'</span>, <span style="color: #483d8b;">'nachos'</span><span style="color: black;">&#93;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> tree.<span style="color: black;">delete</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;nacho&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> tree.<span style="color: black;">get_hints</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;nacho&quot;</span><span style="color: black;">&#41;</span>
<span style="color: black;">&#91;</span><span style="color: #483d8b;">'nachos'</span><span style="color: black;">&#93;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> tree.<span style="color: black;">count_words</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff4500;">2</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> tree.<span style="color: black;">get_hints</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;n&quot;</span><span style="color: black;">&#41;</span>
<span style="color: black;">&#91;</span><span style="color: #483d8b;">'nachete'</span>, <span style="color: #483d8b;">'nachos'</span><span style="color: black;">&#93;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> tree.<span style="color: black;">is_indexed</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;nachete&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #008000;">True</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> tree.<span style="color: black;">is_indexed</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;nach&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #008000;">False</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> tree.<span style="color: black;">empty</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #008000;">False</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">class</span> HintSearchTreeNode<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
<span style="color: #ff7700;font-weight:bold;">class</span> HintSearchTreeNode<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
  <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, parent=<span style="color: #008000;">None</span>, terminal=<span style="color: #008000;">False</span><span style="color: black;">&#41;</span>:
    <span style="color: #008000;">self</span>._children = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
    <span style="color: #008000;">self</span>._terminal = terminal
    <span style="color: #008000;">self</span>._parent = parent
&nbsp;
  @<span style="color: #008000;">property</span>
  <span style="color: #ff7700;font-weight:bold;">def</span> children<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>._children
&nbsp;
  @<span style="color: #008000;">property</span>
  <span style="color: #ff7700;font-weight:bold;">def</span> terminal<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>._terminal
&nbsp;
  @terminal.<span style="color: black;">setter</span>
  <span style="color: #ff7700;font-weight:bold;">def</span> terminal<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, value<span style="color: black;">&#41;</span>:
    <span style="color: #008000;">self</span>._terminal = value
&nbsp;
  @<span style="color: #008000;">property</span>
  <span style="color: #ff7700;font-weight:bold;">def</span> parent<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>._parent
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> HintSearchTree<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
  <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    <span style="color: #008000;">self</span>._root = HintSearchTreeNode<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">def</span> put<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, word<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;Adds a word to the tree.&quot;&quot;&quot;</span>
    <span style="color: #808080; font-style: italic;"># TODO: Sanitize 'word'</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;</span>gt<span style="color: #66cc66;">;</span> <span style="color: #ff4500;">0</span>:
      <span style="color: #008000;">self</span>._put<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>._root, word<span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">def</span> count_words<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;Retrieves the number of indexed words in the tree.&quot;&quot;&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>._count_words<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>._root<span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">def</span> is_indexed<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, word<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;Returns True if 'word' is indexed.&quot;&quot;&quot;</span>
    node = <span style="color: #008000;">self</span>._find<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>._root, word<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> node <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">None</span> <span style="color: #ff7700;font-weight:bold;">and</span> node.<span style="color: black;">terminal</span> <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #008000;">True</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">def</span> get_hints<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, prefix<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;Returns a list of words prefixed by 'prefix'.&quot;&quot;&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>._match_prefix<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>._root, prefix<span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">def</span> delete<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, word<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;Deletes 'word' (if exists) from the tree.&quot;&quot;&quot;</span>
    terminal = <span style="color: #008000;">self</span>._find<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>._root, word<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> terminal <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">None</span>:
      terminal.<span style="color: black;">terminal</span> = <span style="color: #008000;">False</span>
      <span style="color: #008000;">self</span>._prune<span style="color: black;">&#40;</span>terminal.<span style="color: black;">parent</span>, word<span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">def</span> empty<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;Returns True if the tree contains no elements.&quot;&quot;&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>._root.<span style="color: black;">children</span><span style="color: black;">&#41;</span> == <span style="color: #ff4500;">0</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">def</span> _put<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, node, word, depth=<span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>:
    next_node = node.<span style="color: black;">children</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#91;</span>depth<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> next_node <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #008000;">None</span>:
      next_node = HintSearchTreeNode<span style="color: black;">&#40;</span>parent=node<span style="color: black;">&#41;</span>
      node.<span style="color: black;">children</span><span style="color: black;">&#91;</span>word<span style="color: black;">&#91;</span>depth<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> = next_node
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span>-<span style="color: #ff4500;">1</span> == depth:
      next_node.<span style="color: black;">terminal</span> = <span style="color: #008000;">True</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
      <span style="color: #008000;">self</span>._put<span style="color: black;">&#40;</span>next_node, word, depth+<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">def</span> _count_words<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, node<span style="color: black;">&#41;</span>:
    words = <span style="color: #ff4500;">1</span> <span style="color: #ff7700;font-weight:bold;">if</span> node.<span style="color: black;">terminal</span> <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #008000;">True</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: #ff4500;">0</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> k <span style="color: #ff7700;font-weight:bold;">in</span> node.<span style="color: black;">children</span>:
      words += <span style="color: #008000;">self</span>._count_words<span style="color: black;">&#40;</span>node.<span style="color: black;">children</span><span style="color: black;">&#91;</span>k<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> words
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">def</span> _match_prefix<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, node, prefix<span style="color: black;">&#41;</span>:
    terminal = <span style="color: #008000;">self</span>._find<span style="color: black;">&#40;</span>node, prefix<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> terminal <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">None</span>:
      <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>._harvest_node<span style="color: black;">&#40;</span>terminal, prefix<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
      <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">def</span> _harvest_node<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, node, prefix, path=<span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span>:
    hints = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> node.<span style="color: black;">terminal</span> <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #008000;">True</span>:
      hints.<span style="color: black;">append</span><span style="color: black;">&#40;</span>prefix + path<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> k <span style="color: #ff7700;font-weight:bold;">in</span> node.<span style="color: black;">children</span>:
      hints.<span style="color: black;">extend</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>._harvest_node<span style="color: black;">&#40;</span>node.<span style="color: black;">children</span><span style="color: black;">&#91;</span>k<span style="color: black;">&#93;</span>, prefix, path+k<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> hints
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">def</span> _find<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, node, word, depth=<span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> depth == <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span>:
      <span style="color: #ff7700;font-weight:bold;">return</span> node
    <span style="color: #ff7700;font-weight:bold;">else</span>:
      child = node.<span style="color: black;">children</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#91;</span>depth<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
      <span style="color: #ff7700;font-weight:bold;">if</span> child <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">None</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>._find<span style="color: black;">&#40;</span>child, word, depth+<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
      <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">None</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">def</span> _prune<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, node, word<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">self</span>._count_words<span style="color: black;">&#40;</span>node.<span style="color: black;">children</span><span style="color: black;">&#91;</span>word<span style="color: black;">&#91;</span>-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> == <span style="color: #ff4500;">0</span>:
      <span style="color: #ff7700;font-weight:bold;">del</span> node.<span style="color: black;">children</span><span style="color: black;">&#91;</span>word<span style="color: black;">&#91;</span>-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span>
      <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>node.<span style="color: black;">children</span><span style="color: black;">&#41;</span> == <span style="color: #ff4500;">0</span> <span style="color: #ff7700;font-weight:bold;">and</span> node.<span style="color: black;">parent</span> <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">None</span> \
          <span style="color: #ff7700;font-weight:bold;">and</span> node.<span style="color: black;">terminal</span> <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">True</span>:
        <span style="color: #008000;">self</span>._prune<span style="color: black;">&#40;</span>node.<span style="color: black;">parent</span>, word<span style="color: black;">&#91;</span>:-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>The code is released in the public domain.</p>
]]></content:encoded>
			<wfw:commentRss>http://criptonita.com/~nacho/blog/2011/03/24/term-completion-using-a-pythonic-search-tree/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some Perl to redirect HTTP requests</title>
		<link>http://criptonita.com/~nacho/blog/2011/02/24/some-perl-bits-to-redirect-http-requests/</link>
		<comments>http://criptonita.com/~nacho/blog/2011/02/24/some-perl-bits-to-redirect-http-requests/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 21:55:33 +0000</pubDate>
		<dc:creator>Nacho Barrientos</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://criptonita.com/~nacho/blog/?p=325</guid>
		<description><![CDATA[After almost a year without publishing a single post, it seems this week I&#8217;m going to beat all my records. A week ago, I wanted to prank my brother for a while. Nothing sophisticated&#8230; just some Iptables rules, Tinyproxy and HTTP magic. To go ahead with my evil plans, I needed &#8220;something&#8221; able to redirect [...]]]></description>
			<content:encoded><![CDATA[<p>After almost a year without publishing a single post, it seems this week I&#8217;m going to beat all my records.</p>
<p>A week ago, I wanted to prank my brother for a while. Nothing sophisticated&#8230; just some Iptables rules, Tinyproxy and HTTP magic. To go ahead with my evil plans, I needed &#8220;something&#8221; able to redirect a HTTP request. Actually, there are several ways to do that: Apache redirects, Tornado, Netcat* and so on. These alternatives are fast, bulletproof and time-saving, but not fun.</p>
<p>As many of you probably know, I didn&#8217;t get a job yet. That necessary means that I&#8217;ve got plenty of free time to waste. So&#8230; what did I do? I wrote some Perl and today I&#8217;m publishing the source code just in case someone finds it useful somehow. Like the previous entry, it&#8217;s published in the public domain.</p>
<p>The script just collects connections, issues <em>301</em> back (Moved Permanently) and sets <em>Location</em> to the URI specified as a command line argument (option -u). It lacks some security checks (left as an exercise to the reader) but it does what it is supposed to do. You may likely spot some silly bugs as I haven&#8217;t spent much time reading it again. Reports are welcome!</p>
<p>For those wondering, the prank was a big success. I&#8217;m afraid I can&#8217;t spare any detail by now but it turns out my bro is still thinking that his computer has been cracked.</p>
<p>Example invocation:</p>
<blockquote><p>$ <strong>perl redir.pl -p 7070 -v -t 3 -u http://31337.pl</strong><br />
2011/02/24 21:41:54 Listening on port 7070<br />
2011/02/24 21:41:54 Redirecting HTTP requests to: &#8216;http://31337.pl&#8217;<br />
2011/02/24 21:41:54 3 thread(s) working under the hood<br />
&#8230;</p></blockquote>
<p>And finally the source code:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> threads<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> Thread<span style="color: #339933;">::</span><span style="color: #006600;">Queue</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> POSIX<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> IO<span style="color: #339933;">::</span><span style="color: #006600;">Socket</span><span style="color: #339933;">::</span><span style="color: #006600;">INET</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> HTTP<span style="color: #339933;">::</span><span style="color: #006600;">Request</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> HTTP<span style="color: #339933;">::</span><span style="color: #006600;">Status</span> <span style="color: #000066;">qw</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">:</span>constants status_message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> Getopt<span style="color: #339933;">::</span><span style="color: #006600;">Long</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> DateTime<span style="color: #339933;">::</span><span style="color: #006600;">Format</span><span style="color: #339933;">::</span><span style="color: #006600;">HTTP</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Data<span style="color: #339933;">::</span><span style="color: #006600;">Validate</span><span style="color: #339933;">::</span><span style="color: #006600;">URI</span> <span style="color: #000066;">qw</span><span style="color: #009900;">&#40;</span>is_http_uri<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Log<span style="color: #339933;">::</span><span style="color: #006600;">Log4perl</span> <span style="color: #000066;">qw</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">:</span>easy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> constant MAX_THREADS <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> constant MAX_LEN_HEADERS_BUFFER <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">1024</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> constant DEFAULT_REDIRECT_URI <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;http://www.example.org&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> constant DEFAULT_PORT <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">80</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> constant DEFAULT_POOL_SIZE <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$redir_uri</span> <span style="color: #339933;">=</span> DEFAULT_REDIRECT_URI<span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$server_port</span> <span style="color: #339933;">=</span> DEFAULT_PORT<span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$thread_pool_size</span> <span style="color: #339933;">=</span> DEFAULT_POOL_SIZE<span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$verbose</span><span style="color: #339933;">;</span>
&nbsp;
GetOptions<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'url=s'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">\$redir_uri</span><span style="color: #339933;">,</span> 
           <span style="color: #ff0000;">'port=i'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">\$server_port</span><span style="color: #339933;">,</span>
           <span style="color: #ff0000;">'threads=i'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">\$thread_pool_size</span><span style="color: #339933;">,</span>
           <span style="color: #ff0000;">'verbose'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">\$verbose</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">exit</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Invalid redirect URI (e.g. http://www.example.org)<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">unless</span> is_http_uri<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$redir_uri</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Invalid port (e.g. 8080)<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">unless</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000ff;">$server_port</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #0000ff;">$server_port</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">**</span><span style="color: #cc66cc;">16</span><span style="color: #339933;">;</span>
<span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Invalid pool size (should be in [1..&quot;</span><span style="color: #339933;">.</span>MAX_THREADS<span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;])<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> 
            <span style="color: #b1b100;">unless</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000ff;">$thread_pool_size</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #0000ff;">$thread_pool_size</span> <span style="color: #339933;">&lt;=</span> MAX_THREADS<span style="color: #339933;">;</span>
&nbsp;
Log<span style="color: #339933;">::</span><span style="color: #006600;">Log4perl</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">easy_init</span><span style="color: #009900;">&#40;</span> level <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$verbose</span><span style="color: #339933;">?</span> <span style="color: #0000ff;">$DEBUG</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">$INFO</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pending</span> <span style="color: #339933;">=</span> Thread<span style="color: #339933;">::</span><span style="color: #006600;">Queue</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$lsock</span> <span style="color: #339933;">=</span> IO<span style="color: #339933;">::</span><span style="color: #006600;">Socket</span><span style="color: #339933;">::</span><span style="color: #006600;">INET</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span> LocalPort <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$server_port</span><span style="color: #339933;">,</span>
                                   Proto <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'tcp'</span><span style="color: #339933;">,</span>
                                   Listen <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
                                   Reuse <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Couldn't bind listening socket ($!)<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> 
&nbsp;
INFO<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Listening on port $server_port<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
INFO<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Redirecting HTTP requests to: '$redir_uri'<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@workers</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">..</span><span style="color: #0000ff;">$thread_pool_size</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$thread</span> <span style="color: #339933;">=</span> threads<span style="color: #339933;">-&gt;</span><span style="color: #006600;">create</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;worker&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@workers</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$thread</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
DEBUG<span style="color: #009900;">&#40;</span><span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d thread(s) working under the hood<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$#workers</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Set a tidy shutdown just in case an external agent SIG{INT,TERM}s the process</span>
<span style="color: #0000ff;">$SIG</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'INT'</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$SIG</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'TERM'</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">sub</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;"># Dirty hack. threads-&gt;kill() does not wake up the thread :(</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">..</span><span style="color: #0000ff;">@workers</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #0000ff;">$pending</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">enqueue</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@workers</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        DEBUG<span style="color: #009900;">&#40;</span><span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Worker %d terminated: %d clients served<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">tid</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">join</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$lsock</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #000066;">exit</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$csock</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$lsock</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">accept</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #b1b100;">next</span><span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$pending</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">enqueue</span><span style="color: #009900;">&#40;</span>POSIX<span style="color: #339933;">::</span><span style="color: #006600;">dup</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">fileno</span> <span style="color: #0000ff;">$csock</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    DEBUG<span style="color: #009900;">&#40;</span><span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;New client enqueued: %s:%s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$csock</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">peerhost</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$csock</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">peerport</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$csock</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> worker <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$clients_served</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$fd</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$pending</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">dequeue</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;"># API promises thread safety :-)</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$fd</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066;">return</span> <span style="color: #0000ff;">$clients_served</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$sock</span> <span style="color: #339933;">=</span> IO<span style="color: #339933;">::</span><span style="color: #006600;">Socket</span><span style="color: #339933;">::</span><span style="color: #006600;">INET</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new_from_fd</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$fd</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;r+&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        DEBUG<span style="color: #009900;">&#40;</span><span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Dequeued client %s:%d by worker %d.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$sock</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">peerhost</span><span style="color: #339933;">,</span>
                            <span style="color: #0000ff;">$sock</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">peerport</span><span style="color: #339933;">,</span> threads<span style="color: #339933;">-&gt;</span><span style="color: #006600;">tid</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$buf</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&lt;</span><span style="color: #0000ff;">$sock</span><span style="color: #339933;">&gt;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;"># CAUTION: there isn't any self protection against very long lines</span>
            <span style="color: #b1b100;">last</span> <span style="color: #b1b100;">if</span> <span style="color: #009966; font-style: italic;">/^\r\n$/</span><span style="color: #339933;">;</span>
            <span style="color: #0000ff;">$buf</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
            <span style="color: #000066;">goto</span> BYE <span style="color: #b1b100;">if</span> <span style="color: #000066;">length</span> <span style="color: #0000ff;">$buf</span> <span style="color: #339933;">&gt;</span> MAX_LEN_HEADERS_BUFFER<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$request</span> <span style="color: #339933;">=</span> HTTP<span style="color: #339933;">::</span><span style="color: #006600;">Request</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">parse</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$buf</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            INFO<span style="color: #009900;">&#40;</span><span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;[%s] %s {%s}<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">method</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">uri</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$sock</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">peerhost</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000066;">printf</span> <span style="color: #0000ff;">$sock</span> <span style="color: #ff0000;">&quot;HTTP/1.1 %d %s<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> 
            HTTP_MOVED_PERMANENTLY<span style="color: #339933;">,</span> status_message<span style="color: #009900;">&#40;</span>HTTP_MOVED_PERMANENTLY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span> <span style="color: #0000ff;">$sock</span> <span style="color: #ff0000;">&quot;Date: %s<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> DateTime<span style="color: #339933;">::</span><span style="color: #006600;">Format</span><span style="color: #339933;">::</span><span style="color: #006600;">HTTP</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">format_datetime</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">print</span> <span style="color: #0000ff;">$sock</span> <span style="color: #ff0000;">&quot;Location: $redir_uri<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">print</span> <span style="color: #0000ff;">$sock</span> <span style="color: #ff0000;">&quot;Server: Simple HTTP Redirection/0.1 ($^O)<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">print</span> <span style="color: #0000ff;">$sock</span> <span style="color: #ff0000;">&quot;Connection: close<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">print</span> <span style="color: #0000ff;">$sock</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
BYE<span style="color: #339933;">:</span>  
        <span style="color: #0000ff;">$clients_served</span><span style="color: #339933;">++;</span>
        <span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$sock</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>(*) just an approach, may drop connections:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; 
 <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;HTTP/1.1 301 Moved Permanently<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>Location: http://31337.pl<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> nc <span style="color: #660033;">-l</span> <span style="color: #000000;">7070</span>; 
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://criptonita.com/~nacho/blog/2011/02/24/some-perl-bits-to-redirect-http-requests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2 weeks, 6 days, 16 hours wasted!</title>
		<link>http://criptonita.com/~nacho/blog/2008/03/20/2-weeks-6-days-16-hours-wasted/</link>
		<comments>http://criptonita.com/~nacho/blog/2008/03/20/2-weeks-6-days-16-hours-wasted/#comments</comments>
		<pubDate>Thu, 20 Mar 2008 14:38:45 +0000</pubDate>
		<dc:creator>Nacho Barrientos</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[TV]]></category>

		<guid isPermaLink="false">http://criptonita.com/~nacho/blog/2008/03/20/2-weeks-6-days-16-hours-wasted/</guid>
		<description><![CDATA[Although Dato has recently talked about it, it is worth to drop again a few more bits about MyEpisodes.com as a try to increase its popcon among TV shows addicts. MyEpisodes.com is an easy way to track your activity watching TV shows. Using a fancy interface it is possible, for instance, to tag episodes as [...]]]></description>
			<content:encoded><![CDATA[<p>Although <a href="http://chistera.yi.org/~adeodato/blog/entries/2008/03/19/myepisodes.com.html" title="Dato talking about MyE.com">Dato has recently talked about it</a>, it is worth to drop again a few more bits about <a href="http://www.myepisodes.com/" title="MyEpisodes.com">MyEpisodes.com</a> as a try to increase its <em>popcon </em>among TV shows addicts.</p>
<p>MyEpisodes.com is an easy way to track your activity watching TV shows. Using a fancy interface it is possible, for instance, to tag episodes as acquired/watched, be aware of upcoming premieres and, taking advantage of the provided RSS channels, stay up to date of new episodes without even visiting the website.</p>
<p>Have you ever asked yourself how many hours have you spent in front of your screen watching TV shows? MyEpisodes.com has got the answer.</p>
<p>Cool, isn&#8217;t it? ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://criptonita.com/~nacho/blog/2008/03/20/2-weeks-6-days-16-hours-wasted/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Filesharing milestones</title>
		<link>http://criptonita.com/~nacho/blog/2008/01/05/filesharing-milestones/</link>
		<comments>http://criptonita.com/~nacho/blog/2008/01/05/filesharing-milestones/#comments</comments>
		<pubDate>Sat, 05 Jan 2008 15:47:26 +0000</pubDate>
		<dc:creator>Nacho Barrientos</dc:creator>
				<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://criptonita.com/~nacho/blog/2008/01/05/filesharing-milestones/</guid>
		<description><![CDATA[In order to wake my blog up, let&#8217;s talk about p2p-based filesharing and stuff like that. RevolutionTT is a well-known invite-only bittorrent tracker with high speed transfers in mind where it&#8217;s quite easy getting the maximum transfer speed (here, 10240 kbps) in a few seconds since the download engages. OTOH, if something is brand new [...]]]></description>
			<content:encoded><![CDATA[<p>In order to wake my blog up, let&#8217;s talk about p2p-based filesharing and stuff like that.</p>
<p>RevolutionTT is a well-known invite-only bittorrent tracker with high speed transfers in mind where it&#8217;s quite easy getting the maximum transfer speed (here, 10240 kbps) in a few seconds since the download engages. OTOH, if something is brand new and <em>shareable</em>, it&#8217;s in there.</p>
<p>Member for almost forty weeks, I&#8217;ve just reached a few hours ago the amount of six hundred uploaded gigabytes with an aprox. 4.0 ratio (numerical relationship among uploaded and downloaded bytes). I&#8217;ve been user of a bunch of trackers (both public and private) along my life as p2p user and I&#8217;m pretty sure this one is the best.</p>
<p>If you&#8217;re an intensive p2p user and you&#8217;re still stuck in some crappy public tracker or even using ed2k please consider getting an invite somewhere.</p>
<p><em>RevolutionTT, the revolution has begun</em></p>
]]></content:encoded>
			<wfw:commentRss>http://criptonita.com/~nacho/blog/2008/01/05/filesharing-milestones/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>~nacho v6.0 is out!</title>
		<link>http://criptonita.com/~nacho/blog/2007/08/09/new-website/</link>
		<comments>http://criptonita.com/~nacho/blog/2007/08/09/new-website/#comments</comments>
		<pubDate>Thu, 09 Aug 2007 14:00:31 +0000</pubDate>
		<dc:creator>Nacho Barrientos</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://criptonita.com/~nacho/blog/2007/08/09/new-website/</guid>
		<description><![CDATA[Another redesign of my website featuring a completely rewritten content is out! Please, leave whatever suggestion as an attached comment to this post.]]></description>
			<content:encoded><![CDATA[<p>Another <a href="http://criptonita.com/~nacho/">redesign of my website</a> featuring a completely rewritten content is out!</p>
<p>Please, leave whatever suggestion as an attached comment to this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://criptonita.com/~nacho/blog/2007/08/09/new-website/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hello Slicehost!</title>
		<link>http://criptonita.com/~nacho/blog/2007/07/17/hello-slicehost/</link>
		<comments>http://criptonita.com/~nacho/blog/2007/07/17/hello-slicehost/#comments</comments>
		<pubDate>Tue, 17 Jul 2007 10:03:07 +0000</pubDate>
		<dc:creator>Nacho Barrientos</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://criptonita.com/~nacho/blog/2007/07/17/hello-slicehost/</guid>
		<description><![CDATA[As you might know, I&#8217;ve been sharing a dedicated server with three more guys. Since several months ago, we have been thinking about change the provider because the plans offered by JVDS were very price-outdated compared with other providers. Dreamhost didn&#8217;t fit our requirements (no root access and shared databases., WTF?!), so we had to [...]]]></description>
			<content:encoded><![CDATA[<p>As you might know, I&#8217;ve been sharing a dedicated server with three more guys. Since several months ago, we have been thinking about change the provider  because the plans offered by <a href="http://www.jvds.com/">JVDS</a> were very price-outdated compared with other providers. <a href="http://www.dreamhost.com/">Dreamhost</a> didn&#8217;t fit our requirements (no root access and shared databases., WTF?!), so we had to choose between either <a href="http://linode.com/">Linode</a> or <a href="http://www.slicehost.com/">Slicehost</a>.</p>
<p>After waiting for about a month in the prospective customer queue, we finally moved to Slicehost. Slicehost is a fast, made-from-geeks-to-geeks and <a href="http://www.xensource.com/">XEN</a> powered virtual dedicated servers provider.</p>
<p>We&#8217;re quite happy with the change, we got a new machine with four times more memory for the same price and we also moved from Apache to <a href="http://www.lighttpd.net/">Lighttpd</a>. All the references from Slicehost we read were good and, at least by now, I second those thoughts.</p>
<p><a href="http://zeus.rm-fr.net/~skyhusker/">Skyhusker</a> made an awesome work migrating the stuff and all the services are already moved. Of course, we&#8217;re running <a href="http://www.debian.org/releases/stable/">Etch</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://criptonita.com/~nacho/blog/2007/07/17/hello-slicehost/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The #10000</title>
		<link>http://criptonita.com/~nacho/blog/2007/06/17/the-10000/</link>
		<comments>http://criptonita.com/~nacho/blog/2007/06/17/the-10000/#comments</comments>
		<pubDate>Sun, 17 Jun 2007 19:08:13 +0000</pubDate>
		<dc:creator>Nacho Barrientos</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://criptonita.com/~nacho/blog/2007/06/17/the-10000/</guid>
		<description><![CDATA[I&#8217;ve just submitted my song number 10,000 to last.fm!.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just submitted <a href="http://www.last.fm/music/Hard-Fi/_/Tied+Up+Too+Tight">my song number 10,000</a> to last.fm!.</p>
]]></content:encoded>
			<wfw:commentRss>http://criptonita.com/~nacho/blog/2007/06/17/the-10000/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSPF ha llegado a España</title>
		<link>http://criptonita.com/~nacho/blog/2007/04/06/openspf-ha-llegado-a-espana/</link>
		<comments>http://criptonita.com/~nacho/blog/2007/04/06/openspf-ha-llegado-a-espana/#comments</comments>
		<pubDate>Thu, 05 Apr 2007 23:38:51 +0000</pubDate>
		<dc:creator>Nacho Barrientos</dc:creator>
				<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://criptonita.com/~nacho/blog/2007/04/06/openspf-ha-llegado-a-espana/</guid>
		<description><![CDATA[Tarde, como es habitual con estas cosas en España, pero parece que los ISPs españoles se empiezan a poner las pilas&#8230; Bandaancha nos cuenta&#8230; Según explica Mercè Molist en El País, Telefónica, ONO, Orange o Jazztel son algunos de los 26 proveedores de internet que se suman a un pacto para adoptar el SPF (sender [...]]]></description>
			<content:encoded><![CDATA[<p>Tarde, como es habitual con estas cosas en España, pero parece que los ISPs españoles se empiezan a poner las pilas&#8230;</p>
<p>Bandaancha <a href="http://www.bandaancha.st/weblogart.php?artid=4615">nos cuenta</a>&#8230;</p>
<blockquote><p>
Según explica Mercè Molist en El País, Telefónica, ONO, Orange o Jazztel son algunos de los 26 proveedores de internet que se suman a un pacto para adoptar el SPF (sender policy framework) de manera conjunta.
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://criptonita.com/~nacho/blog/2007/04/06/openspf-ha-llegado-a-espana/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hello again my old dude!</title>
		<link>http://criptonita.com/~nacho/blog/2007/03/19/hello-again-my-old-dude/</link>
		<comments>http://criptonita.com/~nacho/blog/2007/03/19/hello-again-my-old-dude/#comments</comments>
		<pubDate>Mon, 19 Mar 2007 16:23:48 +0000</pubDate>
		<dc:creator>Nacho Barrientos</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://criptonita.com/~nacho/blog/2007/03/19/hello-again-my-old-dude/</guid>
		<description><![CDATA[My mail agent is Mutt again! (again mainly because it was my first MUA). Let&#8217;s fetchmail and procmail do the hard work while I happily browse my mailboxes! Good bye Pine, Evolution, Sylpheed Claws&#8230; and now, Kmail!. (note Evolution link&#8230;) BTW, xfmail2mbox.sh works fine, my mails moved smoothly to Mutt as well, so thanks to [...]]]></description>
			<content:encoded><![CDATA[<p>My mail agent is <a href="http://www.mutt.org">Mutt</a> again! (again mainly because it was my first MUA). Let&#8217;s fetchmail and procmail do the hard work while I happily browse my mailboxes!</p>
<p>Good bye Pine, <a href="http://mail.gnome.org/archives/usability/2005-December/msg00021.html">Evolution</a>, Sylpheed Claws&#8230; and now, <a href="http://kontact.kde.org/kmail/">Kmail</a>!. (note Evolution link&#8230;)</p>
<p>BTW, <a href="http://kontact.kde.org/kmail/tools.php">xfmail2mbox.sh</a> works fine, my mails moved smoothly to Mutt as well, so thanks to Jörg Reinhardt. </p>
]]></content:encoded>
			<wfw:commentRss>http://criptonita.com/~nacho/blog/2007/03/19/hello-again-my-old-dude/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Relicensing</title>
		<link>http://criptonita.com/~nacho/blog/2007/01/03/relicensing/</link>
		<comments>http://criptonita.com/~nacho/blog/2007/01/03/relicensing/#comments</comments>
		<pubDate>Wed, 03 Jan 2007 13:14:42 +0000</pubDate>
		<dc:creator>Nacho Barrientos</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://criptonita.com/~nacho/blog/2007/01/03/relicensing/</guid>
		<description><![CDATA[I&#8217;ve just relicensed my website, after some time thinking about it I moved my website contents from a Creative Commons BY-SA 2.0 to a GPLv2 license once and for all. The main reason is that my concept of free and free software is really closer to the Debian Free Software Guidelines, and, unfortunately, CC licenses [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just <a href="http://criptonita.com/~nacho/aboutweb.php">relicensed my website</a>, after some time thinking about it I moved my website contents from a <a href="http://creativecommons.org/licenses/by-sa/2.0/">Creative Commons BY-SA 2.0</a> to a <a href="http://www.gnu.org/copyleft/gpl.html">GPLv2</a> license once and for all.</p>
<p>The main reason is that my concept of <em>free</em> and <em>free software</em> is really closer to the <a href="http://www.debian.org/social_contract#guidelines">Debian Free Software Guidelines</a>, and, unfortunately, CC licenses terms don&#8217;t match with them very well (issue discussed since months ago in debian-legal and <a href="http://people.debian.org/~evan/ccsummary.html">summed up in this document</a>).</p>
]]></content:encoded>
			<wfw:commentRss>http://criptonita.com/~nacho/blog/2007/01/03/relicensing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Asturian websites: Top 25</title>
		<link>http://criptonita.com/~nacho/blog/2006/11/08/asturian-websites-top-25/</link>
		<comments>http://criptonita.com/~nacho/blog/2006/11/08/asturian-websites-top-25/#comments</comments>
		<pubDate>Wed, 08 Nov 2006 12:27:24 +0000</pubDate>
		<dc:creator>Nacho Barrientos</dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[World]]></category>

		<guid isPermaLink="false">http://criptonita.com/~nacho/blog/?p=81</guid>
		<description><![CDATA[If El Comercio says it, it must be true. It could be interesting to know what is the general criterion to judge how much better than other a web is. Painful.]]></description>
			<content:encoded><![CDATA[<p>If <a href="http://canales.elcomerciodigital.com/extras/mejorweb/index.htm">El Comercio says it</a>, it must be true. It could be interesting to know what is the general criterion to judge how much better than other a web is.</p>
<p>Painful.</p>
]]></content:encoded>
			<wfw:commentRss>http://criptonita.com/~nacho/blog/2006/11/08/asturian-websites-top-25/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending my Firefox&#8217;s capabilities!</title>
		<link>http://criptonita.com/~nacho/blog/2006/10/05/extending-your-firefox/</link>
		<comments>http://criptonita.com/~nacho/blog/2006/10/05/extending-your-firefox/#comments</comments>
		<pubDate>Thu, 05 Oct 2006 00:03:11 +0000</pubDate>
		<dc:creator>Nacho Barrientos</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://criptonita.com/~nacho/blog/?p=78</guid>
		<description><![CDATA[This is just another list of Firefox extensions I&#8217;m using at the moment: Google Toolbar for Firefox &#8211; Useful Google utils pack (includes search, of course). del.icio.us &#8211; All I need to manage my social bookmarks. ColorZilla &#8211; Interesting extension to extract colour codes directly from websites. VideoDownloader &#8211; Well known add-on. Forecastfox &#8211; And [...]]]></description>
			<content:encoded><![CDATA[<p>This is just another list of Firefox extensions I&#8217;m using at the moment:</p>
<ul>
<li><strong>Google Toolbar for Firefox</strong> &#8211; Useful Google utils pack (includes search, of course).</li>
<li><strong>del.icio.us</strong> &#8211; All I need to manage my social bookmarks.</li>
<li><strong>ColorZilla</strong> &#8211; Interesting extension to extract colour codes directly from websites.</li>
<li><strong>VideoDownloader</strong> &#8211; Well known add-on.</li>
<li><strong>Forecastfox</strong> &#8211; And if it rains tomorrow?.</li>
<li><strong>PDF Download</strong> &#8211; Just a dialog to choose between open, download, or show as HTML the downloaded PDF files.</li>
<li><strong>Download Statusbar</strong> &#8211; Enhanced and interesting download manager.</li>
<li><strong>Colorful Tabs</strong> &#8211; Put colours in your life!</li>
<li><strong>Flashblock</strong> &#8211; Flash really sucks, prevent it for me!</li>
<li><strong>Extended Statusbar</strong> &#8211; Adds more information about the loaded website, for example spent time or download speed.</li>
<li><strong>Tab X</strong> &#8211; Adds an independent kill button to each tab.</li>
<li><strong>Link Alert</strong> &#8211; Prevents me to download rubbish, like Microsoft Word documents.</li>
</ul>
<p>Excuse me, I forgot all the links to these extensions, feel free to <a href="https://addons.mozilla.org/extensions.php?app=firefox">search them</a> yourself ;)</p>
<p>This ultraextended Firefox makes my life easier!</p>
]]></content:encoded>
			<wfw:commentRss>http://criptonita.com/~nacho/blog/2006/10/05/extending-your-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>X-Facing!</title>
		<link>http://criptonita.com/~nacho/blog/2006/09/14/x-facing/</link>
		<comments>http://criptonita.com/~nacho/blog/2006/09/14/x-facing/#comments</comments>
		<pubDate>Thu, 14 Sep 2006 22:05:32 +0000</pubDate>
		<dc:creator>Nacho Barrientos</dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://criptonita.com/~nacho/blog/?p=72</guid>
		<description><![CDATA[Finally, after two or three attempts, i built a new X-Face (the old one was a bit &#8220;noisy&#8221;): X-Face: h;*J`D,fz$pX,X$-{&#8216;bN,@\9[a?`~d343Zg+4gy=gcpE(]&#8220;;flj/ XOdFs*)p3y9k[sG9AyN"qp^LYJ!Wu]]></description>
			<content:encoded><![CDATA[<p>Finally, after two or three attempts, i built a new <a href="http://en.wikipedia.org/wiki/X-Face">X-Face</a> (the old one was a bit &#8220;noisy&#8221;):</p>
<blockquote><p>
X-Face: h;*J`D,fz$pX,X$-{&#8216;bN,@\9[a?`~d343Zg+4gy=gcpE(]&#8220;;flj/<br />
XOdFs*)p3y9k[sG9AyN"qp^LYJ!Wu<z *'H]ldJ!L/s#Lcj$Bpl^AB><br />
bUXxXcm?QZ}XqI@C?\~DSUAv/DAajj;wr(|@BZgigOFX< {d=X<br />
TT/GX0`,![]"`iZ$WC
</p></blockquote>
<p><a href="http://www.dairiki.org/xface/xface.php?xface=h%3B%2AJ%60D%2Cfz%24pX%2CX%24-%7B%27bN%2C%40%5C9%5Ba%3F%60%7Ed343Zg%2B4gy%3DgcpE%28%5D%22%3Bflj%2FXOdFs%2A%29p3y9k%5BsG9AyN%22qp%5ELYJ%21Wu%3Cz%2A%27H%5DldJ%21L%2Fs%23Lcj%24Bpl%5EAB%3EbUXxXcm%3FQZ%7DXqI%40C%3F%5C%7EDSUAv%2FDAajj%3Bwr%28%7C%40BZgigOFX%3C%7Bd%3DXTT%2FGX0%60%2C%21%5B%5D%22%60iZ%24WC&#038;preview=1">View it</a> in action or <em>verbatimize</em> it skipping line jumps :)</z></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://criptonita.com/~nacho/blog/2006/09/14/x-facing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

