<?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>Dr Jekyll &#38; Mr Hyde &#187; Python</title>
	<atom:link href="http://www.rfc1149.net/blog/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rfc1149.net/blog/</link>
	<description>Samuel Tardieu's dual-sided blog</description>
	<lastBuildDate>Tue, 20 Jul 2010 13:04:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<atom:link rel='hub' href='http://www.rfc1149.net/blog/?pushpress=hub'/>
		<item>
		<title>Prime numbers and Pell equation</title>
		<link>http://www.rfc1149.net/blog/2006/02/10/prime-numbers-and-pell-equation/</link>
		<comments>http://www.rfc1149.net/blog/2006/02/10/prime-numbers-and-pell-equation/#comments</comments>
		<pubDate>Fri, 10 Feb 2006 08:19:15 +0000</pubDate>
		<dc:creator>Samuel Tardieu</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.rfc1149.net/blog/2006/02/10/prime-numbers-and-pell-equation/</guid>
		<description><![CDATA[<p>Before leaving for my vacation,here are two small Python libraries I wrote that may help you if you want to participate to Project Euler:</p>

primes.py: fast prime number generation and integer factorization
pell.py: find solutions pairs to Pell diophantine equation x2-Dy2=1

]]></description>
			<content:encoded><![CDATA[<p>Before leaving for my vacation,here are two small Python libraries I wrote that may help you if you want to participate to <a href="http://mathschallenge.net/index.php?section=project">Project Euler</a>:</p>
<ul>
<li><code><a href="/download/misc/primes.py">primes.py</a></code>: fast prime number generation and integer factorization</li>
<li><code><a href="/download/misc/pell.py">pell.py</a></code>: find solutions pairs to <a title="Pell equation (from MathWorld)" href="http://mathworld.wolfram.com/PellEquation.html">Pell diophantine equation</a> <em>x<sup>2</sup>-Dy<sup>2</sup>=1</em></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rfc1149.net/blog/2006/02/10/prime-numbers-and-pell-equation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting rid of RSS slammers</title>
		<link>http://www.rfc1149.net/blog/2005/10/12/getting-rid-of-rss-slammers/</link>
		<comments>http://www.rfc1149.net/blog/2005/10/12/getting-rid-of-rss-slammers/#comments</comments>
		<pubDate>Wed, 12 Oct 2005 14:39:26 +0000</pubDate>
		<dc:creator>Samuel Tardieu</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Free Software]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.rfc1149.net/blog/?p=63</guid>
		<description><![CDATA[<p>A few weeks ago, I noticed that some people were getting my RSS feed once every minute. The load on the WWW server was already high and I found a much cheaper solution on my side: redirect them to the <a href="http://www.rsscache.com/" title="RSScache">RSScache</a> service through an Apache redirection.</p>
<p>This morning, I read that Daniel Glazman [had the same [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago, I noticed that some people were getting my RSS feed once every minute. The load on the WWW server was already high and I found a much cheaper solution on my side: redirect them to the <a href="http://www.rsscache.com/" title="RSScache">RSScache</a> service through an Apache redirection.</p>
<p>This morning, I read that Daniel Glazman <a href="http://www.glazman.org/weblog/dotclear/index.php?2005/10/11/1298-painful-rss" title="had the same problem">had the same problem</a> and I suggested him (in a private email as he forbids comments on his blog) to do the same. After discussing a while, we thought it could be a good idea to automate the process.</p>
<p>I wrote a small Python script called <a href="http://www.rfc1149.net/download/rssabuse/rssabuse.py" title="rssabuse.py">rssabuse.py</a> which parses your web server access log, tries to detect the abusers for the previous day and rewrites part of your <code>.htaccess</code> so that abusers are redirected transparently to <a href="http://www.rsscache.com/" title="RSSCache">RSSCache</a>. Ok, they may get extra advertisments in the feed, so what? This is their problem, not yours. A HTTP redirection is much less costly than a full feed serving and they can still follow your blog activity. This should work with many blogs software (using WordPress or DotClear for example), provided that you can use Apache&#8217;s <code>mod_rewrite</code> in your <code>.htaccess.</p>
<p>The idea is to put something like that in your </code><code>.htaccess</code>:</p>
<pre>
RewriteEngine on
RewriteBase /blog
# rssabuse section
RewriteCond %{REMOTE_ADDR} 0.0.0.0  [replaced later by this script]
RewriteRule ^(feed.*)$ http://my.rsscache.com/www.rfc1149.net/blog/$1 [R,L]
</pre>
<p>and then, every night, shortly after midnight, you launch (through a crontab for example):</p>
<pre>
rssabuse.py /home/log/apache/access.log '^/blog/feed' 100 /home/sam/blog/.htaccess
</pre>
<p>(100 means 96 times a day plus a few hits to be on the safe side)</p>
<p>The script will count accesses to <code>^/blog/feed</code> as a regular expression and redirect the hosts (by name or address) abusing your feeds to <a href="http://www.rsscache.com/" title="RSScache">RSScache</a> by rewriting your <code>.htaccess</code> file. You should see your server load decrease as the abusers are kept away.</p>
<p>A note for the technical junkies: the script will try very hard to make the file update atomic so that no hit to your web server can see a partial or missing <code>.htaccess</code>.</p>
<p><a href="http://www.rfc1149.net/download/rssabuse/rssabuse.py" title="rssabuse.py">rssabuse.py</a> is made available under the GNU General Public License version 2.</p>
<ul>
<li><strong>Version 1.0:</strong> initial release</li>
<li><strong>Version 1.1:</strong> the list of abusers is available on standard output so that you can see that it is working</li>
<li><strong>Version 1.2:</strong> fix a bug in date computation and output more helpful statistics with the number of accesses that caused a host to be blocked</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rfc1149.net/blog/2005/10/12/getting-rid-of-rss-slammers/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>blenderdist</title>
		<link>http://www.rfc1149.net/blog/2005/08/21/blenderdist/</link>
		<comments>http://www.rfc1149.net/blog/2005/08/21/blenderdist/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>Samuel Tardieu</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Free Software]]></category>
		<category><![CDATA[Photo and imaging]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>When doing some heavy 3D rendering with Blender, I realized that one of my animation was going to take 53 hours to render. Existing distributed rendering systems such as DrQueue were fine but require that some software other than Blender or basic interpreters (such as Python or Perl) is installed on the contributing machines.</p>
<p>So I [...]]]></description>
			<content:encoded><![CDATA[<p>When doing some heavy 3D rendering with <a href="http://www.blender.org/">Blender</a>, I realized that one of my animation was going to take 53 hours to render. Existing distributed rendering systems such as <a href="http://www.drqueue.org/">DrQueue</a> were fine but require that some software other than Blender or basic interpreters (such as Python or Perl) is installed on the contributing machines.</p>
<p>So I wrote a simple Python script called <a href="http://www.rfc1149.net/mercurial/blenderdist">blenderdist.py</a> which only needs blender and python to run. A server is launched with:</p>
<p><code><br />
% python blenderdist.py --server PORT JOBDIR RENDERDIR<br />
</code></p>
<p>and will monitor the status of job files (three lines each, the blender file, the first frame to render and the last one to render) in JOBDIR. Resulting frames are placed under RENDERDIR/jobname. Job names have to end with .job and if a file named JOBNAME.job.suspend is present, its rendering is suspended to allow urgent jobs to be rendered first.</p>
<p>Clients are launched with:</p>
<p><code><br />
% python blenderdist.py --client HOST PORT<br />
</code></p>
<p>The server constantly monitors its source code. Whenever the Python script changes, the server relaunches itself (without loosing its state saved in a checkpoint file) and the next time the clients connect to it they will receive the new version of the program and relaunch themselves too.</p>
<p>I have currently a dozen machines working as I type, most of them out of my control. Some friends of mine have agreed to run the script and are contributing CPU cycles for my rendering. This proves to be <b>very helpful</b>. The program is much less powerful than generic ones such as DrQueue, but it does not require that disk space is shared between machines or setting up complex scripts. It just gets the job done.</p>
<p>Note: as this script has been written for a one-time shot need, I place it under the public domain, do whatever you want with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rfc1149.net/blog/2005/08/21/blenderdist/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
