<?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>recurser &#187; Programming</title>
	<atom:link href="http://recurser.com/articles/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://recurser.com</link>
	<description></description>
	<lastBuildDate>Sun, 01 Aug 2010 15:19:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Push and delete remote git branches</title>
		<link>http://recurser.com/articles/2010/03/17/push-and-delete-remote-git-branches/</link>
		<comments>http://recurser.com/articles/2010/03/17/push-and-delete-remote-git-branches/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 03:44:42 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Version Control]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=530</guid>
		<description><![CDATA[A few simple pointers on managing remote git branches.]]></description>
			<content:encoded><![CDATA[	<p>This is easy to do, but I always forget how to do it, so this is more a reminder to myself than anything else.</p>

	<p>To create and checkout a branch in git :<br />
<pre class="bash">&gt; git branch version_0<span style="color: #cc66cc;">.9</span><span style="color: #cc66cc;">.3</span>
&gt; git checkout version_0<span style="color: #cc66cc;">.9</span><span style="color: #cc66cc;">.3</span></pre></p>

	<p>.. or if you have a better memory than me you can do it in one command :<br />
<pre class="bash">&gt; git checkout -b version_0<span style="color: #cc66cc;">.9</span><span style="color: #cc66cc;">.3</span></pre></p>

	<p>Now we&#8217;ve created the branch, committed a bunch of changes, and we want to push it to a remote repository. Regular <em>git push</em> doesn&#8217;t do anything :<br />
<pre class="bash">&gt; git push
Everything up-to-date</pre></p>

	<p>You have to specify the remote name where you want to push it to (usually origin, depending how you&#8217;ve configured things) :<br />
<pre class="bash">&gt; git push origin version_0<span style="color: #cc66cc;">.9</span><span style="color: #cc66cc;">.3</span>
Total <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#40;</span>delta <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>, reused <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#40;</span>delta <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
To git@recurser.com:my_repository.git
 * <span style="color: #66cc66;">&#91;</span>new branch<span style="color: #66cc66;">&#93;</span>      version_0<span style="color: #cc66cc;">.9</span><span style="color: #cc66cc;">.3</span> -&gt; version_0<span style="color: #cc66cc;">.9</span><span style="color: #cc66cc;">.3</span></pre></p>

	<p>The syntax to delete a remote branch is the part I always forget :<br />
<pre class="bash">git push origin :version_0<span style="color: #cc66cc;">.9</span><span style="color: #cc66cc;">.3</span></pre><br />
Note that this will only delete the remote branch &#8211; you’ll still need to delete the branch locally :<br />
<pre class="bash">&gt; git branch -d version_0<span style="color: #cc66cc;">.9</span><span style="color: #cc66cc;">.3</span>.</pre></p>

	<p>If you&#8217;re familiar with ruby, you should also checkout the <a href="http://github.com/webmat/git_remote_branch">git_remote_branch rubygem</a> , which is designed to make working with remote branches easier.</p>]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2010/03/17/push-and-delete-remote-git-branches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling Nginx with flv streaming support on Ubuntu</title>
		<link>http://recurser.com/articles/2010/03/16/compiling-nginx-with-flv-streaming-support-on-ubuntu/</link>
		<comments>http://recurser.com/articles/2010/03/16/compiling-nginx-with-flv-streaming-support-on-ubuntu/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 08:18:17 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=518</guid>
		<description><![CDATA[Quick guide to compiling and installing "nginx":http://nginx.org/  with flv streaming support on Ubuntu.
]]></description>
			<content:encoded><![CDATA[	<p>First, we need to get the latest version of nginx :<br />
<pre class="bash">&gt; wget http://nginx.org/download/nginx<span style="color: #cc66cc;">-0.8</span><span style="color: #cc66cc;">.34</span>.tar.gz
&gt; tar xvzf nginx<span style="color: #cc66cc;">-0.8</span><span style="color: #cc66cc;">.34</span>.tar.gz
&gt; <span style="color: #000066;">cd</span> nginx<span style="color: #cc66cc;">-0.8</span><span style="color: #cc66cc;">.34</span></pre></p>

	<p>Next, configure it to support ssl, gzip, flv streaming and real-ip. I generally compile it to <em>/opt/nginx-YYMMDD</em> (change the <em>&#8212;prefix</em> setting if you want to put it somewhere else) :<br />
<pre class="bash">&gt; ./configure \
        --<span style="color: #0000ff;">prefix=</span>/opt/nginx<span style="color: #cc66cc;">-20100311</span> \
        --with-http_ssl_module \
        --with-http_gzip_static_module \
        --with-http_flv_module \
        --with-http_realip_module</pre></p>

	<p>At this point I got an error about missing <span class="caps">PCRE</span> &#8211; this Ubuntu installation is basically fresh so there&#8217;s a lot of stuff missing.<br />
<pre class="bash">./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the <span style="color: #000066;">source</span> with nginx by using --with-<span style="color: #0000ff;">pcre=</span>&lt;path&gt; option.</pre></p>

	<p>I had <em>libpcre3</em> installed, but i needed <em>libpcre3-dev</em> as well.<br />
<pre class="bash">&gt; sudo aptitude install libpcre3-dev 
&gt; ./configure \
        --<span style="color: #0000ff;">prefix=</span>/opt/nginx<span style="color: #cc66cc;">-20100311</span> \
        --with-http_ssl_module \
        --with-http_gzip_static_module \
        --with-http_flv_module \
        --with-http_realip_module</pre></p>

	<p>We get a bit further this time, but still no luck. <br />
<pre class="bash">./configure: error: SSL modules require the OpenSSL library.
You can either <span style="color: #b1b100;">do</span> not <span style="color: #000066;">enable</span> the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the <span style="color: #000066;">source</span>
with nginx by using --with-<span style="color: #0000ff;">openssl=</span>&lt;path&gt; option.</pre></p>

	<p>This time it&#8217;s <em>libssl-dev</em> that&#8217;s missing :<br />
<pre class="bash">&gt; sudo aptitude install libssl-dev
&gt; ./configure \
        --<span style="color: #0000ff;">prefix=</span>/opt/nginx<span style="color: #cc66cc;">-20100311</span> \
        --with-http_ssl_module \
        --with-http_gzip_static_module \
        --with-http_flv_module \
        --with-http_realip_module
.....
.....
.....
&nbsp;
Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + md5: using OpenSSL library
  + sha1 library is not used
  + using system zlib library</pre></p>

	<p>Now that we&#8217;ve successfully configured it, we can compile and install :<br />
<pre class="bash">&gt; make 
&gt; sudo make install</pre></p>

	<p>Now, make a symlink so you can switch to newer versions easily :<br />
<pre class="bash">&gt; sudo ln -s /opt/nginx<span style="color: #cc66cc;">-20100311</span> /opt/nginx</pre></p>

	<p>Finally, we want to set up a startup script. Create a file in /etc/init.d/nginx and paste the following in :<br />
<pre class="bash"><span style="color: #808080; font-style: italic;">#! /bin/sh</span>
&nbsp;
<span style="color: #808080; font-style: italic;">### BEGIN INIT INFO</span>
<span style="color: #808080; font-style: italic;"># Provides:          nginx</span>
<span style="color: #808080; font-style: italic;"># Required-Start:    $all</span>
<span style="color: #808080; font-style: italic;"># Required-Stop:     $all</span>
<span style="color: #808080; font-style: italic;"># Default-Start:     2 3 4 5</span>
<span style="color: #808080; font-style: italic;"># Default-Stop:      0 1 6</span>
<span style="color: #808080; font-style: italic;"># Short-Description: starts the nginx web server</span>
<span style="color: #808080; font-style: italic;"># Description:       starts nginx using start-stop-daemon</span>
<span style="color: #808080; font-style: italic;">### END INIT INFO</span>
&nbsp;
<span style="color: #0000ff;">PATH=</span>/opt/nginx/sbin:/usr/<span style="color: #000066;">local</span>/sbin:/usr/<span style="color: #000066;">local</span>/bin:/sbin:/bin:/usr/sbin:/usr/bin
<span style="color: #0000ff;">DAEMON=</span>/opt/nginx/sbin/nginx
<span style="color: #0000ff;">NAME=</span>nginx
<span style="color: #0000ff;">DESC=</span>nginx
&nbsp;
<span style="color: #000066;">test</span> -x <span style="color: #0000ff;">$DAEMON</span> || <span style="color: #000066;">exit</span> <span style="color: #cc66cc;">0</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Include nginx defaults if available</span>
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#91;</span> -f /etc/default/nginx <span style="color: #66cc66;">&#93;</span> ; <span style="color: #b1b100;">then</span>
	. /etc/default/nginx
<span style="color: #b1b100;">fi</span>
&nbsp;
<span style="color: #000066;">set</span> -e
&nbsp;
<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #b1b100;">in</span>
  start<span style="color: #66cc66;">&#41;</span>
	<span style="color: #000066;">echo</span> -n <span style="color: #ff0000;">&quot;Starting $DESC: &quot;</span>
	start-stop-daemon --start --quiet --pidfile /var/run/<span style="color: #0000ff;">$NAME</span>.pid \
		--<span style="color: #000066;">exec</span> <span style="color: #0000ff;">$DAEMON</span> -- <span style="color: #0000ff;">$DAEMON_OPTS</span>
	<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;$NAME.&quot;</span>
	;;
  stop<span style="color: #66cc66;">&#41;</span>
	<span style="color: #000066;">echo</span> -n <span style="color: #ff0000;">&quot;Stopping $DESC: &quot;</span>
	start-stop-daemon --stop --quiet --pidfile /var/run/<span style="color: #0000ff;">$NAME</span>.pid \
		--<span style="color: #000066;">exec</span> <span style="color: #0000ff;">$DAEMON</span>
	<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;$NAME.&quot;</span>
	;;
  restart|force-reload<span style="color: #66cc66;">&#41;</span>
	<span style="color: #000066;">echo</span> -n <span style="color: #ff0000;">&quot;Restarting $DESC: &quot;</span>
	start-stop-daemon --stop --quiet --pidfile \
		/var/run/<span style="color: #0000ff;">$NAME</span>.pid --<span style="color: #000066;">exec</span> <span style="color: #0000ff;">$DAEMON</span>
	sleep <span style="color: #cc66cc;">1</span>
	start-stop-daemon --start --quiet --pidfile \
		/var/run/<span style="color: #0000ff;">$NAME</span>.pid --<span style="color: #000066;">exec</span> <span style="color: #0000ff;">$DAEMON</span> -- <span style="color: #0000ff;">$DAEMON_OPTS</span>
	<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;$NAME.&quot;</span>
	;;
  reload<span style="color: #66cc66;">&#41;</span>
      <span style="color: #000066;">echo</span> -n <span style="color: #ff0000;">&quot;Reloading $DESC configuration: &quot;</span>
      start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/<span style="color: #0000ff;">$NAME</span>.pid \
          --<span style="color: #000066;">exec</span> <span style="color: #0000ff;">$DAEMON</span>
      <span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;$NAME.&quot;</span>
      ;;
  *<span style="color: #66cc66;">&#41;</span>
	<span style="color: #0000ff;">N=</span>/etc/init.d/<span style="color: #0000ff;">$NAME</span>
	<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;Usage: $N {start|stop|restart|reload|force-reload}&quot;</span> &gt;&amp;<span style="color: #cc66cc;">2</span>
	<span style="color: #000066;">exit</span> <span style="color: #cc66cc;">1</span>
	;;
<span style="color: #b1b100;">esac</span>
&nbsp;
<span style="color: #000066;">exit</span> <span style="color: #cc66cc;">0</span></pre></p>

	<p>This allows you to start/stop the server easily (although I find stop a bit flakey) :<br />
<pre class="bash">&gt; /etc/init.d/nginx stop
&gt; /etc/init.d/nginx start</pre></p>

	<p>Finally, we want to make sure nginx launches at startup :<br />
<pre class="bash">&gt; sudo update-rc.d nginx defaults</pre></p>

	<p>Now you should be able to load http://yourserver.com/ and see nginx. </p>

	<p>The last thing to do is enable the flv streaming module. You&#8217;ll need to add a rule to your <em>nginx.conf</em> something like the following :<br />
<pre class="bash">location ~ \.flv$ <span style="color: #66cc66;">&#123;</span>
	flv;
	root /path/to/your/flv/files;
<span style="color: #66cc66;">&#125;</span></pre><br />
This will catch any request with a <em>.flv</em> extension, and stream it from the folder <em>/path/to/your/flv/files</em> .</p>

	<p>Done!</p>

]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2010/03/16/compiling-nginx-with-flv-streaming-support-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling and running red5 flash server on OSX</title>
		<link>http://recurser.com/articles/2010/03/16/compiling-and-running-red5-flash-server-on-osx/</link>
		<comments>http://recurser.com/articles/2010/03/16/compiling-and-running-red5-flash-server-on-osx/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 06:04:03 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=504</guid>
		<description><![CDATA[How to get "Red5":http://osflash.org/red5 flash streaming server up and running on OS X.]]></description>
			<content:encoded><![CDATA[	<p>First, you need to make sure you are using java 1.6. I&#8217;m told this method will only work on 64-bit leopard machines, so your mileage may vary. In the finder, browse to /Applications/Utilities and open <em>Java Preferences.app</em> .</p>

	<p>1. Make sure only the <em>Java SE 6</em> 64-bit options are enabled (a word of caution &#8211; Flex Builder doesn&#8217;t work with these settings &#8211; you&#8217;ll need to change them back to use it). <br />
<a href="http://recurser.com/wp-content/uploads/2010/03/JavaPreferences.png"><img src="http://recurser.com/wp-content/uploads/2010/03/JavaPreferences.png" alt="" title="JavaPreferences"  class="aligncenter size-full" /></a></p>

	<p>2. You can check your java version by typing <em>java -version</em> in a terminal &#8211; you should get the following output.<br />
<pre class="bash">&gt; java -version
java version <span style="color: #ff0000;">&quot;1.6.0_17&quot;</span>
Java<span style="color: #66cc66;">&#40;</span>TM<span style="color: #66cc66;">&#41;</span> SE Runtime Environment <span style="color: #66cc66;">&#40;</span>build <span style="color: #cc66cc;">1.6</span>.0_17-b04<span style="color: #cc66cc;">-248</span>-9M3125<span style="color: #66cc66;">&#41;</span>
Java HotSpot<span style="color: #66cc66;">&#40;</span>TM<span style="color: #66cc66;">&#41;</span> <span style="color: #cc66cc;">64</span>-Bit Server VM <span style="color: #66cc66;">&#40;</span>build <span style="color: #cc66cc;">14.3</span>-b01<span style="color: #cc66cc;">-101</span>, mixed mode<span style="color: #66cc66;">&#41;</span></pre></p>

	<p>3. Set JAVA_HOME so it matches your new java version<br />
<pre class="bash">&gt; <span style="color: #000066;">export</span> <span style="color: #0000ff;">JAVA_HOME=</span>/System/Library/Frameworks/JavaVM.framework/Versions/<span style="color: #cc66cc;">1.6</span>/Home</pre></p>

	<p>4. You should now be able to build red5 :<br />
<pre class="bash">&gt; svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5-trunk
&gt; <span style="color: #000066;">cd</span> red5-trunk
&gt; make
ant dist
Buildfile: build.xml
.....
.....
.....
BUILD SUCCESSFUL
Total <span style="color: #b1b100;">time</span>: <span style="color: #cc66cc;">2</span> minutes <span style="color: #cc66cc;">31</span> seconds</pre></p>

	<p>5. Now you should be able to run your newly-built red5 server. Note &#8211; make sure you use the  <em>*.sh</em> files that were created in the <em>dist</em> folder to run it:<br />
<pre class="bash">&gt; <span style="color: #000066;">cd</span> dist
&gt; ./red5.sh
Running on  Darwin
Starting Red5
.....
.....
.....
<span style="color: #66cc66;">&#91;</span>INFO<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span>Launcher:/installer<span style="color: #66cc66;">&#93;</span> org.red5.server.service.Installer - Installer service created</pre></p>

	<p>6. Now you can copy this dist folder to wherever you want your red5 install to live &#8211; eg. <em>/Applications/Red5</em> <pre class="bash">&gt; <span style="color: #000066;">cd</span> ../
&gt; cp -R dist /Applications/Red5</pre></p>

	<p>Once you get all this working, i recommend you <a href="http://wiki.red5.org/wiki/Red5Plugin">install the eclipse red5 plugin</a> , and <a href="http://wiki.red5.org/wiki/Red5Plugin/CreatingRed5Projects">create a red5 eclipse project</a> if you&#8217;re interested in going further.</p>]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2010/03/16/compiling-and-running-red5-flash-server-on-osx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing Flex 4 (Gumbo) SDK on OS X</title>
		<link>http://recurser.com/articles/2010/03/14/installing-flex-4-gumbo-sdk-on-os-x/</link>
		<comments>http://recurser.com/articles/2010/03/14/installing-flex-4-gumbo-sdk-on-os-x/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 00:19:08 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=483</guid>
		<description><![CDATA[How to install and configure the new Flex 4 SDK on OS X.]]></description>
			<content:encoded><![CDATA[	<ul>
		<li> Download the <span class="caps">SDK</span> from the <a href="http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4">Gumbo Downloads</a> page. The file will be called something like &#8216;flex_sdk_4.0.0.xxxxx.zip&#8217;.</li>
		<li> Unzip and move the resulting folder to <em>/Applications/Adobe Flex Builder 3/sdks/</em> and rename it to <em>4.0.0</em></li>
		<li> In Flex Builder, go to Preferences -> Flex -> Installed Flex SDKs. Click the <em>Add&#8230;</em> button and add your new 4.0 <span class="caps">SDK</span> to the list. If you like you can click the checkbox next to the new <span class="caps">SDK</span> and uncheck the others, to enable it by default.<a href="http://recurser.com/wp-content/uploads/2010/03/Flex_Preferences1.png"><img src="http://recurser.com/wp-content/uploads/2010/03/Flex_Preferences1.png" alt="" title="Flex_Preferences"  class="aligncenter size-full wp-image-493" /></a></li>
	</ul>
	<ul>
		<li> To update your project so it uses the new <span class="caps">SDK</span>, go to Project in the Flex Builder top menu, then select Properties -> Flex Compiler, and update the <em>Require Flash Player Version:</em> to <em>10.0.0</em><a href="http://recurser.com/wp-content/uploads/2010/03/Project_Preferences1.png"><img src="http://recurser.com/wp-content/uploads/2010/03/Project_Preferences1.png" alt="" title="Project_Preferences" class="aligncenter size-full wp-image-496" /></a></li>
	</ul>

	<p>You should now be able to use some of the great new stuff from Flex 4, such as the new <a href="http://help.adobe.com/en_US/Flex/4.0/UsingSDK/WSc78f87379113c38b-669905c51221a3b97af-8000.html">VideoPlayer</a> component</p>

	<p><pre class="actionscript">&lt;?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?&gt;
&lt;s:Application
	xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> 
	xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span>&gt;
	
	&lt;s:VideoPlayer 
		source=<span style="color: #ff0000;">&quot;my_movie.flv&quot;</span>
		horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span>
		verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span>
		autoPlay=<span style="color: #ff0000;">&quot;false&quot;</span> /&gt;
	
&lt;/s:Application&gt;</pre></p>]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2010/03/14/installing-flex-4-gumbo-sdk-on-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing git-up on Ubuntu 8.10</title>
		<link>http://recurser.com/articles/2010/02/14/installing-git-up-on-ubuntu-8-10/</link>
		<comments>http://recurser.com/articles/2010/02/14/installing-git-up-on-ubuntu-8-10/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 02:17:53 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Version Control]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=469</guid>
		<description><![CDATA[How to get "git-up":http://github.com/aanand/git-up running properly on Ubuntu 8.10]]></description>
			<content:encoded><![CDATA[	<p>Recently I had a bit of trouble getting <a href="http://github.com/aanand/git-up">git-up</a> to work on Ubuntu (or <a href="http://recurser.com/articles/2010/02/14/updating-rubygems-on-mac-os-x-10-5-leopard/">anywhere else</a> for that matter), so here&#8217;s some of the steps I had to go through.</p>

	<p>Initially ubuntu seems to have <a href="http://rubyforge.org/projects/rubygems/">RubyGems</a> 1.01 and 1.2.0 installed :<br />
<pre class="bash">&gt; gem --version
<span style="color: #cc66cc;">1.2</span><span style="color: #cc66cc;">.0</span>
&gt;/usr/bin/gem1<span style="color: #cc66cc;">.8</span> --version
<span style="color: #cc66cc;">1.2</span><span style="color: #cc66cc;">.0</span>
&gt;/usr/bin/gem1<span style="color: #cc66cc;">.9</span> --version
<span style="color: #cc66cc;">1.0</span><span style="color: #cc66cc;">.1</span></pre></p>

	<p>Unlike <a href="http://recurser.com/articles/2010/02/14/updating-rubygems-on-mac-os-x-10-5-leopard/">installation on OS X</a> , the initial gem install worked fine :</p>

	<p><pre class="bash">&gt; sudo gem install git-up
Successfully installed git-up<span style="color: #cc66cc;">-0.1</span><span style="color: #cc66cc;">.0</span>
<span style="color: #cc66cc;">1</span> gem installed
Installing ri documentation <span style="color: #b1b100;">for</span> git-up<span style="color: #cc66cc;">-0.1</span><span style="color: #cc66cc;">.0</span>...
Installing RDoc documentation <span style="color: #b1b100;">for</span> git-up<span style="color: #cc66cc;">-0.1</span><span style="color: #cc66cc;">.0</span>...</pre></p>

	<p>Trying to actually use it, however, caused a few errors :</p>

	<p><pre class="bash">&gt;  git up
/usr/<span style="color: #000066;">local</span>/lib/site_ruby/<span style="color: #cc66cc;">1.8</span>/rubygems.rb:<span style="color: #cc66cc;">578</span>:<span style="color: #b1b100;">in</span> `report_activate_error<span style="color: #ff0000;">': Could not find RubyGem thoughtbot-shoulda (&gt;= 0) (Gem::LoadError)
        from /usr/local/lib/site_ruby/1.8/rubygems.rb:134:in `activate'</span>
        from /usr/<span style="color: #000066;">local</span>/lib/site_ruby/<span style="color: #cc66cc;">1.8</span>/rubygems.rb:<span style="color: #cc66cc;">158</span>:<span style="color: #b1b100;">in</span> `activate<span style="color: #ff0000;">'
        from /usr/local/lib/site_ruby/1.8/rubygems.rb:157:in `each'</span>
        from /usr/<span style="color: #000066;">local</span>/lib/site_ruby/<span style="color: #cc66cc;">1.8</span>/rubygems.rb:<span style="color: #cc66cc;">157</span>:<span style="color: #b1b100;">in</span> `activate<span style="color: #ff0000;">'
        from /usr/local/lib/site_ruby/1.8/rubygems.rb:49:in `gem'</span>
        from /usr/bin/git-up:<span style="color: #cc66cc;">18</span></pre></p>

	<p>This error persists even after installing shoulda :</p>

	<p><pre class="bash">&gt;  sudo gem install shoulda
Successfully installed shoulda<span style="color: #cc66cc;">-2.10</span><span style="color: #cc66cc;">.3</span>
<span style="color: #cc66cc;">1</span> gem installed
Installing ri documentation <span style="color: #b1b100;">for</span> shoulda<span style="color: #cc66cc;">-2.10</span><span style="color: #cc66cc;">.3</span>...
Installing RDoc documentation <span style="color: #b1b100;">for</span> shoulda<span style="color: #cc66cc;">-2.10</span><span style="color: #cc66cc;">.3</span>...</pre></p>

	<p>After my experience installing it on OS X, i decided the easiest way to move forward was probably to install RubyGems 1.3.1 :</p>

	<p><pre class="bash">&gt; wget http://rubyforge.org/frs/download.php/<span style="color: #cc66cc;">45905</span>/rubygems<span style="color: #cc66cc;">-1.3</span><span style="color: #cc66cc;">.1</span>.tgz
&gt; tar xzf rubygems<span style="color: #cc66cc;">-1.3</span><span style="color: #cc66cc;">.1</span>.tgz
&gt; <span style="color: #000066;">cd</span> rubygems<span style="color: #cc66cc;">-1.3</span><span style="color: #cc66cc;">.1</span>
&gt; sudo ruby setup.rb
.....
RubyGems installed the following executables:
        /usr/bin/gem1<span style="color: #cc66cc;">.8</span>
&nbsp;
If `gem` was installed by a previous RubyGems installation, you may need
to remove it by hand.
&nbsp;
&gt; gem -v
<span style="color: #cc66cc;">1.3</span><span style="color: #cc66cc;">.1</span>
&gt; sudo gem install git-up
Successfully installed git-up<span style="color: #cc66cc;">-0.1</span><span style="color: #cc66cc;">.0</span>
<span style="color: #cc66cc;">1</span> gem installed
Installing ri documentation <span style="color: #b1b100;">for</span> git-up<span style="color: #cc66cc;">-0.1</span><span style="color: #cc66cc;">.0</span>...
Installing RDoc documentation <span style="color: #b1b100;">for</span> git-up<span style="color: #cc66cc;">-0.1</span><span style="color: #cc66cc;">.0</span>...</pre></p>

	<p>After this, trying to run <em>git up</em> caused a bunch of missing dependency errors, and I had to install gems for <em>archive-tar-minitar</em>, <em>nokogiri</em> (which also required installing <em>libxslt-ruby</em>), and <em>rcov</em>. Finally, I got stuck trying to install <em>hoe</em> :</p>

	<p><pre class="bash">&gt; sudo gem install hoe                                                                                                                         <span style="color: #cc66cc;">1</span> ?
ERROR:  Error installing hoe:
        gemcutter requires RubyGems version &gt;= <span style="color: #cc66cc;">1.3</span><span style="color: #cc66cc;">.5</span></pre></p>

	<p>Let&#8217;s try all this again with RubyGems 1.3.5 :</p>

	<p><pre class="bash">&gt; wget http://rubyforge.org/frs/download.php/<span style="color: #cc66cc;">60718</span>/rubygems<span style="color: #cc66cc;">-1.3</span><span style="color: #cc66cc;">.5</span>.tgz
&gt; tar xvzf rubygems<span style="color: #cc66cc;">-1.3</span><span style="color: #cc66cc;">.5</span>.tgz 
&gt; <span style="color: #000066;">cd</span> rubygems<span style="color: #cc66cc;">-1.3</span><span style="color: #cc66cc;">.5</span> 
&gt; sudo ruby setup.rb
RubyGems installed the following executables:
        /usr/bin/gem1<span style="color: #cc66cc;">.8</span>
&gt; gem -v
<span style="color: #cc66cc;">1.3</span><span style="color: #cc66cc;">.5</span>
&gt; sudo gem -v
<span style="color: #cc66cc;">1.3</span><span style="color: #cc66cc;">.5</span>
&gt; sudo gem install git-up
Successfully installed git-up<span style="color: #cc66cc;">-0.1</span><span style="color: #cc66cc;">.0</span>
<span style="color: #cc66cc;">1</span> gem installed
Installing ri documentation <span style="color: #b1b100;">for</span> git-up<span style="color: #cc66cc;">-0.1</span><span style="color: #cc66cc;">.0</span>...
Installing RDoc documentation <span style="color: #b1b100;">for</span> git-up<span style="color: #cc66cc;">-0.1</span><span style="color: #cc66cc;">.0</span>...
&gt; git up
master              up to date</pre></p>

	<p>Finally with RubyGems 1.3.5, git-up works fine, with no dependency issues or missing gems.</p>]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2010/02/14/installing-git-up-on-ubuntu-8-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updating RubyGems on Mac OS X 10.5 Leopard</title>
		<link>http://recurser.com/articles/2010/02/14/updating-rubygems-on-mac-os-x-10-5-leopard/</link>
		<comments>http://recurser.com/articles/2010/02/14/updating-rubygems-on-mac-os-x-10-5-leopard/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 01:34:47 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Version Control]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=465</guid>
		<description><![CDATA[How to update "RubyGems":http://rubyforge.org/projects/rubygems/ from v1.0.1 to v1.3.5 on OS X]]></description>
			<content:encoded><![CDATA[	<p>I haven&#8217;t used ruby for a while, but recently wanted to try out <a href="http://github.com/aanand/git-up">git-up</a> on <span class="caps">OSX</span>. According to the <a href="http://github.com/aanand/git-up/blob/master/README.md">instructions</a> , a simple <em>gem install git-up</em> should work :</p>

	<p><pre class="bash">&gt; sudo gem install git-up
Updating metadata <span style="color: #b1b100;">for</span> <span style="color: #cc66cc;">1</span> gems from http://gems.rubyforge.org
.
<span style="color: #000066;">complete</span>
ERROR:  could not find git-up locally or <span style="color: #b1b100;">in</span> a repository</pre></p>

	<p>I assume this is something to do with gem hosting moving to github or something&#8230; I haven&#8217;t really been following ruby for a year or so so I&#8217;m not sure exactly what&#8217;s going on. It seems i&#8217;m running a pretty old version of <a href="http://rubyforge.org/projects/rubygems/">RubyGems</a> , so I tried to update :</p>

	<p><pre class="bash">&gt; gem --version
<span style="color: #cc66cc;">1.0</span><span style="color: #cc66cc;">.1</span>
&gt; sudo gem update
Updating installed gems...
Updating metadata <span style="color: #b1b100;">for</span> <span style="color: #cc66cc;">1</span> gems from http://gems.rubyforge.org
.
<span style="color: #000066;">complete</span>
Nothing to update</pre></p>

	<p>After a little googling, the correct command turned out to be the following :<br />
<pre class="bash">&gt; sudo gem update --system
Updating RubyGems...
Updating metadata <span style="color: #b1b100;">for</span> <span style="color: #cc66cc;">1</span> gems from http://gems.rubyforge.org
.
<span style="color: #000066;">complete</span>
Attempting remote update of rubygems-update
Successfully installed rubygems-update<span style="color: #cc66cc;">-1.3</span><span style="color: #cc66cc;">.5</span>
<span style="color: #cc66cc;">1</span> gem installed
Installing ri documentation <span style="color: #b1b100;">for</span> rubygems-update<span style="color: #cc66cc;">-1.3</span><span style="color: #cc66cc;">.5</span>...
Installing RDoc documentation <span style="color: #b1b100;">for</span> rubygems-update<span style="color: #cc66cc;">-1.3</span><span style="color: #cc66cc;">.5</span>...
Could not find main page README
Could not find main page README
Could not find main page README
Could not find main page README
Updating version of RubyGems to <span style="color: #cc66cc;">1.3</span><span style="color: #cc66cc;">.5</span>
Installing RubyGems <span style="color: #cc66cc;">1.3</span><span style="color: #cc66cc;">.5</span>
RubyGems <span style="color: #cc66cc;">1.3</span><span style="color: #cc66cc;">.5</span> installed
&nbsp;
=== <span style="color: #cc66cc;">1.3</span><span style="color: #cc66cc;">.5</span> / <span style="color: #cc66cc;">2009</span><span style="color: #cc66cc;">-07</span><span style="color: #cc66cc;">-21</span>
&nbsp;
Bug fixes:
&nbsp;
* Fix use of prerelease gems.
* Gem.bin_path no longer escapes path with spaces. Bug <span style="color: #808080; font-style: italic;">#25935 and #26458.</span>
&nbsp;
Deprecation Notices:
&nbsp;
* Bulk index update is no longer supported <span style="color: #66cc66;">&#40;</span>the code currently remains, but not
  the tests<span style="color: #66cc66;">&#41;</span>
* Gem::manage_gems was removed <span style="color: #b1b100;">in</span> <span style="color: #cc66cc;">1.3</span><span style="color: #cc66cc;">.3</span>.
* Time::today was removed <span style="color: #b1b100;">in</span> <span style="color: #cc66cc;">1.3</span><span style="color: #cc66cc;">.3</span>.
&nbsp;
&nbsp;
------------------------------------------------------------------------------
&nbsp;
RubyGems installed the following executables:
        /System/Library/Frameworks/Ruby.framework/Versions/<span style="color: #cc66cc;">1.8</span>/usr/bin/gem
&nbsp;
RubyGems system software updated</pre></p>

	<p>Now with the more recent version, <a href="http://github.com/aanand/git-up">git-up</a> installs fine :</p>

	<p><pre class="bash">&gt; gem --version
<span style="color: #cc66cc;">1.3</span><span style="color: #cc66cc;">.5</span>
&gt; sudo gem install git-up
Successfully installed colored<span style="color: #cc66cc;">-1.2</span>
Successfully installed diff-lcs<span style="color: #cc66cc;">-1.1</span><span style="color: #cc66cc;">.2</span>
Successfully installed grit<span style="color: #cc66cc;">-2.0</span><span style="color: #cc66cc;">.0</span>
Successfully installed git-up<span style="color: #cc66cc;">-0.1</span><span style="color: #cc66cc;">.0</span>
<span style="color: #cc66cc;">4</span> gems installed
Installing ri documentation <span style="color: #b1b100;">for</span> colored<span style="color: #cc66cc;">-1.2</span>...
Installing ri documentation <span style="color: #b1b100;">for</span> diff-lcs<span style="color: #cc66cc;">-1.1</span><span style="color: #cc66cc;">.2</span>...
Installing ri documentation <span style="color: #b1b100;">for</span> grit<span style="color: #cc66cc;">-2.0</span><span style="color: #cc66cc;">.0</span>...
Installing ri documentation <span style="color: #b1b100;">for</span> git-up<span style="color: #cc66cc;">-0.1</span><span style="color: #cc66cc;">.0</span>...
Installing RDoc documentation <span style="color: #b1b100;">for</span> colored<span style="color: #cc66cc;">-1.2</span>...
Installing RDoc documentation <span style="color: #b1b100;">for</span> diff-lcs<span style="color: #cc66cc;">-1.1</span><span style="color: #cc66cc;">.2</span>...
Installing RDoc documentation <span style="color: #b1b100;">for</span> grit<span style="color: #cc66cc;">-2.0</span><span style="color: #cc66cc;">.0</span>...
Installing RDoc documentation <span style="color: #b1b100;">for</span> git-up<span style="color: #cc66cc;">-0.1</span><span style="color: #cc66cc;">.0</span>...</pre></p>]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2010/02/14/updating-rubygems-on-mac-os-x-10-5-leopard/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>nginx error &#8211; 413 Request Entity Too Large</title>
		<link>http://recurser.com/articles/2009/11/18/nginx-error-413-request-entity-too-large/</link>
		<comments>http://recurser.com/articles/2009/11/18/nginx-error-413-request-entity-too-large/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 00:12:06 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=449</guid>
		<description><![CDATA[How to increase the allowed file upload size in "Nginx":http://nginx.net/, and stop _413 Request Entity Too Large_ errors.]]></description>
			<content:encoded><![CDATA[	<p>If you&#8217;re getting <em>413 Request Entity Too Large</em> errors trying to upload with <a href="http://nginx.net/">Nginx</a> , you need to increase the size limit in <em>nginx.conf</em> . Add &#8216;client_max_body_size xxM&#8217; inside the <em>server</em> section, where <em>xx</em> is the size (in megabytes) that you want to allow.<br />
<pre class="c">http <span style="color: #66cc66;">&#123;</span>
    include       mime.<span style="color: #202020;">types</span>;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  <span style="color: #cc66cc;">65</span>;
&nbsp;
    server <span style="color: #66cc66;">&#123;</span>
        client_max_body_size 20M;
        listen       <span style="color: #cc66cc;">80</span>;
        server_name  localhost;
&nbsp;
        <span style="color: #339933;"># Main location</span>
        location / <span style="color: #66cc66;">&#123;</span>
            proxy_pass         http:<span style="color: #808080; font-style: italic;">//127.0.0.1:8000/;</span>
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></p>]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2009/11/18/nginx-error-413-request-entity-too-large/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Makefile &#8211; missing separator. Stop.</title>
		<link>http://recurser.com/articles/2009/11/12/makefile-missing-separator-stop/</link>
		<comments>http://recurser.com/articles/2009/11/12/makefile-missing-separator-stop/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 01:11:54 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=446</guid>
		<description><![CDATA[How to fix _missing separator_ errors in Makefiles]]></description>
			<content:encoded><![CDATA[	<p>If you&#8217;re getting <em>missing separator</em> errors in your makefile, similar to the following :</p>

	<p><pre class="bash">Makefile:<span style="color: #cc66cc;">22</span>: *** missing separator.  Stop.</pre></p>

	<p>&#8230; make sure you are using real tabs instead of spaces. A global search and replace for four-spaces should fix things up.</p>]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2009/11/12/makefile-missing-separator-stop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NoReverseMatch : custom registration templates break django unit tests</title>
		<link>http://recurser.com/articles/2009/11/10/noreversematch-custom-registration-templates-break-django-unit-tests/</link>
		<comments>http://recurser.com/articles/2009/11/10/noreversematch-custom-registration-templates-break-django-unit-tests/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 09:11:31 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=439</guid>
		<description><![CDATA[How to fix _NoReverseMatch_ errors in the "django":http://www.djangoproject.com/ auth and "django-registration":http://bitbucket.org/ubernostrum/django-registration/ test suites when you are using customized login and registration templates.]]></description>
			<content:encoded><![CDATA[	<p>I&#8217;ve over-ridden several of the built-in <a href="http://www.djangoproject.com/">django</a> auth and <a href="http://bitbucket.org/ubernostrum/django-registration/">django-registration</a> templates so I can have my own custom-styled login and registration pages. This all worked fine until i tried to run the built-in django and django_registration test suites, when everything fell apart :</p>

	<p><pre class="python">======================================================================
ERROR: test_confirm_different_passwords <span style="color: black;">&#40;</span>django.<span style="color: black;">contrib</span>.<span style="color: black;">auth</span>.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">PasswordResetTest</span><span style="color: black;">&#41;</span>
----------------------------------------------------------------------
<span style="color: #dc143c;">Traceback</span> <span style="color: black;">&#40;</span>most recent call last<span style="color: black;">&#41;</span>:
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/contrib/auth/tests/views.py&quot;</span>, line <span style="color: #ff4500;">124</span>, <span style="color: #ff7700;font-weight:bold;">in</span> test_confirm_different_passwords
    <span style="color: #483d8b;">'new_password2'</span>:<span style="color: #483d8b;">' x'</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/test/client.py&quot;</span>, line <span style="color: #ff4500;">313</span>, <span style="color: #ff7700;font-weight:bold;">in</span> post
    response = <span style="color: #008000;">self</span>.<span style="color: black;">request</span><span style="color: black;">&#40;</span>**r<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/core/handlers/base.py&quot;</span>, line <span style="color: #ff4500;">92</span>, <span style="color: #ff7700;font-weight:bold;">in</span> get_response
    response = callback<span style="color: black;">&#40;</span>request, *callback_args, **callback_kwargs<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/contrib/auth/views.py&quot;</span>, line <span style="color: #ff4500;">141</span>, <span style="color: #ff7700;font-weight:bold;">in</span> password_reset_confirm
    <span style="color: #ff7700;font-weight:bold;">return</span> render_to_response<span style="color: black;">&#40;</span>template_name, context_instance=context_instance<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/shortcuts/__init__.py&quot;</span>, line <span style="color: #ff4500;">20</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render_to_response
    <span style="color: #ff7700;font-weight:bold;">return</span> HttpResponse<span style="color: black;">&#40;</span>loader.<span style="color: black;">render_to_string</span><span style="color: black;">&#40;</span>*args, **kwargs<span style="color: black;">&#41;</span>, **httpresponse_kwargs<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/loader.py&quot;</span>, line <span style="color: #ff4500;">108</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render_to_string
    <span style="color: #ff7700;font-weight:bold;">return</span> t.<span style="color: black;">render</span><span style="color: black;">&#40;</span>context_instance<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/test/utils.py&quot;</span>, line <span style="color: #ff4500;">29</span>, <span style="color: #ff7700;font-weight:bold;">in</span> instrumented_test_render
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">nodelist</span>.<span style="color: black;">render</span><span style="color: black;">&#40;</span>context<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/__init__.py&quot;</span>, line <span style="color: #ff4500;">779</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render
    bits.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">render_node</span><span style="color: black;">&#40;</span>node, context<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/__init__.py&quot;</span>, line <span style="color: #ff4500;">792</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render_node
    <span style="color: #ff7700;font-weight:bold;">return</span> node.<span style="color: black;">render</span><span style="color: black;">&#40;</span>context<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/loader_tags.py&quot;</span>, line <span style="color: #ff4500;">97</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render
    <span style="color: #ff7700;font-weight:bold;">return</span> compiled_parent.<span style="color: black;">render</span><span style="color: black;">&#40;</span>context<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/test/utils.py&quot;</span>, line <span style="color: #ff4500;">29</span>, <span style="color: #ff7700;font-weight:bold;">in</span> instrumented_test_render
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">nodelist</span>.<span style="color: black;">render</span><span style="color: black;">&#40;</span>context<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/__init__.py&quot;</span>, line <span style="color: #ff4500;">779</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render
    bits.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">render_node</span><span style="color: black;">&#40;</span>node, context<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/__init__.py&quot;</span>, line <span style="color: #ff4500;">792</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render_node
    <span style="color: #ff7700;font-weight:bold;">return</span> node.<span style="color: black;">render</span><span style="color: black;">&#40;</span>context<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/__init__.py&quot;</span>, line <span style="color: #ff4500;">946</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render
    autoescape=context.<span style="color: black;">autoescape</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/__init__.py&quot;</span>, line <span style="color: #ff4500;">779</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render
    bits.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">render_node</span><span style="color: black;">&#40;</span>node, context<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/__init__.py&quot;</span>, line <span style="color: #ff4500;">792</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render_node
    <span style="color: #ff7700;font-weight:bold;">return</span> node.<span style="color: black;">render</span><span style="color: black;">&#40;</span>context<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/loader_tags.py&quot;</span>, line <span style="color: #ff4500;">24</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render
    result = <span style="color: #008000;">self</span>.<span style="color: black;">nodelist</span>.<span style="color: black;">render</span><span style="color: black;">&#40;</span>context<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/__init__.py&quot;</span>, line <span style="color: #ff4500;">779</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render
    bits.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">render_node</span><span style="color: black;">&#40;</span>node, context<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/__init__.py&quot;</span>, line <span style="color: #ff4500;">792</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render_node
    <span style="color: #ff7700;font-weight:bold;">return</span> node.<span style="color: black;">render</span><span style="color: black;">&#40;</span>context<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/defaulttags.py&quot;</span>, line <span style="color: #ff4500;">244</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">nodelist_false</span>.<span style="color: black;">render</span><span style="color: black;">&#40;</span>context<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/__init__.py&quot;</span>, line <span style="color: #ff4500;">779</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render
    bits.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">render_node</span><span style="color: black;">&#40;</span>node, context<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/__init__.py&quot;</span>, line <span style="color: #ff4500;">792</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render_node
    <span style="color: #ff7700;font-weight:bold;">return</span> node.<span style="color: black;">render</span><span style="color: black;">&#40;</span>context<span style="color: black;">&#41;</span>
  <span style="color: #008000;">File</span> <span style="color: #483d8b;">&quot;/Users/dave/Documents/Code/python/loudgallery/django/template/defaulttags.py&quot;</span>, line <span style="color: #ff4500;">382</span>, <span style="color: #ff7700;font-weight:bold;">in</span> render
    <span style="color: #ff7700;font-weight:bold;">raise</span> e
NoReverseMatch: Reverse <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #483d8b;">'&lt;function index at 0x1ca9c30&gt;'</span> with arguments <span style="color: #483d8b;">'()'</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #dc143c;">keyword</span> arguments <span style="color: #483d8b;">'{}'</span> <span style="color: #ff7700;font-weight:bold;">not</span> found.</pre></p>

	<p>There were quite a few more of these, including :</p>

	<p><pre class="python">test_activation_success_url <span style="color: black;">&#40;</span>registration.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">RegistrationViewTests</span><span style="color: black;">&#41;</span> ... <span style="color: black;">ERROR</span>
test_activation_template_name <span style="color: black;">&#40;</span>registration.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">RegistrationViewTests</span><span style="color: black;">&#41;</span> ... <span style="color: black;">ERROR</span>
test_registration_disallowed_url <span style="color: black;">&#40;</span>registration.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">RegistrationViewTests</span><span style="color: black;">&#41;</span> ... <span style="color: black;">ERROR</span>
test_registration_extra_context <span style="color: black;">&#40;</span>registration.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">RegistrationViewTests</span><span style="color: black;">&#41;</span> ... <span style="color: black;">ERROR</span>
test_registration_success_url <span style="color: black;">&#40;</span>registration.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">RegistrationViewTests</span><span style="color: black;">&#41;</span> ... <span style="color: black;">ERROR</span>
test_registration_template_name <span style="color: black;">&#40;</span>registration.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">RegistrationViewTests</span><span style="color: black;">&#41;</span> ... <span style="color: black;">FAIL</span>
test_registration_view_closed <span style="color: black;">&#40;</span>registration.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">RegistrationViewTests</span><span style="color: black;">&#41;</span> ... <span style="color: black;">ERROR</span>
test_registration_view_failure <span style="color: black;">&#40;</span>registration.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">RegistrationViewTests</span><span style="color: black;">&#41;</span> ... <span style="color: black;">FAIL</span>
test_registration_view_initial <span style="color: black;">&#40;</span>registration.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">RegistrationViewTests</span><span style="color: black;">&#41;</span> ... <span style="color: black;">FAIL</span>
test_registration_view_success <span style="color: black;">&#40;</span>registration.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">RegistrationViewTests</span><span style="color: black;">&#41;</span> ... <span style="color: black;">ERROR</span>
test_valid_activation <span style="color: black;">&#40;</span>registration.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">RegistrationViewTests</span><span style="color: black;">&#41;</span> ... <span style="color: black;">ERROR</span>
...
<span style="color: black;">test_confirm_complete</span> <span style="color: black;">&#40;</span>django.<span style="color: black;">contrib</span>.<span style="color: black;">auth</span>.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">PasswordResetTest</span><span style="color: black;">&#41;</span> ... <span style="color: black;">FAIL</span>
test_confirm_invalid <span style="color: black;">&#40;</span>django.<span style="color: black;">contrib</span>.<span style="color: black;">auth</span>.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">PasswordResetTest</span><span style="color: black;">&#41;</span> ... <span style="color: black;">FAIL</span>
test_confirm_valid <span style="color: black;">&#40;</span>django.<span style="color: black;">contrib</span>.<span style="color: black;">auth</span>.<span style="color: black;">tests</span>.<span style="color: black;">views</span>.<span style="color: black;">PasswordResetTest</span><span style="color: black;">&#41;</span> ... <span style="color: black;">FAIL</span>
...</pre><br />
&#8230; and so on. After some investigation, it seems these errors occur because I have links to my own views in these custom templates, for example :</p>

	<p><pre class="python">&lt;a href=<span style="color: #483d8b;">&quot;{% url home.views.index}&quot;</span>&gt;Cancel&lt;/a&gt;</pre></p>

	<p>For whatever reason, django doesn&#8217;t include my project&#8217;s various <em>urls.py</em> files when it runs its tests, so it doesn&#8217;t know anything about my URLs. After a few hours I found <a href="http://www.mail-archive.com/django-users@googlegroups.com/msg78790.html">this solution</a> , which is a little hack-y, but seems to work. Simply add <em>as xxxx</em> at the end of your url call, and output the url as a variable using (for example) {{ index }} . This seems to suppress the errors :</p>

	<p><pre class="python">&lt;a href=<span style="color: #483d8b;">&quot;{% url home.views.index as index %}{{ index }}&quot;</span>&gt;Cancel&lt;/a&gt;</pre></p>]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2009/11/10/noreversematch-custom-registration-templates-break-django-unit-tests/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sending Django email with Gmail</title>
		<link>http://recurser.com/articles/2009/10/16/sending-django-email-with-gmail/</link>
		<comments>http://recurser.com/articles/2009/10/16/sending-django-email-with-gmail/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 06:02:27 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=437</guid>
		<description><![CDATA[How to set up your "django":http://www.djangoproject.com/ application so email is sent through "Gmail":http://mail.google.com/.]]></description>
			<content:encoded><![CDATA[	<p>After spending a few hours struggling to get <a href="http://www.postfix.org/">postfix</a> to work with <a href="http://www.djangoproject.com/">django</a> on my local dev machine, I gave up and decided to use <a href="http://mail.google.com/">Gmail</a> . To do it, add the following to your <em>settings.py</em> :</p>

	<p><pre class="python">EMAIL_USE_TLS = <span style="color: #008000;">True</span>
EMAIL_HOST = <span style="color: #483d8b;">'smtp.gmail.com'</span>
EMAIL_HOST_USER = username@gmail.<span style="color: black;">com</span><span style="color: #483d8b;">'
EMAIL_HOST_PASSWORD = '</span>password<span style="color: #483d8b;">'
EMAIL_PORT = 587 </span></pre></p>

	<p>(Obviously, substituting your own email and password)</p>

	<p>You can also use an address at your own domain if you set the <span class="caps">DNS</span> records to use google apps.</p>

	<p>To test if it&#8217;s working :</p>

	<p><pre class="python">&gt; python manage.<span style="color: black;">py</span> shell
&gt;&gt;&gt; <span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">core</span>.<span style="color: black;">mail</span> <span style="color: #ff7700;font-weight:bold;">import</span> EmailMessage
&gt;&gt;&gt; <span style="color: #dc143c;">email</span> = EmailMessage<span style="color: black;">&#40;</span><span style="color: #483d8b;">'Mail Test'</span>, <span style="color: #483d8b;">'This is a test'</span>, to=<span style="color: black;">&#91;</span><span style="color: #483d8b;">'test@your-address.com'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&gt;&gt;&gt; <span style="color: #dc143c;">email</span>.<span style="color: black;">send</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></p>]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2009/10/16/sending-django-email-with-gmail/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Compiling mysql-python on OS X leopard</title>
		<link>http://recurser.com/articles/2009/08/18/compiling-mysql-python-on-os-x-leopard/</link>
		<comments>http://recurser.com/articles/2009/08/18/compiling-mysql-python-on-os-x-leopard/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 11:04:32 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=416</guid>
		<description><![CDATA[How to get around a few of the problems you may encounter trying to install  install "mysql-python":http://sourceforge.net/projects/mysql-python/ bindings on OS X Leopard.]]></description>
			<content:encoded><![CDATA[	<p>I&#8217;ve just finished trying to install <a href="http://sourceforge.net/projects/mysql-python/">mysql-python</a> on <span class="caps">OSX</span> Leopard, and had quite a few problems. This is the procedure that finally ended up working for me.</p>

	<p>First, download mysql-python from <a href="http://downloads.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3c1.tar.gz">here</a> .<br />
Unzip and try to build it :<br />
<pre class="bash">&gt; tar xvzf MySQL-python<span style="color: #cc66cc;">-1.2</span>.3c1.tar.gz
&gt; <span style="color: #000066;">cd</span> MySQL-python<span style="color: #cc66cc;">-1.2</span>.3c1
&gt; sudo python setup.py build</pre></p>

	<p>If the build works, you&#8217;re in luck&#8230; you simply need to install it :<br />
<pre class="bash">&gt; sudo python setup.py install</pre></p>

	<p>More than likely though, it isn&#8217;t going to work :) At first, i got an error about _LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)_ :<br />
<pre class="bash">running buildrunning build_py
copying MySQLdb/release.py -&gt; build/lib.macosx<span style="color: #cc66cc;">-10.5</span>-i386<span style="color: #cc66cc;">-2.5</span>/MySQLdb
running build_ext
building <span style="color: #ff0000;">'_mysql'</span> extension
/usr/bin/gcc<span style="color: #cc66cc;">-4.0</span> -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -<span style="color: #0000ff;">Dversion_info=</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">3</span>,<span style="color: #ff0000;">'gamma'</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> -<span style="color: #0000ff;">D__version__=</span><span style="color: #cc66cc;">1.2</span>.3c1 -I/usr/<span style="color: #000066;">local</span>/mysql<span style="color: #cc66cc;">-5.1</span><span style="color: #cc66cc;">.30</span>-osx10<span style="color: #cc66cc;">.5</span>-x86_64/include -I/opt/<span style="color: #000066;">local</span>/Library/Frameworks/Python.framework/Versions/<span style="color: #cc66cc;">2.5</span>/include/python2<span style="color: #cc66cc;">.5</span> -c _mysql.c -o build/temp.macosx<span style="color: #cc66cc;">-10.5</span>-i386<span style="color: #cc66cc;">-2.5</span>/_mysql.o -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL
In file included from /opt/<span style="color: #000066;">local</span>/Library/Frameworks/Python.framework/Versions/<span style="color: #cc66cc;">2.5</span>/include/python2<span style="color: #cc66cc;">.5</span>/Python.h:<span style="color: #cc66cc;">57</span>,
                 from pymemcompat.h:<span style="color: #cc66cc;">10</span>,
                 from _mysql.c:<span style="color: #cc66cc;">29</span>:
/opt/<span style="color: #000066;">local</span>/Library/Frameworks/Python.framework/Versions/<span style="color: #cc66cc;">2.5</span>/include/python2<span style="color: #cc66cc;">.5</span>/pyport.h:<span style="color: #cc66cc;">761</span>:<span style="color: #cc66cc;">2</span>: error: <span style="color: #808080; font-style: italic;">#error &quot;LONG_BIT definition appears wrong for platform (bad gcc/glibc config?).&quot;</span>
In file included from _mysql.c:<span style="color: #cc66cc;">36</span>:
/usr/<span style="color: #000066;">local</span>/mysql<span style="color: #cc66cc;">-5.1</span><span style="color: #cc66cc;">.30</span>-osx10<span style="color: #cc66cc;">.5</span>-x86_64/include/my_config.h:<span style="color: #cc66cc;">1104</span>:<span style="color: #cc66cc;">1</span>: warning: <span style="color: #ff0000;">&quot;SIZEOF_LONG&quot;</span> redefined
In file included from /opt/<span style="color: #000066;">local</span>/Library/Frameworks/Python.framework/Versions/<span style="color: #cc66cc;">2.5</span>/include/python2<span style="color: #cc66cc;">.5</span>/Python.h:<span style="color: #cc66cc;">8</span>,
                 from pymemcompat.h:<span style="color: #cc66cc;">10</span>,
                 from _mysql.c:<span style="color: #cc66cc;">29</span>:
/opt/<span style="color: #000066;">local</span>/Library/Frameworks/Python.framework/Versions/<span style="color: #cc66cc;">2.5</span>/include/python2<span style="color: #cc66cc;">.5</span>/pyconfig.h:<span style="color: #cc66cc;">814</span>:<span style="color: #cc66cc;">1</span>: warning: this is the location of the previous definition
error: <span style="color: #000066;">command</span> <span style="color: #ff0000;">'/usr/bin/gcc-4.0'</span> failed with <span style="color: #000066;">exit</span> status <span style="color: #cc66cc;">1</span></pre></p>

	<p>To get around this, edit the file mentioned in the error ( /opt/local/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/pyport.h ) and comment out the line mentioned in the error (line 761 in the current version) :</p>

	<p><pre class="c"><span style="color: #808080; font-style: italic;">/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent
 * 32-bit platforms using gcc.  We try to catch that here at compile-time
 * rather than waiting for integer multiplication to trigger bogus
 * overflows.
 */</span>
<span style="color: #808080; font-style: italic;">/*#error &quot;LONG_BIT definition appears wrong for platform (bad gcc/glibc config?).&quot;*/</span></pre></p>

	<p>At this point, hopefully you can build and install without problems :<br />
<pre class="bash">&gt; sudo python setup.py build
&gt; sudo python setup.py install</pre></p>

	<p>Even after i managed to install it, i continued to get the following error :<br />
<pre class="bash">django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dynamic module does not define init <span style="color: #b1b100;">function</span> <span style="color: #66cc66;">&#40;</span>init_mysql<span style="color: #66cc66;">&#41;</span></pre><br />
After a bit of digging around, it turns out that this is caused by running a 32-bit version of python alongside a 64-bit version of MySQL. </p>

	<p>We need to uninstall the 64-bit version first. I found some great instructions on <a href="http://akrabat.com/2008/09/11/uninstalling-mysql-on-mac-os-x-leopard/">akrabat.com</a> :</p>

	<p><pre class="php">To uninstall <a href="http://www.php.net/mysql"><span style="color: #000066;">MySQL</span></a> and completely remove it from you Mac <span style="color: #b1b100;">do</span> the following:
&nbsp;
    * sudo rm /usr/local/<a href="http://www.php.net/mysql"><span style="color: #000066;">mysql</span></a>
    * sudo rm -rf /usr/local/<a href="http://www.php.net/mysql"><span style="color: #000066;">mysql</span></a>*
    * sudo rm -rf /Library/StartupItems/MySQLCOM
    * sudo rm -rf /Library/PreferencePanes/My*
    * edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
    * sudo rm -rf /Library/Receipts/<a href="http://www.php.net/mysql"><span style="color: #000066;">mysql</span></a>*
    * sudo rm -rf /Library/Receipts/<a href="http://www.php.net/mysql"><span style="color: #000066;">MySQL</span></a>*
&nbsp;
The last two lines are particularly important <span style="color: #b1b100;">as</span> otherwise, you can<span style="color: #ff0000;">'t install an older version of MySQL even though you think that you'</span>ve completely deleted the newer version!</pre></p>

	<p>Once this is done, download and install the <em>Mac OS X 10.5 (x86)</em> version from the mysql site (make sure you don&#8217;t get the x86_64 version again!), and with a bit of luck everything should be working.</p>]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2009/08/18/compiling-mysql-python-on-os-x-leopard/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>&#8216;Hello World&#8217; with Scala and Lift on OSX</title>
		<link>http://recurser.com/articles/2009/08/17/hello-world-with-scala-and-lift-on-osx/</link>
		<comments>http://recurser.com/articles/2009/08/17/hello-world-with-scala-and-lift-on-osx/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 18:14:48 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=404</guid>
		<description><![CDATA[How to install "Scala":http://www.scala-lang.org/ and "Lift":http://liftweb.net/ on OS X, and create a simple sample project.]]></description>
			<content:encoded><![CDATA[	<p>Obviously we&#8217;re going to need scala before we can do anything useful; the easiest way to install it is via <a href="http://www.macports.org/">macports</a> . We&#8217;re also going to need maven.<br />
<pre class="bash">&gt; sudo port install scala  
&gt; sudo port install maven2</pre><br />
Scala seems to have moved their repository to <a href="http://github.com/dpp/liftweb/tree/master">github</a> , and the old <a href="http://code.google.com/p/liftweb/">google code repository</a> no longer works. Assuming you have <a href="http://git-scm.com/">git</a> installed (if not, there&#8217;s an <a href="http://code.google.com/p/git-osx-installer/downloads/list?can=3">OS X installer here</a> ) :<br />
<pre class="bash">&gt; mkdir -p Documents/code/scala
&gt; <span style="color: #000066;">cd</span> Documents/code/scala
&gt; git clone git://github.com/dpp/liftweb.git
&gt; <span style="color: #000066;">cd</span> liftweb
&gt;  mvn clean:clean install</pre><br />
The <em>mvn install</em> may take quite a while.</p>

	<p>At this point i got an error :<br />
<pre class="java">Required goal not found: org.<span style="color: #006600;">apache</span>.<span style="color: #006600;">maven</span>.<span style="color: #006600;">plugins</span>:maven-archetype-plugin:jar in org.<span style="color: #006600;">apache</span>.<span style="color: #006600;">maven</span>.<span style="color: #006600;">plugins</span>:maven-archetype-plugin:<span style="color: #cc66cc;">1.0</span>-alpha<span style="color: #cc66cc;">-7</span></pre><br />
&#8230; which i think might have been because <a href="http://www.obdev.at/products/littlesnitch/index.html">Little Snitch</a> blocked a request or something&#8230; I ran <em>mvn clean:clean install</em> again and after a few complaints from Little Snitch, success :<br />
<pre class="java"><span style="color: #66cc66;">&#91;</span>INFO<span style="color: #66cc66;">&#93;</span> ------------------------------------------------------------------------
<span style="color: #66cc66;">&#91;</span>INFO<span style="color: #66cc66;">&#93;</span> BUILD SUCCESSFUL
<span style="color: #66cc66;">&#91;</span>INFO<span style="color: #66cc66;">&#93;</span> ------------------------------------------------------------------------
<span style="color: #66cc66;">&#91;</span>INFO<span style="color: #66cc66;">&#93;</span> Total time: <span style="color: #cc66cc;">7</span> minutes <span style="color: #cc66cc;">50</span> seconds
<span style="color: #66cc66;">&#91;</span>INFO<span style="color: #66cc66;">&#93;</span> Finished at: Tue Aug <span style="color: #cc66cc;">18</span> <span style="color: #cc66cc;">03</span>:<span style="color: #cc66cc;">47</span>:<span style="color: #cc66cc;">19</span> JST <span style="color: #cc66cc;">2009</span>
<span style="color: #66cc66;">&#91;</span>INFO<span style="color: #66cc66;">&#93;</span> <span style="color: #000000; font-weight: bold;">Final</span> Memory: 50M/63M
<span style="color: #66cc66;">&#91;</span>INFO<span style="color: #66cc66;">&#93;</span> ------------------------------------------------------------------------
mvn clean:clean install  <span style="color: #cc66cc;">360</span>.40s user <span style="color: #cc66cc;">51</span>.08s system <span style="color: #cc66cc;">87</span>% cpu <span style="color: #cc66cc;">7</span>:<span style="color: #cc66cc;">50.98</span> total</pre></p>

	<p>Next, it&#8217;s time to create our new project :<br />
<pre class="bash">&gt; <span style="color: #000066;">cd</span> ..
&gt; mvn archetype:create -U  \
 -<span style="color: #0000ff;">DarchetypeGroupId=</span>net.liftweb                             \
 -<span style="color: #0000ff;">DarchetypeArtifactId=</span>lift-archetype-basic                 \
 -<span style="color: #0000ff;">DarchetypeVersion=</span><span style="color: #cc66cc;">1.0</span>                            \
 -<span style="color: #0000ff;">DremoteRepositories=</span>http://scala-tools.org/repo-releases  \
 -<span style="color: #0000ff;">DgroupId=</span>net.liftweb.hello -<span style="color: #0000ff;">DartifactId=</span>hello-lift</pre><br />
This should create a <em>hello-lift</em> folder with your new application in it. There are <a href="http://wiki.liftweb.net/index.php/Archetypes">several archetypes available</a> &#8211; this example uses <em>lift-archetype-basic</em>, which provides basic database support and a basic stylesheet. To run it :<br />
<pre class="bash">&gt; <span style="color: #000066;">cd</span> hello-lift/
&gt; mvn install jetty:run</pre><br />
&#8230; and point your browser at <a href="http://localhost:8080/">http://localhost:8080/</a> , and you should be in business!</p>

	<p><a href="/wp-content/uploads/2009/08/lift-basic.png" target="_blank"><img src="http://recurser.com/wp-content/uploads/2009/08/lift-basic-300x131.png" alt="lift-basic" title="lift-basic" width="300" height="131" class="aligncenter size-medium wp-image-412" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2009/08/17/hello-world-with-scala-and-lift-on-osx/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>mysql select random row with join</title>
		<link>http://recurser.com/articles/2009/08/11/mysql-select-random-row-with-join/</link>
		<comments>http://recurser.com/articles/2009/08/11/mysql-select-random-row-with-join/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 17:27:14 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=330</guid>
		<description><![CDATA[A couple of attempts to select random rows via a join in MySQL.]]></description>
			<content:encoded><![CDATA[	<p>I have a <em>users</em> table and an <em>assets</em> (basically just images) table, and I want to select and display a random <em>asset</em> for each <em>user</em>. I want to show a list of users, with a random thumbnail for each user from their assets.</p>

	<p>I could do this easily enough in code with multiple queries, but it seemed like a nice challenge to try and find a pure-sql alternative.</p>

	<h2>First attempt </h2>

	<p>This was based on an idea from <a href="http://forums.mysql.com/read.php?20,35526,35560#msg-35560">the mysql forums</a> :</p>

	<p><pre class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> u.login, a.filename <span style="color: #993333; font-weight: bold;">FROM</span> users u 
<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> filename, user_id, id <span style="color: #993333; font-weight: bold;">AS</span> rand_id <span style="color: #993333; font-weight: bold;">FROM</span> assets <span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> user_id <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> RAND<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> a 
<span style="color: #993333; font-weight: bold;">ON</span> u.id = a.user_id 
<span style="color: #993333; font-weight: bold;">WHERE</span> a.filename <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> u.login;</pre></p>

	<p>Since the &#8216;order by rand()&#8217; happens after the &#8216;group by&#8217;, it doesn&#8217;t return random results &#8211; it always returns the same results, but in random order.</p>

	<h2>Second attempt</h2>

	<p>Apparently this is known as the <a href="http://markmail.org/message/xwj3gpzoshpyxi2h"><span class="caps">MAX-CONCAT</span> trick</a> :</p>

	<p><pre class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> u.login, user_id, SUBSTRING<span style="color: #66cc66;">&#40;</span>MAX<span style="color: #66cc66;">&#40;</span>CONCAT<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">TRUNCATE</span><span style="color: #66cc66;">&#40;</span>RAND<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span>,a.id<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #cc66cc;">7</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> asset_id 
<span style="color: #993333; font-weight: bold;">FROM</span> assets a 
<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> users u <span style="color: #993333; font-weight: bold;">ON</span> a.user_id = u.id 
<span style="color: #993333; font-weight: bold;">WHERE</span> user_id <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
<span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> user_id 
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> user_id;</pre></p>

	<p>This works, however it&#8217;s pretty hacky and <strong>very</strong> MySQL-specific, and I doubt it will work on any other databases. Depending on the number of rows you want to return, it could well end up being faster just doing the heavy lifting in code rather than trying to bend <span class="caps">SQL</span> to your will.</p>

	<h2>Update &#8211; Solution (2009/12/04)</h2>

	<p><a href="http://egeriis.me/">Ronnii</a> commented and pointed out this approach which (as far as i can tell) seems to do exactly what i wanted.</p>

	<p><pre class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> u.login, a.filename <span style="color: #993333; font-weight: bold;">FROM</span> users u 
<span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> filename, user_id, id <span style="color: #993333; font-weight: bold;">AS</span> rand_id <span style="color: #993333; font-weight: bold;">FROM</span> assets <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> RAND<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> a
<span style="color: #993333; font-weight: bold;">ON</span> u.id = a.user_id 
<span style="color: #993333; font-weight: bold;">WHERE</span> a.filename <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
<span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> user_id
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> u.login;</pre></p>

	<p>Thanks Ronni!</p>]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2009/08/11/mysql-select-random-row-with-join/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Passing IPs to apache with nginx proxy</title>
		<link>http://recurser.com/articles/2009/08/10/passing-ips-to-apache-with-nginx-proxy/</link>
		<comments>http://recurser.com/articles/2009/08/10/passing-ips-to-apache-with-nginx-proxy/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 04:59:56 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=395</guid>
		<description><![CDATA[How to configure "apache":http://httpd.apache.org/ to pick up the correct IP address for logs etc, when requests are proxied from  "nginx":http://nginx.net .]]></description>
			<content:encoded><![CDATA[	<p>When you use <a href="http://nginx.net">nginx</a> to proxy to <a href="http://httpd.apache.org/">apache</a> , apache picks up the IP address of your nginx proxy as the client. A consequence of this is that apache log files, and any application running on the apache backend, will all receive the same IP address (for example 127.0.0.1 if apache and nginx are running the same server).</p>

	<p>Luckily, nginx provides a <span class="caps">HTTP</span> <em>X-Forwarded-For</em> header containing the clients real IP address, although apache doesn&#8217;t pick it up by default. To allow apache to recognize the original client IP, we need to install the mod_rpaf module. On ubuntu, this is as simple as installing a package :</p>

	<p><pre class="bash">&gt; sudo apt-get install  libapache2-mod-rpaf</pre></p>

	<p>Once you have installed mod_rpaf, you need to configure apache. Add something similar to the following to your apache config (alter the RPAFproxy_ips setting as appropriate to match the IP address(es) of your nginx server(s) :</p>

	<p><pre class="bash">&lt;IfModule mod_rpaf.c&gt;
RPAFenable On
RPAFsethostname On
RPAFproxy_ips <span style="color: #cc66cc;">127.0</span><span style="color: #cc66cc;">.0</span><span style="color: #cc66cc;">.1</span>
&lt;/IfModule&gt;</pre></p>

	<p>If you installed the ubuntu package, this should be set up for you automatically in <em>/etc/apache2/mods-available/rpaf.conf</em> . </p>

	<p>Once apache is restarted, you should be able to see the correct IP addresses in the apache access logs.</p>

	<p>If nginx has trouble passing the <em>X-Forwarded-For</em> header for some reason, you can try to force it to set headers by hand :</p>

	<p><pre class="php">...
proxy_set_header Host <span style="color: #0000ff;">$host</span>;
proxy_set_header X-Real-IP <span style="color: #0000ff;">$remote_addr</span>;
proxy_set_header X-Forwarded-<span style="color: #b1b100;">For</span> <span style="color: #0000ff;">$proxy_add_x_forwarded_for</span>;
...</pre></p>]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2009/08/10/passing-ips-to-apache-with-nginx-proxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customize the Nginx server header</title>
		<link>http://recurser.com/articles/2009/08/10/customize-the-nginx-server-header/</link>
		<comments>http://recurser.com/articles/2009/08/10/customize-the-nginx-server-header/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 23:48:40 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://recurser.com/?p=373</guid>
		<description><![CDATA[How to alter the 'server' header in "nginx":http://nginx.net/ .]]></description>
			<content:encoded><![CDATA[	<p>Unfortunately the only way to change the server header in <a href="http://nginx.net/">nginx</a> is to actually recompile it from source. Luckily this is quite easy.</p>

	<p>First, download the latest version of nginx (0.7.61 at the time of writing) :<br />
<pre class="bash">&gt; wget http://sysoev.ru/nginx/nginx<span style="color: #cc66cc;">-0.7</span><span style="color: #cc66cc;">.61</span>.tar.gz 
&gt; tar xvzf nginx<span style="color: #cc66cc;">-0.7</span><span style="color: #cc66cc;">.61</span>.tar.gz
&gt; <span style="color: #000066;">cd</span> nginx<span style="color: #cc66cc;">-0.7</span><span style="color: #cc66cc;">.61</span></pre></p>

	<h2>Changing the server string</h2>

	<p>The server header is in a file called ngx_http_header_filter_module.c :<br />
<pre class="bash">&gt; vi src/http/ngx_http_header_filter_module.c</pre></p>

	<p>Edit the following line (currently line 48 in version 0.7.61) :<br />
<pre class="c"><span style="color: #993333;">static</span> <span style="color: #993333;">char</span> ngx_http_server_string<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;Server: nginx&quot;</span> CRLF;</pre></p>

	<p>&#8230; and change the <em>nginx</em> in <em>&#8216;Server: nginx&#8217;</em> to whatever you want:<br />
<pre class="c"><span style="color: #993333;">static</span> <span style="color: #993333;">char</span> ngx_http_server_string<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;Server: recurser&quot;</span> CRLF;</pre></p>

	<p>Next, edit <em>src/core/nginx.h</em> :<br />
<pre class="bash">&gt; vi src/core/nginx.h</pre></p>

	<p>Edit the following line (currently line 13 in version 0.7.61) :<br />
<pre class="c"><span style="color: #339933;">#define NGINX_VER          &quot;nginx/&quot; NGINX_VERSION </span></pre></p>

	<p>&#8230; and change the server string to whatever you want:<br />
<pre class="c"><span style="color: #339933;">#define NGINX_VER          &quot;recurser/&quot; NGINX_VERSION </span></pre></p>

	<h2>Changing the version number</h2>

	<p>You might also want to change the version number to confuse attackers, or just for fun :) Edit <em>src/core/nginx.h</em> :<br />
<pre class="bash">&gt; vi src/core/nginx.h</pre></p>

	<p>Edit the following line (currently line 12 in version 0.7.61) :<br />
<pre class="c"><span style="color: #339933;">#define NGINX_VERSION      &quot;0.7.61&quot; </span></pre></p>

	<p>&#8230; and change the version to whatever you want:<br />
<pre class="c"><span style="color: #339933;">#define NGINX_VERSION      &quot;1.0&quot; </span></pre></p>

	<p>You can stop nginx from displaying the version entirely if you want, by including the server_tokens directive in your <em>nginx.conf</em> :<br />
<pre class="php">server_tokens off;</pre></p>

	<h2>Compiling</h2>

	<p>You can set the prefix as appropriate &#8211; I keep it in <em>/opt/</em> on Ubuntu.<br />
<pre class="bash">&gt; ./configure --<span style="color: #0000ff;">prefix=</span>/opt/nginx<span style="color: #cc66cc;">-0.7</span><span style="color: #cc66cc;">.61</span> --with-http_ssl_module
&gt; make
&gt; sudo make install</pre></p>

	<p>After this, use <em>.bashrc</em> or similar to add /opt/nginx-0.7.61/sbin to your path, then you can start your new nginx install using :<br />
<pre class="bash">&gt; sudo ngingx</pre></p>

	<p>To stop it, use &#8216;-s&#8217; to send the stop signal :<br />
<pre class="bash">&gt; sudo nginx -s stop</pre></p>

	<h2>Results</h2>

	<p>If you check the reponse headers, you should see your custom server string :<br />
<pre class="php">Server: recurser/<span style="color: #cc66cc;">1.0</span>, recurser
<a href="http://www.php.net/date"><span style="color: #000066;">Date</span></a>: Tue, <span style="color: #cc66cc;">11</span> Aug <span style="color: #cc66cc;">2009</span> <span style="color: #cc66cc;">02</span>:<span style="color: #cc66cc;">47</span>:<span style="color: #cc66cc;">31</span> GMT
Content-Type: text/html; charset=UTF<span style="color: #cc66cc;">-8</span>
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/<span style="color: #cc66cc;">5.2</span><span style="color: #cc66cc;">.4</span>-2ubuntu5<span style="color: #cc66cc;">.6</span>
X-Pingback: http:<span style="color: #808080; font-style: italic;">//recurser.com/xmlrpc.php</span>
Expires: Tue, <span style="color: #cc66cc;">18</span> Aug <span style="color: #cc66cc;">2009</span> <span style="color: #cc66cc;">02</span>:<span style="color: #cc66cc;">47</span>:<span style="color: #cc66cc;">31</span> GMT
Last-Modified: Tue, <span style="color: #cc66cc;">11</span> Aug <span style="color: #cc66cc;">2009</span> <span style="color: #cc66cc;">02</span>:<span style="color: #cc66cc;">47</span>:<span style="color: #cc66cc;">31</span> GMT
Cache-Control: max-age=<span style="color: #cc66cc;">604800</span>
Pragma: no-cache
Content-Encoding: gzip</pre></p>]]></content:encoded>
			<wfw:commentRss>http://recurser.com/articles/2009/08/10/customize-the-nginx-server-header/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
