<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Javascript on Lorenzo Bolla</title><link>https://lbolla-info.netlify.app/tags/javascript/</link><description>Recent content in Javascript on Lorenzo Bolla</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 04 Jun 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://lbolla-info.netlify.app/tags/javascript/index.xml" rel="self" type="application/rss+xml"/><item><title>Wired elements</title><link>https://lbolla-info.netlify.app/blog/wired-elements/</link><pubDate>Tue, 04 Jun 2024 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/wired-elements/</guid><description>&lt;p&gt;Recently, &lt;a href="https://news.ycombinator.com/item?id=17146451"&gt;a cool project appeared on the front page of HN reported&lt;/a&gt;: &lt;a href="https://wiredjs.com/"&gt;Wired Elements&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I love the font &lt;a href="https://fonts.google.com/specimen/Gloria+Hallelujah"&gt;Gloria Hallelujah&lt;/a&gt;, so, although I am not using the UI elements in this site, I wanted to give the font a try. It fits very well the spirit of these personal &amp;quot;notes&amp;quot;.&lt;/p&gt;</description></item><item><title>Nice threads in Python</title><link>https://lbolla-info.netlify.app/blog/nice-threads-in-python/</link><pubDate>Sat, 01 Feb 2020 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/nice-threads-in-python/</guid><description>&lt;p&gt;Python has two ways to execute code in parallel: processes and threads. Both have their strengths and weaknesses. In particular, threads are cheaper in terms of resources and are able to share memory, but besides the obvious pitfalls of multi-threaded programming, they suffer from some Python specific problems, notably:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Because of the GIL, only one Python's thread is actually running at any one time. So, very little parallelism is possible if the task is CPU bound. In fact, more often than not, it's more efficient to execute multiple tasks sequentially on a single thread (pinned to a single CPU), rather than spawning multiple threads and having the Python interpreter context switching too much and not being able to schedule the threads on all available CPUs.&lt;/p&gt;</description></item><item><title>Elixir pipe operator in Python</title><link>https://lbolla-info.netlify.app/blog/elixir-pipe-operator-in-python/</link><pubDate>Wed, 25 May 2016 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/elixir-pipe-operator-in-python/</guid><description>&lt;p&gt;&lt;a href="http://elixir-lang.org"&gt;Elixir&lt;/a&gt; implements lots of nice ideas, one of which is its &lt;a href="http://elixir-lang.org/docs/stable/elixir/Kernel.html#%7C%3E/2"&gt;pipe operator&lt;/a&gt;. It allows you to write things like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-elixir" data-lang="elixir"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;iex&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; [&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, [&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;], &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt;] &lt;span style="color:#f92672"&gt;|&amp;gt;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;List&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;flatten()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;[&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Or:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-elixir" data-lang="elixir"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;iex&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; inc &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;fn&lt;/span&gt; x &lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt; x &lt;span style="color:#f92672"&gt;+&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;iex&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; dec &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;fn&lt;/span&gt; x &lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt; x &lt;span style="color:#f92672"&gt;-&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;iex&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; square &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;fn&lt;/span&gt; x &lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt; x &lt;span style="color:#f92672"&gt;*&lt;/span&gt; x &lt;span style="color:#66d9ef"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;iex&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;5&lt;/span&gt; &lt;span style="color:#f92672"&gt;|&amp;gt;&lt;/span&gt; inc&lt;span style="color:#f92672"&gt;.&lt;/span&gt;() &lt;span style="color:#f92672"&gt;|&amp;gt;&lt;/span&gt; dec&lt;span style="color:#f92672"&gt;.&lt;/span&gt;() &lt;span style="color:#f92672"&gt;|&amp;gt;&lt;/span&gt; square&lt;span style="color:#f92672"&gt;.&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;25&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Today, just for fun, I tried to implement something similar in Python. Here is the result:&lt;/p&gt;
&lt;script src="https://gist.github.com/lbolla/e7396c77e63b4c168cce27002f588494.js"&gt;&lt;/script&gt;
&lt;p&gt;So, you can write something like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;5&lt;/span&gt; &lt;span style="color:#f92672"&gt;|&lt;/span&gt;P&lt;span style="color:#f92672"&gt;|&lt;/span&gt; inc &lt;span style="color:#f92672"&gt;|&lt;/span&gt;P&lt;span style="color:#f92672"&gt;|&lt;/span&gt; dec &lt;span style="color:#f92672"&gt;|&lt;/span&gt;P&lt;span style="color:#f92672"&gt;|&lt;/span&gt; square
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;25&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Obviously, this is just a toy: it does not implement all the features available in the Elixir's one, but it was fun!&lt;/p&gt;</description></item><item><title>Comparison of blocking and non-blocking Python multiprocessing Queue</title><link>https://lbolla-info.netlify.app/blog/comparison-of-blocking-and-non-blocking-python-multiprocessing-queue/</link><pubDate>Mon, 25 Apr 2016 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/comparison-of-blocking-and-non-blocking-python-multiprocessing-queue/</guid><description>&lt;p&gt;Python's &lt;a href="https://docs.python.org/2/library/multiprocessing.html#multiprocessing.Queue"&gt;multiprocessing&lt;/a&gt; module offers a &lt;code&gt;Queue&lt;/code&gt; implementation. Surprisingly enough (for me at least), its performance varies greatly if used in a blocking or non-blocking fashion. In particular, the non-blocking way is about &lt;em&gt;ten times slower&lt;/em&gt; than the blocking one!&lt;/p&gt;
&lt;p&gt;Consider this code, which feeds a Queue and then drains it in a blocking and non-blocking way:&lt;/p&gt;
&lt;script src="https://gist.github.com/lbolla/92bad9f4320940ac2f762424ac840a12.js"&gt;&lt;/script&gt;
&lt;p&gt;Running it on my machine, with Python 2.7, gives me these results (Python 3.4 results are similar, but less dramatic):&lt;/p&gt;</description></item><item><title>Long running processes manager</title><link>https://lbolla-info.netlify.app/blog/long-running-processes-manager/</link><pubDate>Fri, 17 Jan 2014 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/long-running-processes-manager/</guid><description>&lt;p&gt;If you want to run multiple processes in Python, the nicest way, in my opinion, is to use &lt;a href="https://docs.python.org/3.4/library/concurrent.futures.html"&gt;concurrent.futures&lt;/a&gt; (there is a &lt;a href="https://pypi.python.org/pypi/futures"&gt;backport&lt;/a&gt; for Python 2.x, too).&lt;/p&gt;
&lt;p&gt;A problem that came up recently was to manage multiple long running processes, intended to run forever, from the same Python process. Using something like &lt;a href="http://supervisord.org/"&gt;supervisord&lt;/a&gt; wouldn't be ideal, because each individual application would have its own config file and deployment procedure.&lt;/p&gt;
&lt;p&gt;Instead, having just one &amp;quot;master&amp;quot; Python process to drive several other processes doing the job seemed the easiest solution to manage. The only caveat is that, being the processes managed long running, you want to restart them as soon as they die.&lt;/p&gt;</description></item><item><title>Overcoming Python GIL with Cython</title><link>https://lbolla-info.netlify.app/blog/overcoming-python-gil-with-cython/</link><pubDate>Mon, 23 Dec 2013 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/overcoming-python-gil-with-cython/</guid><description>&lt;p&gt;Everybody is aware of the infamous &lt;a href="https://wiki.python.org/moin/GlobalInterpreterLock"&gt;Python's GIL&lt;/a&gt;. In a nutshell, the GIL is a global variable that prevents multiple threads to be run concurrently by the interpreter. Under some occasions, for certain operations, the interpreter releases the GIL therefore in certain cases this is not a problem. For example, the GIL is released before doing I/O, so I/O bound threads tend to run concurrently. Another example is when doing system calls. Unfortunately, for CPU bound tasks that don't make any I/O or system calls, the GIL prevents different threads from running concurrently, even on multicore CPUs. The astonishing thing is that, in fact, not only different threads do not run concurrently, but they also run slower on multicore CPUs than on single core ones!&lt;/p&gt;</description></item><item><title>Connect to MSSQL from Python with ODBC and FreeTDS</title><link>https://lbolla-info.netlify.app/blog/connect-to-mssql-from-python-with-odbc-and-freetds/</link><pubDate>Thu, 29 Aug 2013 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/connect-to-mssql-from-python-with-odbc-and-freetds/</guid><description>&lt;p&gt;This is another of those posts that I wrote because I always forget how to do things&amp;hellip;&lt;/p&gt;
&lt;p&gt;This time, I don't want to forget how to connect from Python to MSSQL server anymore. In order to do it, you need the following system packages installed:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$&amp;gt; sudo apt-get install unixodbc-dev tdsodbc sqsh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;sqsh&lt;/code&gt; installs all the required &lt;code&gt;freetds&lt;/code&gt;-related libraries; &lt;code&gt;tdsodbc&lt;/code&gt; is the &lt;a href="http://en.wikipedia.org/wiki/FreeTDS"&gt;FreeTDS&lt;/a&gt; driver for &lt;a href="http://en.wikipedia.org/wiki/ODBC"&gt;ODBC&lt;/a&gt; and &lt;code&gt;unixodbc-dev&lt;/code&gt; is needed to install &lt;a href="https://code.google.com/p/pyodbc/"&gt;&lt;code&gt;pyodbc&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Python and C with ctypes</title><link>https://lbolla-info.netlify.app/blog/python-and-c-with-ctypes/</link><pubDate>Wed, 28 Aug 2013 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/python-and-c-with-ctypes/</guid><description>&lt;p&gt;Calling C code from Python is very simple using &lt;a href="https://docs.python.org/2/library/ctypes.html"&gt;ctypes&lt;/a&gt;. Here is a very simple example to get you started and to serve as a reminder for me!&lt;/p&gt;
&lt;p&gt;Let's say you have this C file, defining 3 functions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;foo&lt;/code&gt; which prints something to &lt;code&gt;stdout&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;bar&lt;/code&gt; which returns and &lt;code&gt;int&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;baz&lt;/code&gt; which takes a parameter and returns a value.&lt;/li&gt;
&lt;/ul&gt;
&lt;script src="https://gist.github.com/lbolla/6363780.js?file=go.c"&gt;&lt;/script&gt;
&lt;p&gt;First, you want to compile this C file into a shared object. Here is a &lt;code&gt;Makefile&lt;/code&gt; to do just this: simple type &lt;code&gt;make all&lt;/code&gt; and you're done.&lt;/p&gt;</description></item><item><title>Useful scripts - csvfmt, xmlfmt, jsonfmt</title><link>https://lbolla-info.netlify.app/blog/useful-scripts---csvfmt-xmlfmt-jsonfmt/</link><pubDate>Fri, 16 Nov 2012 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/useful-scripts---csvfmt-xmlfmt-jsonfmt/</guid><description>&lt;p&gt;This is the third post of a series describing simple scripts that I wrote to ease my life as a programmer.&lt;/p&gt;
&lt;p&gt;In this post, I'll describe 3 scripts to &amp;quot;pretty print&amp;quot; some common file types, to improve readability: &lt;a href="https://github.com/lbolla/cmd/blob/master/csvfmt"&gt;&lt;code&gt;csvfmt&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/lbolla/cmd/blob/master/xmlfmt"&gt;&lt;code&gt;xmlfmt&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://github.com/lbolla/cmd/blob/master/jsonfmt"&gt;&lt;code&gt;jsonfmt&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/lbolla/cmd/blob/master/csvfmt"&gt;&lt;code&gt;csvfmt&lt;/code&gt;&lt;/a&gt; takes a &lt;code&gt;CSV&lt;/code&gt; (&amp;quot;Comma Separated Values&amp;quot;) file from &lt;code&gt;stdin&lt;/code&gt;, parses it and pretty print each record as a Python dictionary.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/usr/bin/env python&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; csv
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; sys
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; pprint
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; row &lt;span style="color:#f92672"&gt;in&lt;/span&gt; csv&lt;span style="color:#f92672"&gt;.&lt;/span&gt;DictReader(sys&lt;span style="color:#f92672"&gt;.&lt;/span&gt;stdin):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; pprint&lt;span style="color:#f92672"&gt;.&lt;/span&gt;pprint(row)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Output looks like this:&lt;/p&gt;</description></item><item><title>Tornado vs. Warp vs. Yesod</title><link>https://lbolla-info.netlify.app/blog/tornado-vs.-warp-vs.-yesod/</link><pubDate>Sun, 02 Sep 2012 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/tornado-vs.-warp-vs.-yesod/</guid><description>&lt;p&gt;Today I tried to benchmark 3 web servers that I've used recently:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="http://www.tornadoweb.org/"&gt;Tornado&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://hackage.haskell.org/package/warp/"&gt;Warp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.yesodweb.com/"&gt;Yesod&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In fact, these are only *2* web servers, because &lt;code&gt;Yesod&lt;/code&gt; runs on top of Warp and it's a fully fledged web framework, rather than a web server: but this was also the intent of the benchmark, i.e. to measure how slower all its goodies made Yesod with respect to Warp.&lt;/p&gt;
&lt;p&gt;Tornado and Warp are obviously very different web servers (async vs. threaded, interpreted vs. compiled, etc.) but, &lt;a href="http://ziutek.github.com/web_bench/"&gt;who cares&lt;/a&gt;?&lt;/p&gt;</description></item><item><title>Pipelines in Python</title><link>https://lbolla-info.netlify.app/blog/pipelines-in-python/</link><pubDate>Fri, 20 Apr 2012 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/pipelines-in-python/</guid><description>&lt;p&gt;Generators (&lt;a href="http://www.python.org/dev/peps/pep-0255/"&gt;PEP 255 &amp;quot;Simple Generators&amp;quot;&lt;/a&gt;) and Coroutines (&lt;a href="http://www.python.org/dev/peps/pep-0342/"&gt;PEP 342 &amp;quot;Coroutines via Enhanced Generators&amp;quot;&lt;/a&gt;) are the cleanest way I've come across so far to implement the concept of a &amp;quot;pipeline&amp;quot; in Python.&lt;/p&gt;
&lt;h2 id="first-approximation"&gt;First approximation&lt;/h2&gt;
&lt;p&gt;A pipeline is made of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a &lt;em&gt;Producer&lt;/em&gt;, that generates data;&lt;/li&gt;
&lt;li&gt;many /Stage/s, that receive data from the previous stage and send it to the next;&lt;/li&gt;
&lt;li&gt;a &lt;em&gt;Consumer&lt;/em&gt;, that receives data from the last stage.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The producer is a coroutine that only /send/s data, generated internally from some initial state. /Stage/s are coroutines that both receive and send messages. The &lt;em&gt;consumer&lt;/em&gt; only receives data. Chaining is done in function &lt;em&gt;pipeline&lt;/em&gt;: each argument but the last is instantiated with an instance of the next stage. The full pipeline is &lt;em&gt;started&lt;/em&gt; by issuing a &lt;em&gt;next&lt;/em&gt; (or &lt;em&gt;send(None)&lt;/em&gt;) to the &lt;em&gt;Producer&lt;/em&gt;.&lt;/p&gt;</description></item><item><title>Sudoku solver in Haskell</title><link>https://lbolla-info.netlify.app/blog/sudoku-solver-in-haskell/</link><pubDate>Mon, 27 Feb 2012 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/sudoku-solver-in-haskell/</guid><description>&lt;p&gt;Recently, I've been challenged to write a &lt;a href="http://en.wikipedia.org/wiki/Sudoku"&gt;Sudoku&lt;/a&gt; solver. Not knowing the rules and with only 30 minutes, I needed some help&amp;hellip;&lt;/p&gt;
&lt;p&gt;So, in case someone asks me again, I've implemented the same algorithm in Haskell.&lt;/p&gt;
&lt;script src="https://gist.github.com/1925630.js"&gt; &lt;/script&gt;
&lt;p&gt;I know that &lt;a href="http://www.haskell.org/haskellwiki/Sudoku"&gt;there are already a lot of other solutions&lt;/a&gt;, but, hey, it was fun!&lt;/p&gt;</description></item><item><title>ulint, Universal Lint</title><link>https://lbolla-info.netlify.app/blog/ulint-universal-lint/</link><pubDate>Thu, 05 Jan 2012 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/ulint-universal-lint/</guid><description>&lt;p&gt;I've been using so many code static checkers lately, that I decided to write a wrapper around the ones I use the most. I called it: &lt;a href="https://github.com/lbolla/ulint"&gt;Universal Lint&lt;/a&gt;, &lt;a href="https://github.com/lbolla/ulint"&gt;ulint&lt;/a&gt; for short.&lt;/p&gt;
&lt;p&gt;At the moment, Python, Javascript and Haskell files are supported, but adding new linters/extension is trivial.&lt;/p&gt;
&lt;p&gt;Download it and use it!&lt;/p&gt;</description></item><item><title>git pre-commit hook for Python and Javascript</title><link>https://lbolla-info.netlify.app/blog/git-pre-commit-hook-for-python-and-javascript/</link><pubDate>Thu, 17 Nov 2011 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/git-pre-commit-hook-for-python-and-javascript/</guid><description>&lt;p&gt;Following a &lt;a href="http://news.ycombinator.com/item?id=3244475"&gt;recent discussion on HN&lt;/a&gt;, I decided to share my own &lt;a href="http://book.git-scm.com/5_git_hooks.html"&gt;git pre-commit hook&lt;/a&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/usr/bin/python&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; os
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; sys
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; re
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; subprocess
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;devnull &lt;span style="color:#f92672"&gt;=&lt;/span&gt; open(os&lt;span style="color:#f92672"&gt;.&lt;/span&gt;devnull, &lt;span style="color:#e6db74"&gt;&amp;#39;w&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;call&lt;/span&gt;(cmd):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; p &lt;span style="color:#f92672"&gt;=&lt;/span&gt; subprocess&lt;span style="color:#f92672"&gt;.&lt;/span&gt;Popen(cmd&lt;span style="color:#f92672"&gt;.&lt;/span&gt;split(),
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; stdout&lt;span style="color:#f92672"&gt;=&lt;/span&gt;subprocess&lt;span style="color:#f92672"&gt;.&lt;/span&gt;PIPE,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; stderr&lt;span style="color:#f92672"&gt;=&lt;/span&gt;subprocess&lt;span style="color:#f92672"&gt;.&lt;/span&gt;PIPE)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; out, err &lt;span style="color:#f92672"&gt;=&lt;/span&gt; p&lt;span style="color:#f92672"&gt;.&lt;/span&gt;communicate()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; out&lt;span style="color:#f92672"&gt;.&lt;/span&gt;decode(&lt;span style="color:#e6db74"&gt;&amp;#39;utf-8&amp;#39;&lt;/span&gt;), err&lt;span style="color:#f92672"&gt;.&lt;/span&gt;decode(&lt;span style="color:#e6db74"&gt;&amp;#39;utf-8&amp;#39;&lt;/span&gt;), p&lt;span style="color:#f92672"&gt;.&lt;/span&gt;returncode
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;execute&lt;/span&gt;(cmd, silent&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;False&lt;/span&gt;):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; silent:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; params &lt;span style="color:#f92672"&gt;=&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;stdout&amp;#39;&lt;/span&gt;: devnull,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;stderr&amp;#39;&lt;/span&gt;: devnull,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;else&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; params &lt;span style="color:#f92672"&gt;=&lt;/span&gt; {}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; retcode &lt;span style="color:#f92672"&gt;=&lt;/span&gt; subprocess&lt;span style="color:#f92672"&gt;.&lt;/span&gt;call(cmd&lt;span style="color:#f92672"&gt;.&lt;/span&gt;split(), &lt;span style="color:#f92672"&gt;**&lt;/span&gt;params)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; retcode
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;exists&lt;/span&gt;(cmd):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; execute(&lt;span style="color:#e6db74"&gt;&amp;#39;which &lt;/span&gt;&lt;span style="color:#e6db74"&gt;%s&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;%&lt;/span&gt; cmd, silent&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;True&lt;/span&gt;) &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;get_modified&lt;/span&gt;(ext):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; modified &lt;span style="color:#f92672"&gt;=&lt;/span&gt; re&lt;span style="color:#f92672"&gt;.&lt;/span&gt;compile(&lt;span style="color:#e6db74"&gt;&amp;#39;^(?:M|A).(?P&amp;lt;name&amp;gt;.*\.&lt;/span&gt;&lt;span style="color:#e6db74"&gt;%s&lt;/span&gt;&lt;span style="color:#e6db74"&gt;)&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;%&lt;/span&gt; ext)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; out, _, _ &lt;span style="color:#f92672"&gt;=&lt;/span&gt; call(&lt;span style="color:#e6db74"&gt;&amp;#39;git status --porcelain&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; modifieds &lt;span style="color:#f92672"&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; line &lt;span style="color:#f92672"&gt;in&lt;/span&gt; out&lt;span style="color:#f92672"&gt;.&lt;/span&gt;splitlines():
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;match&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; modified&lt;span style="color:#f92672"&gt;.&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;match&lt;/span&gt;(line&lt;span style="color:#f92672"&gt;.&lt;/span&gt;strip())
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (&lt;span style="color:#66d9ef"&gt;match&lt;/span&gt;):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; modifieds&lt;span style="color:#f92672"&gt;.&lt;/span&gt;append(&lt;span style="color:#66d9ef"&gt;match&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;group(&lt;span style="color:#e6db74"&gt;&amp;#39;name&amp;#39;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; modifieds
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It's a work-in-progress, so you can find the &lt;a href="https://github.com/lbolla/dotfiles/blob/master/githooks/pre-commit"&gt;most updated version here&lt;/a&gt;. To use it, just drop it in your &lt;code&gt;.git/hooks&lt;/code&gt; directory. At every &lt;code&gt;git commit&lt;/code&gt;, it will run &lt;code&gt;[pep8][4]&lt;/code&gt; and &lt;code&gt;[pyflakes][5]&lt;/code&gt; on &lt;code&gt;.py&lt;/code&gt; files, and &lt;code&gt;[gjslint][6]&lt;/code&gt; on &lt;code&gt;.js&lt;/code&gt; files.&lt;/p&gt;</description></item><item><title>They broke delicious</title><link>https://lbolla-info.netlify.app/blog/they-broke-delicious/</link><pubDate>Fri, 30 Sep 2011 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/they-broke-delicious/</guid><description>&lt;p&gt;The new redesign of &lt;a href="http://www.delicious.com"&gt;delicious.com&lt;/a&gt; broke so many things, that I thought I had to take notes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.delicious.com/help/bookmarklets"&gt;bookmarklet&lt;/a&gt; in Chrome can't be drag-n-dropped to the toolbar. Its Javascript code is also hard to copy and paste to create the bookmarklet &amp;quot;manually&amp;quot;.&lt;/li&gt;
&lt;li&gt;install links for the &lt;a href="http://www.delicious.com/help/quicktour/chrome"&gt;chrome&lt;/a&gt; and &lt;a href="http://www.delicious.com/help/quicktour/firefox"&gt;Firefox&lt;/a&gt; extensions redirect to &lt;a href="http://www.delicious.com/help/installff"&gt;empty pages&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.delicious.com/help/tools"&gt;documentation for developer&lt;/a&gt; is coming soon (!)&lt;/li&gt;
&lt;li&gt;the &lt;a href="http://www.delicious.com/"&gt;top-right menu&lt;/a&gt; with the logged-in username and stuff is the most horrible I've ever seen: it changes its width on hover, the corners look interrupted (in Chrome, at least &amp;ndash; I'm not bothered trying with other browsers)&lt;/li&gt;
&lt;li&gt;what the hell are &lt;a href="http://www.delicious.com/stacks/lbolla"&gt;stacks&lt;/a&gt;? Grouping can be done with tags, already, and I don't want that much space in the page taken by a &amp;quot;social&amp;quot; feature! Who needs it?&lt;/li&gt;
&lt;li&gt;the list of links in the main personal page only shows 8 links on my screen&amp;hellip; 8 links?! There's way too much padding, too whitespaces, too much to scroll&amp;hellip; It's a bookmarking services, it should show you bookmarks in the most friendly way!&lt;/li&gt;
&lt;li&gt;image: why should I use an image for myself? And if I don't use one, &lt;a href="http://www.delicious.com/static/img/profile/keyboardcat.png"&gt;I got assigned one by default&lt;/a&gt;&amp;hellip; Please&amp;hellip;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I'll add more to the list in the future.&lt;/p&gt;</description></item><item><title>Javascript templating benchmark</title><link>https://lbolla-info.netlify.app/blog/javascript-templating-benchmark/</link><pubDate>Mon, 23 May 2011 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/javascript-templating-benchmark/</guid><description>&lt;p&gt;There are many popular libraries to do templating in Javascript.&lt;/p&gt;
&lt;p&gt;The most popular are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://api.jquery.com/jQuery.template/"&gt;JQuery Template&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.javascriptr.com/2008/06/05/purejstemplate-a-pure-javascript-templating-engine-for-jquery/"&gt;Pure Template&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ejohn.org/blog/javascript-micro-templating/"&gt;Resig Template&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://code.google.com/p/trimpath/wiki/JavaScriptTemplates"&gt;Trimpath Template&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://aefxx.com/jquery-plugins/jqote2/"&gt;JQote2 Template&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I decided to benchmark them, so I created a simple &amp;quot;hello world&amp;quot; test.&lt;/p&gt;
&lt;p&gt;As usual, the results are interesting. Here are, on my box:&lt;/p&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;&lt;/th&gt;
					&lt;th&gt;Firefox 3.6&lt;/th&gt;
					&lt;th&gt;Chrome 11.0&lt;/th&gt;
					&lt;th&gt;Safari 5.0&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;jQuery Template&lt;/td&gt;
					&lt;td&gt;297ms&lt;/td&gt;
					&lt;td&gt;138ms&lt;/td&gt;
					&lt;td&gt;113ms&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Pure&lt;/td&gt;
					&lt;td&gt;309ms&lt;/td&gt;
					&lt;td&gt;43ms&lt;/td&gt;
					&lt;td&gt;36ms&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Resig&lt;/td&gt;
					&lt;td&gt;309ms&lt;/td&gt;
					&lt;td&gt;41ms&lt;/td&gt;
					&lt;td&gt;41ms&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Trimpath&lt;/td&gt;
					&lt;td&gt;15ms&lt;/td&gt;
					&lt;td&gt;5ms&lt;/td&gt;
					&lt;td&gt;6ms&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;JQote2&lt;/td&gt;
					&lt;td&gt;7ms&lt;/td&gt;
					&lt;td&gt;1ms&lt;/td&gt;
					&lt;td&gt;6ms&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;A part from the obvious result that Firefox is the slowest browser of all, I'm astonished by the excellent performance of JQote2!&lt;/p&gt;</description></item><item><title>Migrating away from wordpress.com</title><link>https://lbolla-info.netlify.app/blog/migrating-away-from-wordpress.com/</link><pubDate>Mon, 11 Apr 2011 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/migrating-away-from-wordpress.com/</guid><description>&lt;p&gt;Today I decided to migrate my blog from &lt;a href="http://lbolla.wordpress.com"&gt;wordpress.com&lt;/a&gt; to &lt;a href="https://lbolla.info/blog"&gt;my own domain&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I did it for many reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;To be able to &lt;a href="http://en.forums.wordpress.com/topic/adding-plugins?replies=8"&gt;add plugins&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;To be able to &lt;a href="http://wordpress.org/support/topic/adding-javascript-to-page"&gt;add javascript&lt;/a&gt; to individual pages&lt;/li&gt;
&lt;li&gt;To run a &lt;a href="http://63222hljwcjlds6no5lczchgsg.hop.clickbank.net/"&gt;customized theme&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;And all the other reasons listed &lt;a href="http://en.support.wordpress.com/com-vs-org/"&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I did not want to loose the popularity and the ranking of my original address, accumulated over the years.&lt;/p&gt;
&lt;p&gt;Here are the steps I had to follow (if the following steps make no sense to you, &lt;a href="http://a07086nbyhov3xdnzplolg3tdz.hop.clickbank.net/"&gt;this guide&lt;/a&gt; might help you):&lt;/p&gt;</description></item><item><title>Get registered domain in Python and Javascript</title><link>https://lbolla-info.netlify.app/blog/get-registered-domain-in-python-and-javascript/</link><pubDate>Tue, 05 Apr 2011 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/get-registered-domain-in-python-and-javascript/</guid><description>&lt;p&gt;&lt;a href="http://www.dkim-reputation.org/regdom-libs/"&gt;reg-dom-libs&lt;/a&gt; are a set of libraries for &lt;code&gt;C&lt;/code&gt;, &lt;code&gt;PHP&lt;/code&gt; and &lt;code&gt;Perl&lt;/code&gt; to convert an arbitrary domain name to the registered domain name.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For simple domains, like &lt;code&gt;www.amazon.com&lt;/code&gt; or &lt;code&gt;news.ycombinator.com&lt;/code&gt;, the task is trivial.&lt;/li&gt;
&lt;li&gt;For more complicated ones, like &lt;code&gt;www.ebay.co.uk&lt;/code&gt; or &lt;code&gt;www.japantimes.co.jp&lt;/code&gt;, handling the second level subdomain is a little painful.&lt;/li&gt;
&lt;li&gt;For exoteric ones, like &lt;code&gt;nic.com.ai&lt;/code&gt; or &lt;code&gt;www.nic.net.ge&lt;/code&gt; or &lt;code&gt;公司.cn&lt;/code&gt;, the problem becomes virtually impossible.&lt;/li&gt;
&lt;li&gt;After seeing stupid ones, like &lt;code&gt;www.comune.caserta.it&lt;/code&gt; (believe it or not, the registered domain is &lt;code&gt;comune.caserta.it&lt;/code&gt;!), I gave up finding an elegant algorithm for the problem.&lt;/li&gt;
&lt;li&gt;A full list of valid registered domain is necessary. Luckily, it is available (and nightly updated) &lt;a href="http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Inspired by &lt;a href="http://www.dkim-reputation.org/regdom-libs/"&gt;reg-dom-libs&lt;/a&gt;, I've ported the algorithm to &lt;a href="https://github.com/lbolla/junk/blob/master/utils/regdomain.py"&gt;Python&lt;/a&gt; and &lt;a href="https://github.com/lbolla/junk/blob/master/utils/regdomain.js"&gt;Javascript&lt;/a&gt;. See the tests at the end of each file for an example of the usage. A demo is available &lt;a href="file:///junk/regdomain/"&gt;here&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Handling an iframe from the inside</title><link>https://lbolla-info.netlify.app/blog/handling-an-iframe-from-the-inside/</link><pubDate>Wed, 30 Mar 2011 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/handling-an-iframe-from-the-inside/</guid><description>&lt;p&gt;If you've ever worked with &lt;code&gt;iframes&lt;/code&gt; you've certainly run into the &lt;a href="http://en.wikipedia.org/wiki/Same_origin_policy"&gt;same origin policy&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;From &lt;a href="http://www.onlineaspect.com/2010/01/15/backwards-compatible-postmessage/"&gt;here&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The same origin policy basically limits how scripts and frames on different domains can talk to each other.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is particularly bad if you want to resize an &lt;code&gt;iframe&lt;/code&gt; to accomodate its content, as this is not doable with simple CSS (to the best of my knowledge!). It can be done using &lt;a href="https://developer.mozilla.org/en/DOM/window.postMessage"&gt;&lt;code&gt;window.postMessage&lt;/code&gt;&lt;/a&gt;, though.&lt;/p&gt;
&lt;p&gt;&lt;a href="file:///junk/iframe/"&gt;See a demo here&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Papers about Python and scientific computing</title><link>https://lbolla-info.netlify.app/blog/papers-about-python-and-scientific-computing/</link><pubDate>Wed, 25 Apr 2007 00:00:00 +0000</pubDate><guid>https://lbolla-info.netlify.app/blog/papers-about-python-and-scientific-computing/</guid><description>&lt;p&gt;Here is a list of articles about Python and scientific computing appeared in &lt;a href="http://www.computer.org/portal/site/cise/index.jsp"&gt;Computing in Science and Engineering&lt;/a&gt;, available online:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.computer.org/portal/site/cise/menuitem.92a12adebee18778161489108bcd45f3/index.jsp?&amp;amp;pName=cise_level1_article&amp;amp;TheCat=1015&amp;amp;path=cise/2007/n3&amp;amp;file=oli.xml&amp;amp;"&gt;Python for Scientific Computing&lt;/a&gt; by Travis E. Oliphant (&lt;a href="http://www.computer.org/portal/cms_docs_cise/cise/2007/n3/10-20.pdf"&gt;pdf&lt;/a&gt;);&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.computer.org/portal/site/cise/menuitem.92a12adebee18778161489108bcd45f3/index.jsp?&amp;amp;pName=cise_level1_article&amp;amp;TheCat=1015&amp;amp;path=cise/2007/n3&amp;amp;file=gei.xml&amp;amp;"&gt;Python: Batteries included&lt;/a&gt; by Paul F. Dubois;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.siue.edu/~rkrauss/pdfs/python-flexible-robots.pdf"&gt;A Python module for modeling and control design of flexible robots&lt;/a&gt; by Ryan W. Krauss;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cirl.berkeley.edu/twiki/pub/User/JarrodMillman/nipy-cise2007.pdf"&gt;Analysis of Functional Magnetic Resonance Imaging in Python&lt;/a&gt; by K. Jarrod Millman and Matthew Brett, Computing in Science and Engineering, vol. 9, no. 3, pp. 52-55, May/June, 2007;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://amath.colorado.edu/faculty/fperez/preprints/ipython-cise-final.pdf"&gt;IPython: A System for Interactive Scientific Computing&lt;/a&gt; by Fernando Perez;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://nitace.bsd.uchicago.edu/misc/c3sci.pdf"&gt;Matplotlib: a 2D Graphics Environment&lt;/a&gt; by John D. Hunter.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Happy reading!&lt;/p&gt;</description></item></channel></rss>