<?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>orz</title>
	<atom:link href="http://www.radicand.org/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.radicand.org</link>
	<description></description>
	<lastBuildDate>Sat, 10 Dec 2011 15:42:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Subsonic Under Tomcat &amp; Gentoo</title>
		<link>https://www.radicand.org/subsonic-under-tomcat-gentoo/</link>
		<comments>https://www.radicand.org/subsonic-under-tomcat-gentoo/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 15:42:02 +0000</pubDate>
		<dc:creator>radicand</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[fixes]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[subsonic]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://www.radicand.org/?p=83</guid>
		<description><![CDATA[You might be seeing non-working audio output and the following tricky bits in your subsonic log: Error in jukebox: javax.sound.sampled.LineUnavailableException: Audio Device Unavailable First thing is to make sure you&#8217;re running the Sun JDK and not OpenJDK or something else. Apparently there are things that don&#8217;t play well with non-Sun. If you&#8217;ve done this, restarted [...]]]></description>
			<content:encoded><![CDATA[<p>You might be seeing non-working audio output and the following tricky bits in your subsonic log:
<code></p>

<p>Error in jukebox: javax.sound.sampled.LineUnavailableException: Audio Device Unavailable
</code></p>

<p>First thing is to make sure you&#8217;re running the Sun JDK and not OpenJDK or something else.  Apparently there are things that don&#8217;t play well with non-Sun.</p>

<p>If you&#8217;ve done this, restarted Tomcat and still have no audio when using Subsonic with Gentoo and Tomcat, remember to add Tomcat to the relevant groups:</p>

<p><code>
groupmems -g pulse -a tomcat</p>

<p>groupmems -g pulse-access -a tomcat</p>

<p>groupmems -g audio -a tomcat</p>

<p>groupmems -g plugdev -a tomcat
</code></p>

<p>To be fair I&#8217;m not sure if they&#8217;re all necessary, but it works for me.  You&#8217;ll need to restart Tomcat afterward to make it work.</p>

<p><code></p>

<p>sudo /etc/init.d/tomcat-6 restart
</code></p>
]]></content:encoded>
			<wfw:commentRss>https://www.radicand.org/subsonic-under-tomcat-gentoo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenVZ: VLAN with VEs that Works</title>
		<link>https://www.radicand.org/openvz-vlan-with-ves-that-works/</link>
		<comments>https://www.radicand.org/openvz-vlan-with-ves-that-works/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 02:05:18 +0000</pubDate>
		<dc:creator>radicand</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[openvz]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.radicand.org/?p=76</guid>
		<description><![CDATA[So I setup OpenVZ a few months ago in an environment where my Host had two NICs, one on a local &#8220;office&#8221; network, and another hooked directly up to a WiFi AP that had VLAN&#8217;d SSIDs. That part&#8217;s not too important, but what is important is the VLANs. It seemed real easy when I did [...]]]></description>
			<content:encoded><![CDATA[<p>So I setup OpenVZ a few months ago in an environment where my Host had two NICs, one on a local &#8220;office&#8221; network, and another hooked directly up to a WiFi AP that had VLAN&#8217;d SSIDs.  That part&#8217;s not too important, but what is important is the VLANs.  It seemed real easy when I did it back then.</p>

<p>However, having to re-do it again for various reasons without the source config, it was not so easy.  In fact, I wasted nearly half a day until I figured out you need to add the veth device and the Host adapter to a bridge to even route the traffic properly.  The key understanding is that the veth device for OpenVZ has absolutely no relation to any network adapter on the HN.  Understand that and you&#8217;ll be OK.  All it does is create an interface on the HN whose other side is on the VE.</p>

<p>So to save myself some hellish boot configuration, I modified vznetaddbr (below) to create the bridges and bring everything up real nice for me.  The key bits are that you defined your veth device with a bridge parameter called &#8216;vlan###&#8217; where ### is the vlan ID.  You&#8217;ll also need to change the line near the top that says dev=eth1, unless eth1 is your VLAN&#8217;d NIC.</p>

<p>Really, hopefully this helps someone.  Should be self-explanatory, but be sure you have brctl and vconfig installed.</p>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="co0"># create this file somewhere, and add it to</span>
<span class="co0"># /etc/vz/vznet.conf as:</span>
<span class="co0">#</span>
<span class="co0">#!/bin/bash</span>
<span class="co0">#EXTERNAL_SCRIPT=&quot;/path/to/script&quot;</span>
<span class="co0">#</span>
<span class="co0"># be sure to chmod +x both</span>
&nbsp;
<span class="re2">CONFIGFILE</span>=<span class="sy0">/</span>etc<span class="sy0">/</span>vz<span class="sy0">/</span>conf<span class="sy0">/</span><span class="re1">$VEID</span>.conf
. <span class="re1">$CONFIGFILE</span>
&nbsp;
<span class="re2">NETIFLIST</span>=$<span class="br0">&#40;</span><span class="kw3">printf</span> <span class="sy0">%</span>s <span class="st0">&quot;<span class="es2">$NETIF</span>&quot;</span> <span class="sy0">|</span><span class="kw2">tr</span> <span class="st_h">';'</span> <span class="st_h">'\n'</span><span class="br0">&#41;</span>
<span class="re2">dev</span>=<span class="st0">&quot;eth1&quot;</span>
ip <span class="kw2">link</span> <span class="kw1">set</span> dev <span class="st0">&quot;<span class="es2">$dev</span>&quot;</span> up
&nbsp;
<span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re5">-z</span> <span class="st0">&quot;<span class="es2">$NETIFLIST</span>&quot;</span> <span class="br0">&#93;</span>; <span class="kw1">then</span>
   <span class="kw3">echo</span> <span class="sy0">&gt;&amp;</span><span class="nu0">2</span> <span class="st0">&quot;According to <span class="es2">$CONFIGFILE</span>, CT<span class="es2">$VEID</span> has no veth interface configured.&quot;</span>
   <span class="kw3">exit</span> <span class="nu0">1</span>
<span class="kw1">fi</span>
&nbsp;
<span class="kw1">for</span> iface <span class="kw1">in</span> <span class="re1">$NETIFLIST</span>; <span class="kw1">do</span>
    <span class="re2">bridge</span>=
    <span class="re2">host_ifname</span>=
&nbsp;
    <span class="kw1">for</span> str <span class="kw1">in</span> $<span class="br0">&#40;</span><span class="kw3">printf</span> <span class="sy0">%</span>s <span class="st0">&quot;<span class="es2">$iface</span>&quot;</span> <span class="sy0">|</span><span class="kw2">tr</span> <span class="st_h">','</span> <span class="st_h">'\n'</span><span class="br0">&#41;</span>; <span class="kw1">do</span>
        <span class="kw1">case</span> <span class="st0">&quot;<span class="es2">$str</span>&quot;</span> <span class="kw1">in</span>
            <span class="re2">bridge</span>=<span class="sy0">*|</span><span class="re2">host_ifname</span>=<span class="sy0">*</span><span class="br0">&#41;</span>
                <span class="kw3">eval</span> <span class="st0">&quot;<span class="es3">${str%%=*}</span>=<span class="es1">\$</span>{str#*=}&quot;</span> <span class="sy0">;;</span>
        <span class="kw1">esac</span>
    <span class="kw1">done</span>
&nbsp;
<span class="co0">#    [ &quot;$host_ifname&quot; = &quot;$3&quot; ] ||</span>
<span class="co0">#       continue</span>
&nbsp;
    <span class="br0">&#91;</span> <span class="re5">-n</span> <span class="st0">&quot;<span class="es2">$bridge</span>&quot;</span> <span class="br0">&#93;</span> <span class="sy0">||</span>
        <span class="re2">bridge</span>=vmbr0
&nbsp;
    <span class="re2">vlan</span>=<span class="sy0">`</span><span class="kw3">echo</span> <span class="st0">&quot;<span class="es2">$bridge</span>&quot;</span> <span class="sy0">|</span> <span class="kw2">sed</span> s<span class="sy0">/</span>vlan<span class="sy0">//`</span>
    <span class="re2">target_if</span>=<span class="st0">&quot;eth1.<span class="es2">$vlan</span>&quot;</span>
&nbsp;
    <span class="kw3">echo</span> <span class="st0">&quot;Creating <span class="es2">$bridge</span> on CT0&quot;</span>
    brctl addbr <span class="st0">&quot;<span class="es2">$bridge</span>&quot;</span>
    <span class="kw3">echo</span> <span class="st0">&quot;Adding interface <span class="es2">$host_ifname</span> to bridge <span class="es2">$bridge</span> on CT0 for CT<span class="es2">$VEID</span>&quot;</span>
    ip <span class="kw2">link</span> <span class="kw1">set</span> dev <span class="st0">&quot;<span class="es2">$host_ifname</span>&quot;</span> up
    brctl addif <span class="st0">&quot;<span class="es2">$bridge</span>&quot;</span> <span class="st0">&quot;<span class="es2">$host_ifname</span>&quot;</span>
    <span class="kw3">echo</span> <span class="nu0">1</span> <span class="sy0">&gt;</span><span class="st0">&quot;/proc/sys/net/ipv4/conf/<span class="es2">$host_ifname</span>/proxy_arp&quot;</span>
    <span class="kw3">echo</span> <span class="nu0">1</span> <span class="sy0">&gt;</span><span class="st0">&quot;/proc/sys/net/ipv4/conf/<span class="es2">$host_ifname</span>/forwarding&quot;</span>
&nbsp;
    <span class="kw3">echo</span> <span class="st0">&quot;Creating interface <span class="es2">$target_if</span> on CT0 for CT<span class="es2">$VEID</span>&quot;</span>
    vconfig add <span class="st0">&quot;<span class="es2">$dev</span>&quot;</span> <span class="st0">&quot;<span class="es2">$vlan</span>&quot;</span>
    <span class="kw3">echo</span> <span class="st0">&quot;Adding interface <span class="es2">$host_ifname</span> to bridge <span class="es2">$bridge</span> on CT0 for CT<span class="es2">$VEID</span>&quot;</span>
    ip <span class="kw2">link</span> <span class="kw1">set</span> dev <span class="st0">&quot;<span class="es2">$target_if</span>&quot;</span> up
    brctl addif <span class="st0">&quot;<span class="es2">$bridge</span>&quot;</span> <span class="st0">&quot;<span class="es2">$target_if</span>&quot;</span>
    <span class="kw3">echo</span> <span class="nu0">1</span> <span class="sy0">&gt;</span><span class="st0">&quot;/proc/sys/net/ipv4/conf/<span class="es2">$target_if</span>/proxy_arp&quot;</span>
    <span class="kw3">echo</span> <span class="nu0">1</span> <span class="sy0">&gt;</span><span class="st0">&quot;/proc/sys/net/ipv4/conf/<span class="es2">$target_if</span>/forwarding&quot;</span>
&nbsp;
    ip <span class="kw2">link</span> <span class="kw1">set</span> dev <span class="st0">&quot;<span class="es2">$bridge</span>&quot;</span> up
&nbsp;
<span class="kw1">done</span>
&nbsp;
<span class="kw3">exit</span> <span class="nu0">0</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>https://www.radicand.org/openvz-vlan-with-ves-that-works/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fix &#8216;Nautilus Hangs When Viewing Properties&#8217;</title>
		<link>https://www.radicand.org/fix-nautilus-hang-on-properties-window/</link>
		<comments>https://www.radicand.org/fix-nautilus-hang-on-properties-window/#comments</comments>
		<pubDate>Sat, 14 May 2011 22:49:47 +0000</pubDate>
		<dc:creator>radicand</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.radicand.org/?p=73</guid>
		<description><![CDATA[If you get hangs in Nautilus when attempting to view file properties, do the following: rm -rf ~/.thumbnails killall nautilus Should be good after that!]]></description>
			<content:encoded><![CDATA[<p>If you get hangs in Nautilus when attempting to view file properties, do the following:</p>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">rm</span> <span class="re5">-rf</span> ~<span class="sy0">/</span>.thumbnails
<span class="kw2">killall</span> nautilus</pre></div></div>


<p>Should be good after that!</p>
]]></content:encoded>
			<wfw:commentRss>https://www.radicand.org/fix-nautilus-hang-on-properties-window/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recursive Search and Replace in *Nix</title>
		<link>https://www.radicand.org/recursive-search-replace-nix/</link>
		<comments>https://www.radicand.org/recursive-search-replace-nix/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 03:02:09 +0000</pubDate>
		<dc:creator>radicand</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.radicand.org/?p=70</guid>
		<description><![CDATA[grep -rl matchstring somedir/ &#124; xargs sed -i 's/string1/string2/g' The Source]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">grep</span> <span class="re5">-rl</span> matchstring somedir<span class="sy0">/</span> <span class="sy0">|</span> <span class="kw2">xargs</span> <span class="kw2">sed</span> <span class="re5">-i</span> <span class="st_h">'s/string1/string2/g'</span></pre></div></div>


<p><a href="http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html">The Source</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.radicand.org/recursive-search-replace-nix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing MySQLdb encoding issues with Python</title>
		<link>https://www.radicand.org/fixing-mysqldb-encoding-python/</link>
		<comments>https://www.radicand.org/fixing-mysqldb-encoding-python/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 00:01:49 +0000</pubDate>
		<dc:creator>radicand</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.radicand.org/?p=68</guid>
		<description><![CDATA[Are you running into encoding issues with MySQLdb on Python? Have you searched high and low only to be told to change your my.cnf settings and create tables with the proper encoding, yet it STILL doesn&#8217;t work? In that case, be sure to specify charset='utf8' in your MySQLdb.connect(...) along with the rest of the required [...]]]></description>
			<content:encoded><![CDATA[<p>Are you running into encoding issues with MySQLdb on Python?  Have you searched high and low only to be told to change your <code>my.cnf</code> settings and create tables with the proper encoding, yet it STILL doesn&#8217;t work?  In that case, be sure to specify <code>charset='utf8'</code> in your <code>MySQLdb.connect(...)</code> along with the rest of the required parameters.  This tiny, neglected setting is what&#8217;s actually used to encode unicode back for MySQL.  Not configuration files, not table settings, just that.</p>

<p>Of course, you should have a table with a utf8 charset for it to work, but this is the setting that will prevent those latin-1 encoding issues when you swore you didn&#8217;t say latin-1 anywhere.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.radicand.org/fixing-mysqldb-encoding-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cloning Hard Drives</title>
		<link>https://www.radicand.org/cloning-hard-drives/</link>
		<comments>https://www.radicand.org/cloning-hard-drives/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 01:57:45 +0000</pubDate>
		<dc:creator>radicand</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.radicand.org/?p=66</guid>
		<description><![CDATA[Very easy: dd if=/dev/SOURCE of=/dev/DESTINATION bs=1M I&#8217;ve found in my experience 1M tends to be a solid &#8220;bs&#8221; number; lower than that and the copy rate is slower, higher than that doesn&#8217;t give much performance gain (if any). The SOURCE should be the hard disk that has the image you want to keep and clone, [...]]]></description>
			<content:encoded><![CDATA[<p>Very easy:</p>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">dd</span> <span class="re2">if</span>=<span class="sy0">/</span>dev<span class="sy0">/</span>SOURCE <span class="re2">of</span>=<span class="sy0">/</span>dev<span class="sy0">/</span>DESTINATION <span class="re2">bs</span>=1M</pre></div></div>


<p>I&#8217;ve found in my experience 1M tends to be a solid &#8220;bs&#8221; number; lower than that and the copy rate is slower, higher than that doesn&#8217;t give much performance gain (if any).  The SOURCE should be the hard disk that has the image you want to keep and clone, the DESTINATION should be the hard disk that is to be cloned and receive the image on the SOURCE.</p>

<p>This will copy, bit-for-bit, everything on one hard disk to another.  Useful for copying over complex workstation/server configurations on machines with the same hardware.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.radicand.org/cloning-hard-drives/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mounting a JFFS2 filesystem in Linux</title>
		<link>https://www.radicand.org/mounting-a-jffs2-filesystem-in-linux/</link>
		<comments>https://www.radicand.org/mounting-a-jffs2-filesystem-in-linux/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 07:25:00 +0000</pubDate>
		<dc:creator>radicand</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[jffs2]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.radicand.org/?p=64</guid>
		<description><![CDATA[This is described on this mailing list, but here&#8217;s the short of it in case that page ever dies: If /dev/mtdblock0 doesn&#8217;t exist, do the following mknod /dev/mtdblock0 b 31 0 Then do the following. The kernel modules can be enabled under Device Drivers->MTD. Make sure to get them all. modprobe mtd # get this [...]]]></description>
			<content:encoded><![CDATA[<p>This is described on <a href="http://www.handhelds.org/hypermail/familiar/62/6233.html">this mailing list</a>, but here&#8217;s the short of it in case that page ever dies:</p>

<p>If /dev/mtdblock0 doesn&#8217;t exist, do the following</p>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">mknod</span> <span class="sy0">/</span>dev<span class="sy0">/</span>mtdblock0 b <span class="nu0">31</span> <span class="nu0">0</span></pre></div></div>


<p>Then do the following.  The kernel modules can be enabled under Device Drivers->MTD.  Make sure to get them all.</p>


<div class="wp_syntax"><div class="code"><pre class="bash">modprobe mtd <span class="co0"># get this when enabling MTD</span>
modprobe jffs2 <span class="co0"># under Filesystems, Misc</span>
modprobe mtdram <span class="co0"># under MTD section</span>
modprobe mtdchar <span class="co0"># under MTD section</span>
modprobe mtdblock <span class="co0"># under MTD section</span>
&nbsp;
<span class="kw2">dd</span> <span class="re2">if</span>=your.jffs2 <span class="re2">of</span>=<span class="sy0">/</span>dev<span class="sy0">/</span>mtd0
&nbsp;
<span class="kw2">mount</span> <span class="re5">-t</span> jffs2 <span class="sy0">/</span>dev<span class="sy0">/</span>mtdblock0 <span class="sy0">/</span>your-mount-point</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>https://www.radicand.org/mounting-a-jffs2-filesystem-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making Facebook Useful</title>
		<link>https://www.radicand.org/making-facebook-useful/</link>
		<comments>https://www.radicand.org/making-facebook-useful/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 10:42:15 +0000</pubDate>
		<dc:creator>radicand</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[lazy developers]]></category>

		<guid isPermaLink="false">http://www.radicand.org/?p=62</guid>
		<description><![CDATA[I&#8217;m not a particularly big fan of Facebook, but I recognize its usefulness in some ways, so I have an account. My brother (and a bunch of other folks I know) seem to be pretty addicted to the site, for reasons unknown to me. Maybe that&#8217;s the same reason I find keeping a Twitter account [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not a particularly big fan of Facebook, but I recognize its usefulness in some ways, so I have an account.  My brother (and a bunch of other folks I know) seem to be pretty addicted to the site, for reasons unknown to me.  Maybe that&#8217;s the same reason I find keeping a Twitter account useless (no, I don&#8217;t have one).</p>

<p>So imagine my surprise when I sign in today and discover that I can&#8217;t find friends of mine from a certain city I&#8217;m visiting soon.  Searching for said city returns a bunch of people, events, <em>web results</em> and other things of no relevance.  Apparently Facebook thinks people would rather find new &#8220;friends&#8221; than search the ones they have.</p>

<p>After searching <em>Google</em> for some sanity-checking, someone had <a href="http://www.facebook.com/friends/?filter=bfp#!/friends/?filter=bfp">this link</a> to share, which apparently is exactly what I wanted in the first place.  Attempts to find this page from the Facebook interface were met with frustration and failure, until about 10 minutes later I found it under &#8220;Edit Friends&#8221;.  Edit Friends?  What?</p>

<p>Maybe I&#8217;m overthinking it, but why is searching your friends list under &#8220;Edit&#8221; and actual searching doesn&#8217;t search your friends?  Did the use-case focus group goof up?</p>
]]></content:encoded>
			<wfw:commentRss>https://www.radicand.org/making-facebook-useful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>eDonkey2000 Hash in Python</title>
		<link>https://www.radicand.org/edonkey2000-hash-in-python/</link>
		<comments>https://www.radicand.org/edonkey2000-hash-in-python/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 20:57:20 +0000</pubDate>
		<dc:creator>radicand</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.radicand.org/?p=60</guid>
		<description><![CDATA[As part of a filesystem watcher program I maintain as part of a larger site, I need to obtain the ed2k hash of some files. Believe me when I tell you I have searched high and low for an Edonkey2000 hash algorithm in python. I&#8217;ve seen massive libraries that scared the bejesus out of me, [...]]]></description>
			<content:encoded><![CDATA[<p>As part of a filesystem watcher program I maintain as part of a larger site, I need to obtain the ed2k hash of some files.  Believe me when I tell you I have searched high and low for an Edonkey2000 hash algorithm in python.  I&#8217;ve seen massive libraries that scared the bejesus out of me, but nothing clean, concise, and without external dependencies.  Enjoy the below.  It&#8217;s worth noting it&#8217;s just as fast as the C version.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="python"><span class="kw1">import</span> hashlib
&nbsp;
<span class="kw1">def</span> hash_file<span class="br0">&#40;</span><span class="kw2">self</span>, file_path<span class="br0">&#41;</span>:
    <span class="st0">&quot;&quot;&quot; Returns the ed2k hash of a given file. &quot;&quot;&quot;</span>
&nbsp;
    md4 = hashlib.<span class="kw3">new</span><span class="br0">&#40;</span><span class="st0">'md4'</span><span class="br0">&#41;</span>.<span class="kw3">copy</span>
&nbsp;
    <span class="kw1">def</span> gen<span class="br0">&#40;</span>f<span class="br0">&#41;</span>:
        <span class="kw1">while</span> <span class="kw2">True</span>:
            x = f.<span class="me1">read</span><span class="br0">&#40;</span><span class="nu0">9728000</span><span class="br0">&#41;</span>
            <span class="kw1">if</span> x: <span class="kw1">yield</span> x
            <span class="kw1">else</span>: <span class="kw1">return</span>
&nbsp;
    <span class="kw1">def</span> md4_hash<span class="br0">&#40;</span>data<span class="br0">&#41;</span>:
        m = md4<span class="br0">&#40;</span><span class="br0">&#41;</span>
        m.<span class="me1">update</span><span class="br0">&#40;</span>data<span class="br0">&#41;</span>
        <span class="kw1">return</span> m
&nbsp;
    <span class="kw1">with</span> <span class="kw2">open</span><span class="br0">&#40;</span>file_path, <span class="st0">'rb'</span><span class="br0">&#41;</span> <span class="kw1">as</span> f:
        a = gen<span class="br0">&#40;</span>f<span class="br0">&#41;</span>
        hashes = <span class="br0">&#91;</span>md4_hash<span class="br0">&#40;</span>data<span class="br0">&#41;</span>.<span class="me1">digest</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="kw1">for</span> data <span class="kw1">in</span> a<span class="br0">&#93;</span>
        <span class="kw1">if</span> <span class="kw2">len</span><span class="br0">&#40;</span>hashes<span class="br0">&#41;</span> == <span class="nu0">1</span>:
            <span class="kw1">return</span> hashes<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>.<span class="me1">encode</span><span class="br0">&#40;</span><span class="st0">&quot;hex&quot;</span><span class="br0">&#41;</span>
        <span class="kw1">else</span>: <span class="kw1">return</span> md4_hash<span class="br0">&#40;</span><span class="kw2">reduce</span><span class="br0">&#40;</span><span class="kw1">lambda</span> a,d: a + d, hashes, <span class="st0">&quot;&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>.<span class="me1">hexdigest</span><span class="br0">&#40;</span><span class="br0">&#41;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>https://www.radicand.org/edonkey2000-hash-in-python/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Linux Hates my Palm Pre</title>
		<link>https://www.radicand.org/linux-hates-my-palm-pre/</link>
		<comments>https://www.radicand.org/linux-hates-my-palm-pre/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 15:47:53 +0000</pubDate>
		<dc:creator>radicand</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[palm pre]]></category>
		<category><![CDATA[system administration]]></category>

		<guid isPermaLink="false">http://www.radicand.org/?p=55</guid>
		<description><![CDATA[For the life of me, I can not get my desktop Linux to recognize (and thus charge or give filesystem access to) my Palm Pre. Apparently no one else on the Internet has this problem. I&#8217;ve tried enabling low level usb debugging in the kernel, and I can see when I plug the device in: [...]]]></description>
			<content:encoded><![CDATA[<p>For the life of me, I can not get my desktop Linux to recognize (and thus charge or give filesystem access to) my Palm Pre.  Apparently no one else on the Internet has this problem.</p>

<p>I&#8217;ve tried enabling low level usb debugging in the kernel, and I can see when I plug the device in:</p>

<p><code>usb 7-5.1.3: no configuration chosen from 1 choice</code></p>

<p>If I reboot the device, I see it automount for half a second during its &#8220;bootup&#8221; phase, having:</p>

<p><code>usb 7-5.1.3: configuration #1 chosen from 1 choice<br />
sd 20:0:0:0: [sdf] Attached SCSI removable disk</code></p>

<p>But then it defaults to nothing once again.  Works fine in Windows, which pains me to say.  Works fine also when my computer itself boots up- Pre must negotiate with the hardware directly since the &#8220;charge&#8221; menu shows up&#8230; but once the Linux kernel kicks in, that&#8217;s all over.</p>

<p>It&#8217;s not a lack of power on the USB bus, I can trigger that error by other means, but it&#8217;s certainly not one of the log lines normally.</p>

<p>Ideas?  I&#8217;m running out of my own.</p>

<p>My kernel: 2.6.31-gentoo-r6 SMP</p>

<p>EDIT:
&#8220;Solution&#8221;: root into the pre.  execute as root:</p>

<p><code>usbnet disable</p>

<p>/sbin/reboot</code></p>
]]></content:encoded>
			<wfw:commentRss>https://www.radicand.org/linux-hates-my-palm-pre/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

