<?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>Guy Rutenberg &#187; Projects</title>
	<atom:link href="http://www.guyrutenberg.com/category/projects/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guyrutenberg.com</link>
	<description>Keeping track of what I do</description>
	<lastBuildDate>Wed, 16 Jun 2010 19:53:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Audio Based True Random Number Generator POC</title>
		<link>http://www.guyrutenberg.com/2010/05/14/audio-based-true-random-number-generator-poc/</link>
		<comments>http://www.guyrutenberg.com/2010/05/14/audio-based-true-random-number-generator-poc/#comments</comments>
		<pubDate>Fri, 14 May 2010 12:18:14 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=678</guid>
		<description><![CDATA[Few days ago I came up with an idea to create a true random number generator based on noise gathered from a cheap microphone attached to my computer. Tests showed that when sampling the microphone, the least significant bit behaves pretty randomly. This lead me to think it might be good source for gathering entropy [...]]]></description>
			<content:encoded><![CDATA[<p>Few days ago I came up with an idea to create a true random number generator based on noise gathered from a cheap microphone attached to my computer. Tests showed that when sampling the microphone, the least significant bit behaves pretty randomly. This lead me to think it might be good source for gathering entropy for a true random number generator.<br />
<span id="more-678"></span><br />
The base design was to gather the noise from the microphone than apply a process that will make in more uniform and refine its randomness. After some design iterations I came up with a process based on applying a hash function to the noise. Each iteration involves filling block of the hash function from the least significant bits of the microphone output and applying the hash. Each iteration outputs the current hash digest. Assuming the hash function is uniform, this will output a uniformly distributed blocks of bits. Furthermore, because there the previous state of the hash function influences the next digest computation, the process accumulates entropy that can smooth out potentially less random blocks. Because for all commonly used hash function the block size is much larger than the digest size the output can tell much about the current state or any future or past state. This also holds true even if someone can find all pre-images of the hash function as the amount of possible states will be too big.</p>
<p>I&#8217;ve built a Python proof of concept (using md5 as a hash function) suitable for Linux.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> hashlib
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">struct</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> GRandom:
    <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>.<span style="color: black;">audio</span> = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/dev/dsp&quot;</span>,<span style="color: #483d8b;">&quot;rb&quot;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: #008000;">hash</span> = hashlib.<span style="color: #dc143c;">md5</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> get_raw_block<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        buffer = <span style="color: #008000;">self</span>.<span style="color: black;">audio</span>.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: #008000;">hash</span>.<span style="color: black;">block_size</span><span style="color: #66cc66;">*</span><span style="color: #ff4500;">8</span><span style="color: black;">&#41;</span>
        <span style="color: #dc143c;">bytes</span> = <span style="color: #dc143c;">struct</span>.<span style="color: black;">unpack</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%iB&quot;</span><span style="color: #66cc66;">%</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>buffer<span style="color: black;">&#41;</span>, buffer<span style="color: black;">&#41;</span>
&nbsp;
        longs = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: #008000;">hash</span>.<span style="color: black;">block_size</span>/<span style="color: #ff4500;">4</span><span style="color: black;">&#41;</span>:
            temp = <span style="color: #ff4500;">0</span>
            <span style="color: #ff7700;font-weight:bold;">for</span> b <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">bytes</span><span style="color: black;">&#91;</span>i<span style="color: #66cc66;">*</span><span style="color: #ff4500;">32</span>:<span style="color: black;">&#40;</span>i+<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #ff4500;">32</span><span style="color: black;">&#93;</span>:
                temp = <span style="color: black;">&#40;</span>temp <span style="color: #66cc66;">&lt;&lt;</span> <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span> ^ <span style="color: black;">&#40;</span>b <span style="color: #66cc66;">&amp;</span> <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
            longs.<span style="color: black;">append</span><span style="color: black;">&#40;</span>temp<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #dc143c;">struct</span>.<span style="color: black;">pack</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%iI&quot;</span><span style="color: #66cc66;">%</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>longs<span style="color: black;">&#41;</span>, <span style="color: #66cc66;">*</span>longs<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> get_block<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: #008000;">hash</span>.<span style="color: black;">update</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">get_raw_block</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: #008000;">hash</span>.<span style="color: black;">digest</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>The amount of generated bits per second is given by (sample rate)*(digest size)/(block size). So for 8KHz (default) sampling rate and md5 we&#8217;ll get a theoretical speed of ~250Kbs. SHA type hashes have higher digest to block size ration thus may result in higher speeds. Another source of speed up may be to change the sample rate of the microphone. But setting it to high may have negative effects on the entropy. The code may get a considerable performance gain by porting it to c/c++, as it uses both bit manipulations and calculates hashes. Anyways, even the Python implementation&#8217;s speed allows us it be used for many cases where true randomness is required, such as generating passwords.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2010/05/14/audio-based-true-random-number-generator-poc/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hash Puppy 0.2</title>
		<link>http://www.guyrutenberg.com/2010/03/31/hash-puppy-0-2/</link>
		<comments>http://www.guyrutenberg.com/2010/03/31/hash-puppy-0-2/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 21:15:06 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Hash Puppy]]></category>
		<category><![CDATA[QT]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=656</guid>
		<description><![CDATA[This is an update for my simple easy-to-use checksum calculator. It supports md4, md5, and sha1 hash functions. I wrote the project as a way to experience and learn Qt.

Changes since the previous version (Hash Puppy 0.1) include ability to abort a checksum calculation and improved GUI responsiveness. Also there were other minor tweaks to [...]]]></description>
			<content:encoded><![CDATA[<p>This is an update for my simple easy-to-use checksum calculator. It supports md4, md5, and sha1 hash functions. I wrote the project as a way to experience and learn Qt.<br />
<img src="http://www.guyrutenberg.com/wp-content/uploads/2010/03/hashpuppy-0.2.png" alt="" title="hashpuppy-0.2" width="565" height="205" class="aligncenter size-full wp-image-661" /><br />
Changes since the previous version (<a href="/2009/05/29/hash-puppy-a-qt-checksum-calculator/">Hash Puppy 0.1</a>) include ability to abort a checksum calculation and improved GUI responsiveness. Also there were other minor tweaks to make Hash Puppy easier to use.<br />
<span id="more-656"></span><br />
The software is available under the GPL license.<br />
Source code: <a href="/wp-content/uploads/2010/03/hashpuppy-0.2.tar.gz">hashpuppy-0.2.tar.gz</a><br />
Binary for Windows: <a href="/wp-content/uploads/2010/03/hashpuppy-0.2.zip">hashpuppy-0.2.zip</a> (Compiled against Qt 4.6.2).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2010/03/31/hash-puppy-0-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improved FTP Backup for WordPress</title>
		<link>http://www.guyrutenberg.com/2010/02/28/improved-ftp-backup-for-wordpress/</link>
		<comments>http://www.guyrutenberg.com/2010/02/28/improved-ftp-backup-for-wordpress/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 06:38:44 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[backup]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=637</guid>
		<description><![CDATA[This script backups both the database and files of a WordPress blog into a remote FTP server (while keeping a local copy). It&#8217;s an update of my WordPress Backup to FTP script. The main changes are auto-detecting database settings and better support for caching plugins (specifically WP-Cache). The new version makes it easier to backup [...]]]></description>
			<content:encoded><![CDATA[<p>This script backups both the database and files of a WordPress blog into a remote FTP server (while keeping a local copy). It&#8217;s an update of my <a href="/2009/01/06/wordpress-backup-to-ftp/">WordPress Backup to FTP</a> script. The main changes are auto-detecting database settings and better support for caching plugins (specifically WP-Cache). The new version makes it easier to backup multiple WordPress blogs to the same FTP server.<br />
<span id="more-637"></span><br />
Usage is pretty simple after a short initial configuration. First, save the the script and make it executable:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> +x wp-backup</pre></div></div>

<p>(assuming you saved it under the name <code>wp-backup</code>). After saving it edit the file with your favorite editor and set the 5 configuration variable to whatever is appropriate for you. <code>BACKUP_DIR</code> is the folder to save the local backups to. <code>FTP_HOST</code>, <code>FTP_USER</code>, <code>FTP_PASS</code> control the FTP host, username and password, respectively, for the remote backup server. <code>FTP_BACKUP_DIR</code> sets the folder on the FTP server to save the remote backup to.</p>
<p>Now that the initial configuration is done, all you need to do is execute the script and give the path to the blog as an argument. For example:</p>

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

<p>And that it, the script will backup your files (excluding cache) and database to both a local and remote locations. This allows using the same script to backup multiple WordPress blogs, unlike the previous script which had to be modified for each blog.</p>
<p>And now the script itself:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Copyright 2008, 2010 Guy Rutenberg &lt;http://www.guyrutenberg.com/contact-me&gt;</span>
<span style="color: #666666; font-style: italic;"># WordPress FTP backup 2.0</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Easily backup wordpress instances via ftp.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Change Log:</span>
<span style="color: #666666; font-style: italic;"># ===========</span>
<span style="color: #666666; font-style: italic;"># 2.0:</span>
<span style="color: #666666; font-style: italic;">#  - Auto-detect database settings.</span>
<span style="color: #666666; font-style: italic;">#  - Exclude cache data from backups.</span>
&nbsp;
<span style="color: #007800;">BACKUP_DIR</span>=
<span style="color: #007800;">FTP_HOST</span>=
<span style="color: #007800;">FTP_USER</span>=
<span style="color: #007800;">FTP_PASS</span>=
<span style="color: #007800;">FTP_BACKUP_DIR</span>=
&nbsp;
<span style="color: #666666; font-style: italic;"># end of configuration - you probably don't need to touch anything bellow</span>
&nbsp;
<span style="color: #007800;">PROG</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #ff0000;">&quot;$0&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
print_usage <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;USAGE: <span style="color: #007800;">${PROG}</span> [options] BLOG_ROOT&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Backup a WordPress blog&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
print_help <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    print_usage
    <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #cc0000; font-style: italic;">&lt;&lt; EOF
&nbsp;
Options:
    -h, --help          show this help message and exit
&nbsp;
EOF</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #007800;">TEMP</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">getopt</span> <span style="color: #660033;">-o</span> h <span style="color: #660033;">--long</span> <span style="color: #7a0874; font-weight: bold;">help</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$PROG</span>&quot;</span> <span style="color: #660033;">--</span> <span style="color: #ff0000;">&quot;$@&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$?</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    print_usage
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">--</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TEMP</span>&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">true</span> ; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
        -h<span style="color: #000000; font-weight: bold;">|</span>--help<span style="color: #7a0874; font-weight: bold;">&#41;</span> print_help; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000; font-weight: bold;">;;</span>
        --<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">shift</span>; <span style="color: #7a0874; font-weight: bold;">break</span><span style="color: #000000; font-weight: bold;">;;</span>
    <span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
 print_usage <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>stderr
 <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">BLOG_DIR</span>=$<span style="color: #000000;">1</span>
<span style="color: #007800;">DB_NAME</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&lt;?php require_once(<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${BLOG_DIR}</span>/wp-config.php<span style="color: #000099; font-weight: bold;">\&quot;</span>); echo DB_NAME;&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> php<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">DB_USER</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&lt;?php require_once(<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${BLOG_DIR}</span>/wp-config.php<span style="color: #000099; font-weight: bold;">\&quot;</span>); echo DB_USER;&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> php<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">DB_PASS</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&lt;?php require_once(<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${BLOG_DIR}</span>/wp-config.php<span style="color: #000099; font-weight: bold;">\&quot;</span>); echo DB_PASSWORD;&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> php<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">DB_HOST</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&lt;?php require_once(<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${BLOG_DIR}</span>/wp-config.php<span style="color: #000099; font-weight: bold;">\&quot;</span>); echo DB_HOST;&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> php<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #007800;">BLOG_DIR</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dirname</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BLOG_DIR</span>&quot;</span><span style="color: #000000; font-weight: bold;">`/`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BLOG_DIR</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">BACKUP_DIR</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dirname</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUP_DIR</span>&quot;</span><span style="color: #000000; font-weight: bold;">`/`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUP_DIR</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;dumping database... &quot;</span>
<span style="color: #007800;">DUMP_NAME</span>=<span style="color: #800000;">${DB_NAME}</span>-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>d<span style="color: #7a0874; font-weight: bold;">&#41;</span>.sql.bz2
mysqldump <span style="color: #660033;">--user</span>=<span style="color: #800000;">${DB_USER}</span> <span style="color: #660033;">--password</span>=<span style="color: #800000;">${DB_PASS}</span> <span style="color: #660033;">--host</span>=<span style="color: #800000;">${DB_HOST}</span> \
 <span style="color: #660033;">--databases</span> <span style="color: #800000;">${DB_NAME}</span> \
 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bzip2</span> <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #800000;">${BACKUP_DIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${DUMP_NAME}</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$?&quot;</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;failed!&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Creating tarball... &quot;</span>
<span style="color: #007800;">TAR_NAME</span>=<span style="color: #800000;">${BLOG_DIR##*/}</span>-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>d<span style="color: #7a0874; font-weight: bold;">&#41;</span>.tar.bz2
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-cjf</span> <span style="color: #800000;">${BACKUP_DIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${BLOG_DIR##*/}</span>-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>d<span style="color: #7a0874; font-weight: bold;">&#41;</span>.tar.bz2 <span style="color: #660033;">--exclude</span> cache <span style="color: #800000;">${BLOG_DIR}</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$?&quot;</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;failed!&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Uploading SQL dump and tarball to FTP... &quot;</span>
lftp <span style="color: #660033;">-u</span> <span style="color: #800000;">${FTP_USER}</span>,<span style="color: #800000;">${FTP_PASS}</span> <span style="color: #800000;">${FTP_HOST}</span> <span style="color: #cc0000; font-style: italic;">&lt;&lt;EOF
cd &quot;${FTP_BACKUP_DIR}&quot;
put &quot;${BACKUP_DIR}/${DUMP_NAME}&quot;
put &quot;${BACKUP_DIR}/${TAR_NAME}&quot;
&nbsp;
EOF</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$?&quot;</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;failed!&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">3</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2010/02/28/improved-ftp-backup-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>An Early Release of the New cssrtl.py-2.0</title>
		<link>http://www.guyrutenberg.com/2009/09/20/an-early-release-of-the-new-cssrtl-py-2-0/</link>
		<comments>http://www.guyrutenberg.com/2009/09/20/an-early-release-of-the-new-cssrtl-py-2-0/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 10:00:50 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[cssrtl.py]]></category>
		<category><![CDATA[RTL]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=578</guid>
		<description><![CDATA[It has been three years since I&#8217;ve released the ]]></description>
			<content:encoded><![CDATA[<p>It has been three years since I&#8217;ve released the <a href=/2007/12/28/convert-css-layout-to-rtl-cssrtlpy/">original version</a> of <code>cssrtl.py</code> (and two since it&#8217;s re-release). The old version did a nice job, but experience gained during that time led me to write from scratch a new version. I&#8217;ve detailed more than a month ago, the <a href="/2009/08/05/designing-a-better-a-css-rtl-convertor/">basic principles and ideas</a> that guided me to design a better tool to help adapting CSS files from left-to-right to right-to-left.</p>
<p>The guidelines weren&#8217;t just empty words, they were written while working on the <a href="/2009/08/15/rtl-and-hebrew-adaptation-of-the-fusion-wordpress-theme/">Hebrew adaptation to the Fusion theme</a> and in the same time writing a new proof-of-concept version of <code>cssrtl.py</code>. The original intent was to release a more mature version of that code when it will be completed. However, due to the apparent shortage of time in the present and foreseeable future, I can&#8217;t see myself complete the project any time soon. So following the &#8220;release early&#8221; mantra, I&#8217;ve decided to release the code as-is. As I said, the code is in working state, but not polished, so it may be of benefit but may contain bugs. If you find any bugs or have any suggestions, I would be glad to hear.<br />
<span id="more-578"></span></p>
<h3>Download</h3>
<p>You can download the new version from here: <a href="/wp-content/uploads/2009/09/cssrtl.py-2.0.tar.bz2">cssrtl.py-2.0.tar.bz2</a>. The code is available under the GPLv2 or any later version.</p>
<h3>Usage</h3>
<p>The new version works by creating a seperate css &#8220;fix&#8221; file that fixes the directionality of the css styles.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">./cssrtl.py &lt; main.css &gt; main-rtl.css</pre></div></div>

<p>Afterward, just link the <code>main-rtl.css</code> after <code>main.css</code> in your HTML files.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2009/09/20/an-early-release-of-the-new-cssrtl-py-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple AI Engine for the Oware Game</title>
		<link>http://www.guyrutenberg.com/2009/08/19/simple-ai-engine-for-the-oware-game/</link>
		<comments>http://www.guyrutenberg.com/2009/08/19/simple-ai-engine-for-the-oware-game/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 10:54:28 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[oware]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=568</guid>
		<description><![CDATA[Sometime ago I worked with a friend on building an Oware game. I was supposed to build the AI engine, and he was supposed to build the user interface to it. Unfortunately, while AI engine interface I designed and a simple alpha-beta pruning engine was implemented, the project was never completed.

Instead of letting the project [...]]]></description>
			<content:encoded><![CDATA[<p>Sometime ago I worked with a friend on building an <a href="http://en.wikipedia.org/wiki/Oware">Oware</a> <a href="http://www.wikimanqala.org/wiki/Oware">game</a>. I was supposed to build the AI engine, and he was supposed to build the user interface to it. Unfortunately, while AI engine interface I designed and a simple alpha-beta pruning engine was implemented, the project was never completed.</p>
<div id="attachment_569" class="wp-caption alignnone" style="width: 672px"><img src="http://www.guyrutenberg.com/wp-content/uploads/2009/08/oware-screenshot.png" alt="Screenshot of game session" title="oware-screenshot" width="662" height="412" class="size-full wp-image-569" /><p class="wp-caption-text">Screenshot of game session</p></div>
<p><span id="more-568"></span><br />
Instead of letting the project just sit and wait until it will be redeemed and completed I&#8217;ve decided to release my code. It consists of a simple terminal user-interface and an AI opponent. Compiling is straight forward and doesn&#8217;t require any special libraries. You can obtain the code from here: <a href="/wp-content/uploads/2009/09/oware-0.1.tar.bz2">oware-0.1.tar.bz2</a> [15.1 KB].</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">tar xvf ./oware-0.1.tar.bz2
cd oware
g++ main.cpp ai/basic_ai_engine.cpp -o oware</pre></div></div>

<p>Running the program is pretty simple, just type <code>./oware</code>. You will be prompted to select the level of the AI opponent. The higher the number the slower and better the opponent will play. I suggest starting pretty low, and climbing up untill you find it challenging. The houses (holes) are numbered from 0 to 11 starting with the bottom left hole (yours) and going counter-clockwise. </p>
<p>The game is licensed under the GPLv2 or any latter version, so fill free to hack and improve the game if you have time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2009/08/19/simple-ai-engine-for-the-oware-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Designing a Better a CSS RTL Convertor</title>
		<link>http://www.guyrutenberg.com/2009/08/05/designing-a-better-a-css-rtl-convertor/</link>
		<comments>http://www.guyrutenberg.com/2009/08/05/designing-a-better-a-css-rtl-convertor/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 09:41:15 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[cssrtl.py]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=418</guid>
		<description><![CDATA[About a year and a half ago I&#8217;ve released cssrtl.py, a script that translates CSS code to RTL. The script was designed to be fully autonomous, however translating CSS code is a complex task, as not all the information needed to make the translation is available in the CSS files. While cssrtl.py did a very [...]]]></description>
			<content:encoded><![CDATA[<p>About a year and a half ago I&#8217;ve released <a href="/2007/12/28/convert-css-layout-to-rtl-cssrtlpy/"><code>cssrtl.py</a>, a script that translates CSS code to RTL. The script was designed to be fully autonomous, however translating CSS code is a complex task, as not all the information needed to make the translation is available in the CSS files. While <code>cssrtl.py</code> did a very good job on some tasks it lacks on several issues:</p>
<ol>
<li>When a design update is released, one cannot use previous translation work.</li>
<li>When things don't go smooth, it's hard to find out why.</li>
<li>Complex CSS can't be translated automatically, as it requires understanding of the structure of the corresponding html files and how the CSS will be used by future code.</li>
</ol>
<p><span id="more-418"></span><br />
There are two basic ideas behind building a new and improved replacement for <code>cssrtl.py</code>. The first, instead of translating the CSS file, the script will create a patch that translates the code. This would allow to see the changes required for RTL changes and easily adapt new version of the CSS code. This also solves the second problem, as it makes clear what changes where made by the script and what are part of the original code. The other change takes the script from trying to be autonomous to human guided translation. Instead of making all the changes completely by itself, the script only makes trivial changes (which are most changes) and clearly leaves comments guiding the human operator on what work remained to be done. This approach saves a lot of time as the script works only does what it can and doesn't hinder the translation efforts by trying to translate code that it can't translate properly.</p>
<p>Following this new design for CSS to RTL convertor, I've built a new version of <code>cssrtl.py</code>. The new version is still premature work, and some work needs to be done before I'll be able to release it publicly. However, it already revealed itself handy when I adapted a WordPress theme to Hebrew, which I intend to release soon.</p>
<p><strong>Update 2009-08-15:</strong> I've released the mentioned WordPress theme, it's <a href="/2009/08/15/rtl-and-hebrew-adaptation-of-the-fusion-wordpress-theme/">RTL port of the Fusion theme</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2009/08/05/designing-a-better-a-css-rtl-convertor/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hash Puppy &#8211; A Qt Checksum Calculator</title>
		<link>http://www.guyrutenberg.com/2009/05/29/hash-puppy-a-qt-checksum-calculator/</link>
		<comments>http://www.guyrutenberg.com/2009/05/29/hash-puppy-a-qt-checksum-calculator/#comments</comments>
		<pubDate>Fri, 29 May 2009 10:56:03 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Hash Puppy]]></category>
		<category><![CDATA[QT]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=365</guid>
		<description><![CDATA[I&#8217;ve decided to give Qt a try after long time of wxWidgets programming. When I learn to a new language or how to use a new library I always like to build some small projects to get my hands dirty with. This time I&#8217;ve built small checksum calculator &#8211; Hash Puppy (in fact, first I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve decided to give Qt a try after long time of wxWidgets programming. When I learn to a new language or how to use a new library I always like to build some small projects to get my hands dirty with. This time I&#8217;ve built small checksum calculator &#8211; Hash Puppy (in fact, first I had the name then I&#8217;ve decided I must use it for some new project). </p>
<p><img src="http://www.guyrutenberg.com/wp-content/uploads/2009/05/hashpuppy.png" alt="hashpuppy" title="hashpuppy" width="518" height="211" class="aligncenter size-full wp-image-366" /><br />
<span id="more-365"></span><br />
As a checksum calculator Hash Puppy is pretty simple, as it supports only MD4, MD5 and SHA1. It also supports basic Drag and Drop and clipboard interaction. The source code for Hash Puppy is released under the GPL and available from here: <a href="/wp-content/uploads/2009/05/hashpuppy-0.1.tar.bz2">hashpuppy-0.1.tar.bz2</a>.</p>
<p>While the wxWidgets vs Qt story should be part of another post, I can note that programming Qt was fun. While first I was dismayed by the use of non-standard C++ syntax for the Signal-Slot mechanism, I really liked the otherwise clean and modern C++ syntax used by Qt. The Qt Designer is a great utility, and really makes the tedious work of making the UI easy. I liked that Qt Designer encourages the user to inherit the dialog classed he designs in order to add functionality, over the approach used in <a href="http://wxglade.sourceforge.net/">wxGlade</a> which is based on editing the code the program generates. Unfortunately, I don&#8217;t have enough time to pursue such change in wxGlade. </p>
<p><strong>Update</strong> 11/12/2009: Fixed the download link.<br />
<strong>Update</strong> 31/3/2010: A new version is available: <a href="/2010/03/31/hash-puppy-0-2/">Hash Puppy 0.2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2009/05/29/hash-puppy-a-qt-checksum-calculator/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>tarsum-0.2 &#8211; A read only version of tarsum</title>
		<link>http://www.guyrutenberg.com/2009/04/29/tarsum-02-a-read-only-version-of-tarsum/</link>
		<comments>http://www.guyrutenberg.com/2009/04/29/tarsum-02-a-read-only-version-of-tarsum/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 06:58:31 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[tarsum]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=315</guid>
		<description><![CDATA[When I first scratched the itch of calculating checksums for every file in a tar archive, this was my original intention. When I decided I want the script in bash for simplicity, I forfeited the idea and settled for extracting the files and then going over all the files to calculate their checksum value.
So when [...]]]></description>
			<content:encoded><![CDATA[<p>When I first scratched the itch of calculating checksums for every file in a tar archive, this was my original intention. When I decided I want the script in bash for simplicity, I forfeited the idea and settled for extracting the files and then going over all the files to calculate their checksum value.</p>
<p>So when <a href="/2008/10/24/tarsum-calculate-checksum-for-files-inside-tar-archive/#comment-19087">Jon Flowers asked</a> in the comments of the original <a href="/2008/10/24/tarsum-calculate-checksum-for-files-inside-tar-archive/"><code>tarsum</code> post</a> about the possibility of getting the checksums of files in the tar file without extracting all the archive, I&#8217;ve decided to re-tackle the problem.</p>
<p><span id="more-315"></span></p>
<p>This time I&#8217;ve chose python and by using the <code>tarfile</code> and <code>hashlib</code> modules I came up with a solution that allowed me to go over tar files to calculate the checksum values without extracting all of them to the disk. However some sacrifices where made in the form of back-compatibility of the output. I&#8217;ve tried to make the interface similar to the old one, and have kept all the command line options. Instead of specifying a program name to calculate the checksum values (such as <code>sha1sum</code>) as argument to <code>--checksum</code> you specify the name of the checksum algorithm such as md5, sha1, sha256, sha512 (or any other supported by <code>hashlib</code>).</p>
<p>Other changes where made so tar files can be piped directly into <code>tarsum</code> (which also works transparently with bzip2 and gzip compression).</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">tarsum &lt; sometarfile.tar.gz &gt; sometarfile.tar.gz.md5</pre></div></div>

<p>Performance-wise, according to some tests I&#8217;ve carried out, the new version is faster with big tar files than the old one, but it&#8217;s the other way around with small archives (which I find less important).</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#! /usr/bin/env python</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Copyright (C) 2008-2009 by Guy Rutenberg</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># This program is free software; you can redistribute it and/or modify</span>
<span style="color: #808080; font-style: italic;"># it under the terms of the GNU General Public License as published by</span>
<span style="color: #808080; font-style: italic;"># the Free Software Foundation; either version 2 of the License, or</span>
<span style="color: #808080; font-style: italic;"># (at your option) any later version.</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># This program is distributed in the hope that it will be useful,</span>
<span style="color: #808080; font-style: italic;"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span style="color: #808080; font-style: italic;"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span style="color: #808080; font-style: italic;"># GNU General Public License for more details.</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># You should have received a copy of the GNU General Public License</span>
<span style="color: #808080; font-style: italic;"># along with this program; if not, write to the</span>
<span style="color: #808080; font-style: italic;"># Free Software Foundation, Inc.,</span>
<span style="color: #808080; font-style: italic;"># 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> hashlib
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">tarfile</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> tarsum<span style="color: black;">&#40;</span>input_file, <span style="color: #008000;">hash</span>, output_file<span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;&quot;
        input_file  - A FILE object to read the tar file from.
        hash - The name of the hash to use. Must be supported by hashlib.
        output_file - A FILE to write the computed signatures to.
        &quot;&quot;&quot;</span>
        tar = <span style="color: #dc143c;">tarfile</span>.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span>mode=<span style="color: #483d8b;">&quot;r|*&quot;</span>, fileobj=input_file<span style="color: black;">&#41;</span>
&nbsp;
        chunk_size = <span style="color: #ff4500;">100</span><span style="color: #66cc66;">*</span><span style="color: #ff4500;">1024</span>
        store_digests = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">for</span> member <span style="color: #ff7700;font-weight:bold;">in</span> tar:
            <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> member.<span style="color: black;">isfile</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">continue</span>
            f = tar.<span style="color: black;">extractfile</span><span style="color: black;">&#40;</span>member<span style="color: black;">&#41;</span>
            h = hashlib.<span style="color: #dc143c;">new</span><span style="color: black;">&#40;</span><span style="color: #008000;">hash</span><span style="color: black;">&#41;</span>
            data = f.<span style="color: black;">read</span><span style="color: black;">&#40;</span>chunk_size<span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">while</span> data:
                h.<span style="color: black;">update</span><span style="color: black;">&#40;</span>data<span style="color: black;">&#41;</span>
                data = f.<span style="color: black;">read</span><span style="color: black;">&#40;</span>chunk_size<span style="color: black;">&#41;</span>
            output_file.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s  %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>h.<span style="color: black;">hexdigest</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, member.<span style="color: black;">name</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #dc143c;">parser</span> = OptionParser<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    version=<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%prog 0.2.1<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
             <span style="color: #483d8b;">&quot;Copyright (C) 2008-2009 Guy Rutenberg &lt;http://www.guyrutenberg.com/contact-me&gt;&quot;</span><span style="color: black;">&#41;</span>
    usage=<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%prog [options] TARFILE<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
           <span style="color: #483d8b;">&quot;Print a checksum signature for every file in TARFILE.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
           <span style="color: #483d8b;">&quot;With no FILE, or when FILE is -, read standard input.&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #dc143c;">parser</span> = OptionParser<span style="color: black;">&#40;</span>usage=usage, version=version<span style="color: black;">&#41;</span>
    <span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;-c&quot;</span>, <span style="color: #483d8b;">&quot;--checksum&quot;</span>, dest=<span style="color: #483d8b;">&quot;checksum&quot;</span>, <span style="color: #008000;">type</span>=<span style="color: #483d8b;">&quot;string&quot;</span>,
        <span style="color: #008000;">help</span>=<span style="color: #483d8b;">&quot;use HASH as for caclculating the checksums. [default: %default]&quot;</span>, metavar=<span style="color: #483d8b;">&quot;HASH&quot;</span>,
        default=<span style="color: #483d8b;">&quot;md5&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;-o&quot;</span>, <span style="color: #483d8b;">&quot;--output&quot;</span>, dest=<span style="color: #483d8b;">&quot;output&quot;</span>, <span style="color: #008000;">type</span>=<span style="color: #483d8b;">&quot;string&quot;</span>,
        <span style="color: #008000;">help</span>=<span style="color: #483d8b;">&quot;save signatures to FILE.&quot;</span>, metavar=<span style="color: #483d8b;">&quot;FILE&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: black;">&#40;</span>option, args<span style="color: black;">&#41;</span> = <span style="color: #dc143c;">parser</span>.<span style="color: black;">parse_args</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    output_file = <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> option.<span style="color: black;">output</span>:
        output_file = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>option.<span style="color: black;">output</span>, <span style="color: #483d8b;">&quot;w&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
    input_file = <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdin</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>args<span style="color: black;">&#41;</span>==<span style="color: #ff4500;">1</span> <span style="color: #ff7700;font-weight:bold;">and</span> args<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">!</span>=<span style="color: #483d8b;">&quot;-&quot;</span>:
        input_file = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>args<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, <span style="color: #483d8b;">&quot;r&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
    tarsum<span style="color: black;">&#40;</span>input_file, option.<span style="color: black;">checksum</span>, output_file<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    <span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">optparse</span> <span style="color: #ff7700;font-weight:bold;">import</span> OptionParser
    <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
    main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># vim: ai ts=4 sts=4 et sw=4</span></pre></div></div>

<p>You can get a wget&#8217;able version here: <a href="/wp-content/uploads/2009/04/tarsum-0.2.bz2">tarsum-0.2.bz2</a>.</p>
<p><strong>Update 2009-08-12:</strong> Removed excess argument to <code>tarsum()</code> and switched the <code>filemode</code> to <code>r|*</code> (from <code>r:*</code>). Bumped version string.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2009/04/29/tarsum-02-a-read-only-version-of-tarsum/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Italian Radio Stations List for Radio.py</title>
		<link>http://www.guyrutenberg.com/2009/03/25/italian-radio-stations-list-for-radiopy/</link>
		<comments>http://www.guyrutenberg.com/2009/03/25/italian-radio-stations-list-for-radiopy/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 09:21:46 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[radio.py]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=291</guid>
		<description><![CDATA[Fabio, an Italian user of radio.py, wrote to me the other day with couple of suggestions and a huge radio.py configuration file with 150 Italian radio stations.
According to Fabio, the list contains 40 of the most popular Italian radio stations, along with radio station from where he used to live in north Italy.
In his post, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://podcastoro.blogspot.com/">Fabio</a>, an Italian user of <a href="/radiopy">radio.py</a>, wrote to me the other day with couple of suggestions and a huge <a href="http://podcastoro.blogspot.com/2009/03/radiopy.html">radio.py configuration file with 150 Italian radio stations</a>.</p>
<p>According to Fabio, the list contains 40 of the most popular Italian radio stations, along with radio station from where he used to live in north Italy.</p>
<p>In his post, Fabio also describes a useful tip he uses. He used the radio.py configuration file to number his favorite stations, thus allowing him even easier way to listen to them. E.g.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">radio.py 1
radio.py 3</pre></div></div>

<p>Previously, <a href="http://henrikan.wordpress.com/">Henrikan</a> compiled a <a href="http://henrikan.wordpress.com/2008/08/02/spela-och-spela-in-internetradio-fran-terminalen/"><code>.radiopy</code> file containing some 58 Swedish radio stations</a>.</p>
<p>If your a radio.py reader and you&#8217;ve compiles a <code>.radiopy</code> file you would like to share, send a link along with short description and I&#8217;ll gladly publish it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2009/03/25/italian-radio-stations-list-for-radiopy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>InfiniteTTT 0.6 Released</title>
		<link>http://www.guyrutenberg.com/2008/11/22/infinitettt-06-released/</link>
		<comments>http://www.guyrutenberg.com/2008/11/22/infinitettt-06-released/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 08:55:53 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[InfiniteTTT]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=166</guid>
		<description><![CDATA[InfiniteTTT 0.6 was released today. The main change in the new version is that the game is now multi-threaded.
InfiniteTTT is a variation of Tic-Tac-Toe which is played on an infinite board.
The new version has new multi-threaded AI engine, and several minor fixes and improvements. The changes improved the user experience and made the game more [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/infinitettt">InfiniteTTT</a> 0.6 was released today. The main change in the new version is that the game is now multi-threaded.</p>
<p><a href="/infinitettt">InfiniteTTT</a> is a variation of Tic-Tac-Toe which is played on an infinite board.</p>
<p>The new version has new multi-threaded AI engine, and several minor fixes and improvements. The changes improved the user experience and made the game more responsive. The new release contains binaries for Windows, source package and a Gentoo ebuild. Packages for other Linux distributions will follow soon (help will be appreciated).</p>
<p>To download the new version visit <a href="http://www.guyrutenberg.com/infinitettt/#download">InfiniteTTT&#8217;s download</a> page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2008/11/22/infinitettt-06-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.997 seconds -->
