<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Almost Working Code</title>
	<atom:link href="http://almostworkingcode.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://almostworkingcode.wordpress.com</link>
	<description></description>
	<lastBuildDate>Sun, 08 Jan 2012 19:25:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='almostworkingcode.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Almost Working Code</title>
		<link>http://almostworkingcode.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://almostworkingcode.wordpress.com/osd.xml" title="Almost Working Code" />
	<atom:link rel='hub' href='http://almostworkingcode.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Lolipower downloads in HD</title>
		<link>http://almostworkingcode.wordpress.com/2012/01/08/lolipower-downloads-in-hd/</link>
		<comments>http://almostworkingcode.wordpress.com/2012/01/08/lolipower-downloads-in-hd/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 18:49:16 +0000</pubDate>
		<dc:creator>Dario Meloni</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[anime]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[lolipower]]></category>

		<guid isPermaLink="false">http://almostworkingcode.wordpress.com/?p=177</guid>
		<description><![CDATA[I wanted to see a new anime and then I checked out my old lolipower script&#8230; just to find out that it there is more then one episode it will just download the first one! without even looking at the quality of the episode!! So i put up my perl hat and added the feature [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=177&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wanted to see a new anime and then I checked out my old lolipower script&#8230; just to find out that it there is more then one episode it will just download the first one! without even looking at the quality of the episode!!</p>
<p>So i put up my perl hat and added the feature to search for the next same-numbered episode with the highest definition (it should be possible to set thresold, but i don&#8217;t need them at the moment) as well as some fixes and readability code refactoring</p>
<p>the code is always in the same spot that can be read from the previous post <a href="http://almostworkingcode.wordpress.com/2009/12/06/new-lolipower-download-script" title="New lolipower download script">New lolipower download script</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/almostworkingcode.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/almostworkingcode.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/almostworkingcode.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/almostworkingcode.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/almostworkingcode.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/almostworkingcode.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/almostworkingcode.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/almostworkingcode.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/almostworkingcode.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/almostworkingcode.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/almostworkingcode.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/almostworkingcode.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/almostworkingcode.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/almostworkingcode.wordpress.com/177/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=177&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://almostworkingcode.wordpress.com/2012/01/08/lolipower-downloads-in-hd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a502a5d4f53ebb6f02a96e174332d60?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mellon</media:title>
		</media:content>
	</item>
		<item>
		<title>Postfix Admin with domain quotas</title>
		<link>http://almostworkingcode.wordpress.com/2011/03/30/postfix-admin-with-domain-quotas/</link>
		<comments>http://almostworkingcode.wordpress.com/2011/03/30/postfix-admin-with-domain-quotas/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 09:10:23 +0000</pubDate>
		<dc:creator>Dario Meloni</dc:creator>
				<category><![CDATA[Posts]]></category>

		<guid isPermaLink="false">http://almostworkingcode.wordpress.com/?p=161</guid>
		<description><![CDATA[Recently I adapted a patch which i found (I&#8217;m sorry original author, I can&#8217;t find which was the source&#8230;) somewhere on the internet, and ported it to Postfix Admin to the latest stable version 2.3.2 to change the behaviour of the quotas. The default consists on setting the maximum quota a user in the domain [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=161&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently I adapted a patch which i found (I&#8217;m sorry original author, I can&#8217;t find which was the source&#8230;) somewhere on the internet, and ported it to Postfix Admin to the latest stable version 2.3.2 to change the behaviour of the quotas.<br />
The default consists on setting the maximum quota a user in the domain may have, but what I needed is a maximum quota that the domain could use, which is slightly different but more useful from my point of view.</p>
<p>I have posted it in <a href="http://pastebin.com/4F996zQ9">pastebin</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/almostworkingcode.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/almostworkingcode.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/almostworkingcode.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/almostworkingcode.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/almostworkingcode.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/almostworkingcode.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/almostworkingcode.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/almostworkingcode.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/almostworkingcode.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/almostworkingcode.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/almostworkingcode.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/almostworkingcode.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/almostworkingcode.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/almostworkingcode.wordpress.com/161/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=161&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://almostworkingcode.wordpress.com/2011/03/30/postfix-admin-with-domain-quotas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a502a5d4f53ebb6f02a96e174332d60?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mellon</media:title>
		</media:content>
	</item>
		<item>
		<title>Concat videos with srt subtitle</title>
		<link>http://almostworkingcode.wordpress.com/2010/09/19/concat-movies-with-srt-subtitle/</link>
		<comments>http://almostworkingcode.wordpress.com/2010/09/19/concat-movies-with-srt-subtitle/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 16:40:51 +0000</pubDate>
		<dc:creator>Dario Meloni</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[Script]]></category>

		<guid isPermaLink="false">http://almostworkingcode.wordpress.com/?p=145</guid>
		<description><![CDATA[As lately I am encountering a lot of split video files with .srt subtitle i just wrote a simple script that will concat the subtitles with the correct timing shift. It just requires mencoder and mplayer installed to do the concatenation operation. The script does not support mkv files as they have embedded subtitles and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=145&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As lately I am encountering a lot of split video files with .srt subtitle i just wrote a simple script that will concat the subtitles with the correct timing shift.<br />
It just requires mencoder and mplayer installed to do the concatenation operation. The script does not support mkv files as they have embedded subtitles and it needs some mkv toll operation, but usually mkv files are not senslessly splitted anyway</p>
<p>All the code can be found on <a href="https://github.com/mellon85/concat-movie">github</a></p>
<p>Usage is really simple.<br />
If you have file1.avi file2.avi file1.srt file2.srt just do:<br />
<code><br />
perl concat-movie.pl file1.avi file2.avi output.avi<br />
</code><br />
and you&#8217;ll have output.avi and output.srt ready to be used, or even:<br />
<code><br />
perl concat-movie.pl file1.avi file2.avi output.mp4<br />
</code><br />
and the output will use .mp4 as container (check mplayer manuals for the formats)<br />
Here is the script.</p>
<pre>#!/usr/bin/perl
use strict;
use warnings;
use Carp;

sub add_time($);
sub shift_sub($$$);

croak "Wrong number of arguments" if (@ARGV != 3);

my $file1     = shift;
my $file2     = shift;
my $output    = shift;

$output =~ /(.*)\..*/;
my $srt_output = "$1.srt";
$file1 =~ /(.*)\..*/;
my $srt1 = "$1.srt";
$file2 =~ /(.*)\..*/;
my $srt2 = "$1.srt";

croak "Input $file1 non existent"    if (!-e$file1);
croak "Input $file2 non existent"    if (!-e$file2);
croak "Input $srt1 non existent"    if (!-e$srt1);
croak "Input $srt2 non existent"    if (!-e$srt2);
croak "Output $output exists"        if (-e$output);
croak "Output $srt_output exists"    if (-e$srt_output);

# get file1 length
my $file1_length = 0;
open(INFO,"mplayer -vo null -nosound -frames 0 -identify '$file1'|");
foreach() {
    $file1_length = $1 if(/^ID_LENGTH=(.*)\..*/);
}
close INFO;

# convert $file1_length in $h,$m,$s
my ($h,$m,$s);
$s = $file1_length % 60;
$m = int ($file1_length % (60*60))/60;
$h = int ($file1_length % (60*60*24))/(60*60);

# concatenate the subs
shift_sub($srt1,$srt2,$srt_output);

# concatenate the movie
system("mencoder -ovc copy -oac copy '$file1' '$file2' -o '$output'");

sub shift_sub($$$) {
    my ($file1,$file2,$output) = @_;

    open OUTPUT, "&gt;$output" or croak "can't open $output";
    open FILE, $file1 or croak "can't open $file1";
    my $idx_shift = 0;
    while(!eof(FILE)) { # pass trough storing maximum starting index
        $_ = ;
        print OUTPUT;
        if (/^(\d+)\r\n$/) {
            chomp;
            $idx_shift = $_;
        }
    }
    close FILE;

    open FILE, $file2 or croak "can't open $file2";
    while(!eof(FILE)) {
        # srt idx
        my $num = ; # print index
        print OUTPUT $num+$idx_shift."\r\n";

        # srt time
        my $timing = ;
        my ($start,$end) = split(/\s--&gt;\s/,$timing);
        print OUTPUT add_time($start)." --&gt; ".add_time($end)."\r\n";

        # srt text
        my $line;
        do {
            $line = ;
            print OUTPUT $line;
        } while (!($line =~ m/^\r\n$/));
    }
    close FILE;
}

sub add_time($) {
    my ($hh,$mm,$ss,$sss) = split(/[:,]/,$_[0]);
    $ss += $s; $mm += $m; $hh += $h;
    if ( $ss &gt; 60 ) { $mm++; $ss -= 60; }
    if ( $mm &gt; 60 ) { $hh++; $mm -= 60; }
    return sprintf("%03d:%02d:%02d,%03d",$hh,$mm,$ss,$sss);
}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/almostworkingcode.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/almostworkingcode.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/almostworkingcode.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/almostworkingcode.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/almostworkingcode.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/almostworkingcode.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/almostworkingcode.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/almostworkingcode.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/almostworkingcode.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/almostworkingcode.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/almostworkingcode.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/almostworkingcode.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/almostworkingcode.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/almostworkingcode.wordpress.com/145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=145&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://almostworkingcode.wordpress.com/2010/09/19/concat-movies-with-srt-subtitle/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a502a5d4f53ebb6f02a96e174332d60?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mellon</media:title>
		</media:content>
	</item>
		<item>
		<title>VA-API and AMD XVBA</title>
		<link>http://almostworkingcode.wordpress.com/2010/01/29/va-api-and-amd-xvba/</link>
		<comments>http://almostworkingcode.wordpress.com/2010/01/29/va-api-and-amd-xvba/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 11:24:24 +0000</pubDate>
		<dc:creator>Dario Meloni</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[1080p]]></category>
		<category><![CDATA[amd]]></category>
		<category><![CDATA[h264]]></category>
		<category><![CDATA[intel]]></category>
		<category><![CDATA[mplayer]]></category>
		<category><![CDATA[va-api]]></category>
		<category><![CDATA[vdpau]]></category>
		<category><![CDATA[xvba]]></category>

		<guid isPermaLink="false">http://almostworkingcode.wordpress.com/?p=137</guid>
		<description><![CDATA[Lately i was just getting mad that i couldn&#8217;t watch any 1080p video on my desktop pc which has a Radeon HD4890 (ATI Catalyst 10.1) and a Phenom X3 730. MPlayer was even teasing me with this message&#8230; ************************************************ **** Your system is too SLOW to play this! **** ************************************************ this pisses me off, a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=137&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Lately i was just getting mad that i couldn&#8217;t watch any 1080p video on my desktop pc which has a Radeon HD4890 (ATI Catalyst 10.1) and a Phenom X3 730. MPlayer was even teasing me with this message&#8230;</p>
<p><code>           ************************************************<br />
**** Your system is too SLOW to play this!  ****<br />
************************************************<br />
</code></p>
<p>this pisses me off, a lot&#8230;<br />
so I decided to try to install VA-API with XVBA backend and the patches for mplayer to use it.</p>
<p>Since there is no packaging whatsoever for any of the things needed in ubuntu/debian repositories (not even in the unstable ones) i got the packages directly from <a href="http://www.splitted-desktop.com/~gbeauchesne/">splitted-desktop</a>.</p>
<p>I got the latest xvba-video (0.6.4-1), libva(-dev) (0.31.0-1+sds9) packages (nice to see that VA-API has a frontend even for VDPAU by the way), and the latest version of MPlayer va-api patches (the full version contains mplayer code, the small one has a script to get it with svn).</p>
<p>The installation of the packages went fine, but to get mplayer compiled a run of<br />
<code>apt-get build-dep mplayer</code><br />
is necessary to install all the development tools/headers and so on.</p>
<p>Then i used their bundled script &#8220;checkout-patch-build.sh&#8221; which does all the (as you may have already guessed) svn checkout, patching, building of mplayer.<br />
It went flawlessy and in a while i got mplayer ready to run.</p>
<p>i tried it with a h264 1080p movie<br />
<code>./mplayer -vo vaapi -va vaapi movie.mkv</code><br />
and it worked out like a charm, instead of hogging a CPU and still not doing real time decoding it was using only 8% of CPU time!</p>
<p>It is still unstable (at the moment, it works for me anyway) and the VA-API are not broadly implemented (hoping this will change in the near future, it provides Intel, Nvidia and ATI accelerated decoding at once!) but it really does it&#8217;s job well!<br />
If you want to try more splitted-desktop has patches for gnash too</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/almostworkingcode.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/almostworkingcode.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/almostworkingcode.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/almostworkingcode.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/almostworkingcode.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/almostworkingcode.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/almostworkingcode.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/almostworkingcode.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/almostworkingcode.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/almostworkingcode.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/almostworkingcode.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/almostworkingcode.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/almostworkingcode.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/almostworkingcode.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=137&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://almostworkingcode.wordpress.com/2010/01/29/va-api-and-amd-xvba/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a502a5d4f53ebb6f02a96e174332d60?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mellon</media:title>
		</media:content>
	</item>
		<item>
		<title>New Lolipower download script</title>
		<link>http://almostworkingcode.wordpress.com/2009/12/06/new-lolipower-download-script/</link>
		<comments>http://almostworkingcode.wordpress.com/2009/12/06/new-lolipower-download-script/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 20:49:41 +0000</pubDate>
		<dc:creator>Dario Meloni</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[Posts]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[lolipower]]></category>

		<guid isPermaLink="false">http://almostworkingcode.wordpress.com/?p=122</guid>
		<description><![CDATA[And this time it&#8217;s in perl! I rewrote the script from scratch to see how much i knew Perl, and this is what I worked out. It&#8217;s base on WWW::Mechanize and HTML::TreeBuilder::XPath respectively for managing the cookies and for searching in the html tree. Using it is fairly simple. lolipower Title and it will download [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=122&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>And this time it&#8217;s in perl!<br />
I rewrote the script from scratch to see how much i knew Perl, and this is what I worked out.<br />
It&#8217;s base on <code>WWW::Mechanize</code> and <code>HTML::TreeBuilder::XPath</code> respectively for managing the cookies and for searching in the html tree.</p>
<p>Using it is fairly simple.</p>
<p><code>lolipower Title</code></p>
<p>and it will download all the episodes of the anime in the local folder.<br />
With respect to the ruby version you can find in these pages the title can be partial, the script will find the complete title. If the title matches more then one anime then a list of anime that maches will be printed and the download aborted.</p>
<p>There are various options, especially 2 that I added to put the script in a cronjob to get mailed when a new episode comes out and automatically download it at night time.</p>
<p><code>lolipower --dest TitleFolder --new-ep Title</code></p>
<p>The <code>--dest</code> options tells the script where to save the files instead of the current directory, while <code>--new-ep</code> suppress every output except for new downloaded episodes, and will write in the mail even if the anime is completed.</p>
<p>One another nice feature is that it doesn&#8217;t check anymore each file&#8217;s md5 hash but only for freshly downloaded files. The behavior can be hoverwer forced with the <code>--md5</code> flag.</p>
<p>Aside from the options <code>--starep</code> and <code>--endep</code> that do exactly what you can think of there is the <code>--search</code> command. It will search the title in the list of animes without downloading anything.</p>
<p>There is another cute option to allow serial download of more then one anime! The <code>--conf</code> option.<br />
It accepts file with <code>#</code> as comment line and structured like<br />
<code><br />
# comment line<br />
Title=Folder<br />
Title=Folder<br />
</code><br />
where Title is the anime title (or a match for a unique anime) and Folder is a absolute path to the location where to store the episodes.</p>
<p>And from version 1.1 there is support for out of order episodes on the website, &#8211;startep and &#8211;endep works a lot better and the pages on the server are loaded less times.</p>
<p>The script can be found <a href="http://github.com/mellon85/Lolipower-Downloader">here</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/almostworkingcode.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/almostworkingcode.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/almostworkingcode.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/almostworkingcode.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/almostworkingcode.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/almostworkingcode.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/almostworkingcode.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/almostworkingcode.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/almostworkingcode.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/almostworkingcode.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/almostworkingcode.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/almostworkingcode.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/almostworkingcode.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/almostworkingcode.wordpress.com/122/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=122&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://almostworkingcode.wordpress.com/2009/12/06/new-lolipower-download-script/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a502a5d4f53ebb6f02a96e174332d60?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mellon</media:title>
		</media:content>
	</item>
		<item>
		<title>Hamachi and UDP Broadcast Games</title>
		<link>http://almostworkingcode.wordpress.com/2009/05/28/hamachi-and-udp-broadcast-games/</link>
		<comments>http://almostworkingcode.wordpress.com/2009/05/28/hamachi-and-udp-broadcast-games/#comments</comments>
		<pubDate>Thu, 28 May 2009 17:25:59 +0000</pubDate>
		<dc:creator>Dario Meloni</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[broadcast]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[hamachi]]></category>
		<category><![CDATA[lan]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[starcraft]]></category>
		<category><![CDATA[udp]]></category>
		<category><![CDATA[vpn]]></category>
		<category><![CDATA[warcraft]]></category>

		<guid isPermaLink="false">http://almostworkingcode.wordpress.com/?p=98</guid>
		<description><![CDATA[I was recently trying to play some old game (Starcraft, Warcraft 3, and others) in LAN with some friends through the hamachi VPN system. All attempts were unsucessful due to the fact that the broadcasted UDP packet weren&#8217;t sent over the VPN interface but only in the local LAN. To solve this we just had [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=98&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was recently trying to play some old game (Starcraft, Warcraft 3, and others) in LAN with some friends through the hamachi VPN system. All attempts were unsucessful due to the fact that the broadcasted UDP packet weren&#8217;t sent over the VPN interface but only in the local LAN.</p>
<p>To solve this we just had to manipulate the routing table of the systems.<br />
After connecting to the hamachi VPN just do these commands as root user</p>
<p>OS X: as long hamachi uses 5.x.x.x for his nodes<br />
<code>route add -net 255.255.255.255 5.255.255.255</code></p>
<p>Linux: where ham0 is the hamachi interface. There are 2 options available, test it out that works for you<br />
<code>route add -net 255.255.255.255 netmask 255.255.255.255 dev ham0</code></p>
<p><code>sudo route add -n 5.255.255.255 gw 5.0.0.1 dev ham0</code><br />
<em>as suggested from Blake Lightly</em></p>
<p>This will redirect all the broadcast packets, maybe it can interfere with some other program, but as long as you want some time off to play it works great. To clear the modification to the routing table we didn&#8217;t do anything else then disconnecting from the hamachi VPN, the system handles the disappareance of the interface removing every involved route.</p>
<p>Resuming*</p>
<table>
<tr>
<th>Game</th>
<th>Linux</th>
<th>MacOS</th>
</tr>
<tr>
<th>Warcraft 3</th>
<th>play</th>
<th>host</th>
</tr>
<tr>
<th>Starcraft</th>
<th>host</th>
<th>host</th>
</tr>
<tr>
<th>Delta Force</th>
<th>host</th>
<th>untested</th>
</tr>
</table>
<p>* <em>Linux has no other setup then just starting hamachi. This all was tested between a Mac and a Linux systems</em></p>
<p>If someone can test other games and maybe help on the linux problem that would be great.</p>
<p>Hope this helps!<br />
[last update 2 May 2010]</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/almostworkingcode.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/almostworkingcode.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/almostworkingcode.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/almostworkingcode.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/almostworkingcode.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/almostworkingcode.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/almostworkingcode.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/almostworkingcode.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/almostworkingcode.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/almostworkingcode.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/almostworkingcode.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/almostworkingcode.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/almostworkingcode.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/almostworkingcode.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=98&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://almostworkingcode.wordpress.com/2009/05/28/hamachi-and-udp-broadcast-games/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a502a5d4f53ebb6f02a96e174332d60?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mellon</media:title>
		</media:content>
	</item>
		<item>
		<title>Rtorrent web interface</title>
		<link>http://almostworkingcode.wordpress.com/2009/05/25/rtorrent-web-interface/</link>
		<comments>http://almostworkingcode.wordpress.com/2009/05/25/rtorrent-web-interface/#comments</comments>
		<pubDate>Mon, 25 May 2009 16:19:28 +0000</pubDate>
		<dc:creator>Dario Meloni</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[rpc]]></category>
		<category><![CDATA[rtorrent]]></category>
		<category><![CDATA[socket]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://almostworkingcode.wordpress.com/?p=87</guid>
		<description><![CDATA[Me and alka wrote a web application in ruby which serves as an interface to rtorrent. It has been written in ruby using the ramaze and sequel frameworks. It is currently tested on debian stable with mostly apt-get installed gems, for more info check the README file included (the only one external to the distribution [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=87&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Me and alka wrote a web application in ruby which serves as an interface to rtorrent. It has been written in ruby using the ramaze and sequel frameworks. It<br />
is currently tested on debian stable with mostly apt-get installed gems,<br />
for more info check the README file included (the only one external to<br />
the distribution should be the xmlrpc gem which is on another post in<br />
this blog).<br />
It supports authentication and accesses rtorrent through the unix socket<br />
interface, allowing to run the server as a user process.<br />
An internal copy of the information from rtorrent is stored in a<br />
in-memory sqlite database (maybe it can be totaly avoided, but that was how we planned it in the beggining) to avoid to access too much times to rtorrent<br />
along with the caching of pages in ramaze.</p>
<p>Currently may lack some feature, but it&#8217;s doing it&#8217;s job, the main<br />
missing feature is the user interface. If someone can write a<br />
CSS and maybe do some cleanup in the interface any help would be<br />
appreciated.</p>
<p>As usual in the code page everything can be found or directly here<br />
<code>git://github.com/mellon85/rtorrent-wrb.git</code></p>
<p>It is currently no more developed as we switched torrent client. Patches or comment are welcomed</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/almostworkingcode.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/almostworkingcode.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/almostworkingcode.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/almostworkingcode.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/almostworkingcode.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/almostworkingcode.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/almostworkingcode.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/almostworkingcode.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/almostworkingcode.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/almostworkingcode.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/almostworkingcode.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/almostworkingcode.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/almostworkingcode.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/almostworkingcode.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=87&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://almostworkingcode.wordpress.com/2009/05/25/rtorrent-web-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a502a5d4f53ebb6f02a96e174332d60?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mellon</media:title>
		</media:content>
	</item>
		<item>
		<title>Download anime from lolipower.org</title>
		<link>http://almostworkingcode.wordpress.com/2009/05/17/download-from-lolipower-org/</link>
		<comments>http://almostworkingcode.wordpress.com/2009/05/17/download-from-lolipower-org/#comments</comments>
		<pubDate>Sun, 17 May 2009 07:45:32 +0000</pubDate>
		<dc:creator>alkawiz</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[md5]]></category>

		<guid isPermaLink="false">http://almostworkingcode.wordpress.com/?p=72</guid>
		<description><![CDATA[This little ruby script can download a whole anime serie from lolipower.org, when the anime page respects the &#8220;standards&#8221;. It verifies the MD5 checksum of downloads and it avoids to download already downloaded (checksum checked) or duplicated episodes. If there are duplicate episodes the mkv format one will be preferred. You can also choose ,with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=72&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This little ruby script can download a whole anime serie from lolipower.org, when the anime page respects the &#8220;standards&#8221;. It verifies the MD5 checksum of downloads and it avoids to download already downloaded (checksum checked) or duplicated episodes.<br />
If there are duplicate episodes the mkv format one will be preferred. You can also choose ,with command line arguments, the first and last episode to download.</p>
<p>You can find the link to the project in the code page or just here<br />
git://github.com/alka/down-lolipower.git</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/almostworkingcode.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/almostworkingcode.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/almostworkingcode.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/almostworkingcode.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/almostworkingcode.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/almostworkingcode.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/almostworkingcode.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/almostworkingcode.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/almostworkingcode.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/almostworkingcode.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/almostworkingcode.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/almostworkingcode.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/almostworkingcode.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/almostworkingcode.wordpress.com/72/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=72&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://almostworkingcode.wordpress.com/2009/05/17/download-from-lolipower-org/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/497bd6ce4379f4d33f9c1b1d5608f695?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">alkawiz</media:title>
		</media:content>
	</item>
		<item>
		<title>Portsfoster</title>
		<link>http://almostworkingcode.wordpress.com/2009/02/03/portsfoster/</link>
		<comments>http://almostworkingcode.wordpress.com/2009/02/03/portsfoster/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 16:12:16 +0000</pubDate>
		<dc:creator>Dario Meloni</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[clean]]></category>
		<category><![CDATA[debfoster]]></category>
		<category><![CDATA[dependencies]]></category>
		<category><![CDATA[deps]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[portfile]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://almostworkingcode.wordpress.com/?p=58</guid>
		<description><![CDATA[Portsfoster is a debfoster clone i wrote in ruby for the Macports software distribution system. It work in a similar way and helps you to have a clean MacPorts installation without ports you don&#8217;t want (or you forgot). At start it will ask you if you want to purge inactive packages (or the program will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=58&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Portsfoster is a <a href="http://www.fruit.je/debfoster/">debfoster</a> clone i wrote in ruby for the <a href="http://www.macports.org/">Macports</a> software distribution system.<br />
It work in a similar way and helps you to have a clean MacPorts installation without ports you don&#8217;t want (or you forgot).</p>
<p>At start it will ask you if you want to purge inactive packages (or the program will leave them untouched). Then it will load all the installed ports and dependencies to check which are new (to his knowledge) and ask you if you want to keep them.</p>
<p>You you don&#8217;t keep a port the program will continue asking on the packets dependencies if they aren&#8217;t already locked for another port.</p>
<p>When done the list of &#8220;keep&#8221; packet will be saved in <code>/opt/local/var/portsfoster</code> as simple text with one package for line. You can delete or add manually if you need to.</p>
<p>Don&#8217;t worry if the program takes time to calculate all the dependencies, it gets the information through the port command and not analyzing the port files, and this takes some time&#8230;</p>
<p>You can find the link to the project in the code page or just here<br />
<code>git://github.com/mellon85/portsfoster.git</code></p>
<p>P.s.<br />
Dont worry if the pogram reports that information about a port can&#8217;t be found. It means that the package has been localy installed (and it is not in the port tree) or that it has been installed and then removed from the port tree.<br />
If you have a old installation of macports (say, older then this post at least) you may receive the warning on the <code>render</code> port. Just uninstall it, it is no more in the tree.</p>
<p><strong>It has been discontinued and it is not working, it needs fixes to work.</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/almostworkingcode.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/almostworkingcode.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/almostworkingcode.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/almostworkingcode.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/almostworkingcode.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/almostworkingcode.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/almostworkingcode.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/almostworkingcode.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/almostworkingcode.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/almostworkingcode.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/almostworkingcode.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/almostworkingcode.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/almostworkingcode.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/almostworkingcode.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=58&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://almostworkingcode.wordpress.com/2009/02/03/portsfoster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a502a5d4f53ebb6f02a96e174332d60?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mellon</media:title>
		</media:content>
	</item>
		<item>
		<title>4chan</title>
		<link>http://almostworkingcode.wordpress.com/2009/01/19/4chan/</link>
		<comments>http://almostworkingcode.wordpress.com/2009/01/19/4chan/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 19:29:21 +0000</pubDate>
		<dc:creator>Dario Meloni</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[4chan]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[net]]></category>
		<category><![CDATA[page]]></category>

		<guid isPermaLink="false">http://almostworkingcode.wordpress.com/?p=49</guid>
		<description><![CDATA[I have written for testing purpose a script to download images that would have been posted on the website 4chan.org. I tried to let it go for 1 day.. I&#8217;ve got 2.7GB of data for 16661 images (the number tell me something about of what i have done). Here&#8217;s the code #! /usr/bin/ruby # License: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=49&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have written for testing purpose a script to download images that would have been posted on the website <a href="http://www.4chan.org/">4chan.org</a>. I tried to let it go for 1 day.. I&#8217;ve got 2.7GB of data for 16661 images (the number tell me something about of what i have done).</p>
<p>Here&#8217;s the code</p>
<pre>
#! /usr/bin/ruby
# License: GPLv3 or newer

urls=['http://img.4chan.org/b/1.html',
    " ... other 4chan boards you want ..." ]

require 'rubygems'
require 'net/http'
require 'thread'

def download(url)
    uri = URI.parse(url)
    Net::HTTP.start(uri.host) { |h|
        page = h.get(uri.path)
        data = page.body.split(/(href=|\n)/).delete_if {
                               |x| !(x =~ /\"http/)}
        data = data.map {|x| x.gsub(/^\"/,'')}
        data = data.map { |x| x.gsub(/\".*/,'')}
        data = data.delete_if {|x| !(x =~ /(png|jpg|gif)$/)}
        data.uniq.each {|x|
            img = x.gsub(/.*\//,'')
            if !File.exist?(img) then
                puts "downloading #{img}"
                resp = h.get(URI.parse(x).path)
                open(img,"wb") { |f|
                    f.write(resp.body)
                }
            end
        }
        h.close
    }
end

threads = []
s = Mutex.new
urls.each { |x|
    Thread.start{
        s.synchronize{
            threads &lt;&lt; Thread.current
        }
        download(x)}
    }
</pre>
<pre>
while (threads.length != urls.length) do
    Thread.pass
    sleep(5)
end

threads.each{ |x|
    begin
        x.join
    rescue Exception =&gt; e
    end }
puts "finished"
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/almostworkingcode.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/almostworkingcode.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/almostworkingcode.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/almostworkingcode.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/almostworkingcode.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/almostworkingcode.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/almostworkingcode.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/almostworkingcode.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/almostworkingcode.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/almostworkingcode.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/almostworkingcode.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/almostworkingcode.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/almostworkingcode.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/almostworkingcode.wordpress.com/49/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=almostworkingcode.wordpress.com&amp;blog=3928197&amp;post=49&amp;subd=almostworkingcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://almostworkingcode.wordpress.com/2009/01/19/4chan/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a502a5d4f53ebb6f02a96e174332d60?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mellon</media:title>
		</media:content>
	</item>
	</channel>
</rss>
