<?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>World of Sam</title>
	<atom:link href="http://worldofsam.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://worldofsam.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 15 Aug 2011 07:24:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Hosting WordPress on a Nginx + uWSGI + Django Site</title>
		<link>http://worldofsam.com/blog/2011/08/hosting-wordpress-on-a-nginx-uwsgi-django-site/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hosting-wordpress-on-a-nginx-uwsgi-django-site</link>
		<comments>http://worldofsam.com/blog/2011/08/hosting-wordpress-on-a-nginx-uwsgi-django-site/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 06:45:44 +0000</pubDate>
		<dc:creator>Sam Birch</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[uwsgi]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://worldofsam.com/blog/?p=107</guid>
		<description><![CDATA[
Nginx and uWSGI provide a very nice system for efficiently hosting Django applications. Adding a WordPress blog to the mix is not difficult, but it requires some slightly non-obvious (though still straight-forward) Nginx configuration. To set everything up, lets first think about the site structure and what Nginx actually needs to do. At worldofsam.com, everything [...]]]></description>
			<content:encoded><![CDATA[
<p><a title="Nginx" href="http://wiki.nginx.org/">Nginx</a> and <a title="uWSGI" href="http://projects.unbit.it/uwsgi/">uWSGI</a> provide a very nice system for efficiently hosting <a title="Django" href="https://www.djangoproject.com/">Django</a> applications. Adding a WordPress blog to the mix is not difficult, but it requires some slightly non-obvious (though still straight-forward) Nginx configuration.</p>
<p>To set everything up, lets first think about the site structure and what Nginx actually needs to do. At <a title="worldofsam.com" href="http://worldofsam.com/">worldofsam.com</a>, everything is handled by a Django application except for <strong>/blog</strong> , which is handled by WordPress. Therefore, Nginx needs to do the following:</p>
<ol>
<li>If the URI is below <strong>/media</strong>, serve up a static file or 404</li>
<li>If the URI is below <strong>/blog</strong> and maps to a real, non-PHP file, serve it up directly</li>
<li>If the URI is below <strong>/blog</strong> and maps to a PHP file, pass it on to FastCGI</li>
<li>If the URI is below <strong>/blog</strong>, but doesn&#8217;t map to a real file, then pass it onto an appropriate <em>index.php</em> WordPress handler</li>
<li>Otherwise, pass the request on to uWSGI and Django</li>
</ol>
<p>The server is organised so that the Django application and WordPress installation reside in the same directory:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">/www/
    wsgi-handlers/ (uWSGI is configured to look here for WSGI handler scripts)
        worldofsam.py
    worldofsam.com/
        worldofsam_site/ (contains the Django site)
            site_media/
        blog/ (contains the WordPress installation)</pre></div></div>

<p>And Nginx is configured like so:</p>

<div class="wp_syntax"><div class="code"><pre class="nginx" style="font-family:monospace;"><span style="color: #000066;">server</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000066;">listen</span> <span style="">80</span><span style="color: #66cc66;">;</span>
    <span style="color: #000066;">server_name</span> worldofsam.com<span style="color: #66cc66;">;</span>
&nbsp;
    <span style="color: #000066;">root</span> /www/worldofsam.com/worldofsam_site/site_media<span style="color: #66cc66;">;</span>
&nbsp;
    <span style="color: #000066;">location</span> / <span style="color: #66cc66;">&#123;</span>
        <span style="">uwsgi_pass</span> unix:/var/tmp/uwsgi.sock<span style="color: #66cc66;">;</span>
        <span style="color: #b1b100;">include</span> uwsgi_params<span style="color: #66cc66;">;</span>
        uwsgi_param UWSGI_SCRIPT worldofsam<span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000066;">location</span> /media <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000066;">alias</span> /www/worldofsam.com/worldofsam_site/site_media<span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000066;">location</span> /blog <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000066;">root</span> /www/worldofsam.com<span style="color: #66cc66;">;</span>
        <span style="color: #000066;">index</span> <span style="color: #000066;">index</span>.php /blog/<span style="color: #000066;">index</span>.php<span style="color: #66cc66;">;</span>
        <span style="color: #000066;">try_files</span> <span style="">$uri</span> <span style="">$uri</span>/ /blog/<span style="color: #000066;">index</span>.php?q<span style="color: #66cc66;">=</span><span style="">$uri</span>?<span style="">$args</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000066;">location</span> <span style="color: #66cc66;">~</span> /blog/.+\.php$ <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000066;">root</span> /www/worldofsam.com<span style="color: #66cc66;">;</span>
        <span style="color: #b1b100;">include</span> fastcgi.conf<span style="color: #66cc66;">;</span>
        <span style="">fastcgi_pass</span> localhost:<span style="">8820</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The most tightly binding block is the <strong>location ~ /blog/.+\.php$</strong> block, which will pass any request for a PHP file below <strong>/blog</strong> on to FastCGI (satisfying requirement #3 from earlier). The document root is set one directory above the WordPress installation, since any URI matched by this block will already contain the <em>/blog</em> path component (and so will the FCGI script name). WordPress must therefore be installed in a directory with the same name as the directory it appears under on the site.</p>
<p>The <strong>location /blog</strong> block sets the root to <em>/www/worldofsam.com</em> for the same reason, and uses an <strong>index</strong> directive to process the request using a file named <em>index.php</em> if the URI is for a directory, or WordPress&#8217;s primary <em>index.php</em> file if none exists.</p>
<p>The <strong>try_files</strong> directive then tries to handle the request as a static file, as a directory (which should contain an index.php file) or by passing the URI on to WordPress&#8217;s primary <em>index.php</em> handler if the first two fail. This last part is required for pretty permalinks to work.</p>
<p>That satisfies requirements #2 and #4 from earlier, which just leaves us with #1 and #5. Satisfying requirement #1 is easy &#8211; just use an <strong>alias</strong> directive like shown in the <strong>location /media</strong> block, and requirement #5 is satisfied by the <strong>location /</strong> block which passes the request on to uWSGI.</p>
<p>Assuming you have correctly configured uWSGI, FastCGI and WordPress, you should now be able to load yoursite.com/blog and see WordPress come up.</p>
]]></content:encoded>
			<wfw:commentRss>http://worldofsam.com/blog/2011/08/hosting-wordpress-on-a-nginx-uwsgi-django-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Photo Density Maps from Around the World</title>
		<link>http://worldofsam.com/blog/2010/03/photo-density-maps-from-around-the-world/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=photo-density-maps-from-around-the-world</link>
		<comments>http://worldofsam.com/blog/2010/03/photo-density-maps-from-around-the-world/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 00:15:05 +0000</pubDate>
		<dc:creator>Sam Birch</dc:creator>
				<category><![CDATA[Haskell]]></category>
		<category><![CDATA[Photography]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[panoramio]]></category>
		<category><![CDATA[photo density]]></category>

		<guid isPermaLink="false">http://blog.worldofsam.com/?p=83</guid>
		<description><![CDATA[It occurred to me after a visit to the South Island of New Zealand last year that plotting the locations where people have taken lots of photos might turn up some interesting hot-spots. Panoramio was one of the obvious places to look for data, and their API makes it quite easy to get a list [...]]]></description>
			<content:encoded><![CDATA[<p>It occurred to me after a visit to the South Island of New Zealand last year that plotting the locations where people have taken lots of photos might turn up some interesting hot-spots. <a href="http://www.panoramio.com/">Panoramio</a> was one of the obvious places to look for data, and <a href="http://www.panoramio.com/api/">their API</a> makes it quite easy to get a list of the photos taken in a given area.</p>
<p>One small Haskell program and many days worth of Panoramio queries later, I had the data sets for a bunch of large cities and tourist attractions around the world. The data sets aren&#8217;t particularly large, but Panoramio limits each IP to a maximum of 10 000 requests per day, and as such getting the data for a popular area such as Moscow can take quite a long time (unless, I suppose, you happen to be in possession of a large bot net &#8211; but unfortunately that&#8217;s not the kind of thing I tend to have lying around!)</p>
<p>The first thing to do once the data was on my hard drive was to plot each set in an image. Many of the sets turned out to be pretty unexciting, either because they were far less popular than I had expected, or because the photo locations were uniformly distributed without any particular hot-spots or features.</p>
<p>One of the more interesting areas happens to be Auckland, New Zealand, where I&#8217;m currently based:</p>
<div id="attachment_86" class="wp-caption alignnone" style="width: 810px"><a href="http://worldofsam.com/blog/wp-content/uploads/2010/03/Auckland.jpg"><img class="size-full wp-image-86" title="Photo Density Map of Auckland, New Zealand" src="http://worldofsam.com/blog/wp-content/uploads/2010/03/Auckland.jpg" alt="Photo Density Map of Auckland, New Zealand" width="800" height="383" /></a><p class="wp-caption-text">Photo Density Map of Auckland, New Zealand</p></div>
<p>The bright spot slightly below and to the left of the center is Auckland City&#8217;s CBD. The bright line to the left of that is the west coast beaches like Muriwai, Piha and Whatipu, and to the right you can clearly make out the shape of the Coromandel peninsula. You can also see bright patches on Rangitoto, Waiheke and a bunch of the other islands east of Auckland.</p>
<p>Another interesting city is Paris. No surprises here:</p>
<div id="attachment_92" class="wp-caption alignnone" style="width: 810px"><a href="http://worldofsam.com/blog/wp-content/uploads/2010/03/Paris.jpg"><img class="size-full wp-image-92" title="Photo Density Map of Paris" src="http://worldofsam.com/blog/wp-content/uploads/2010/03/Paris.jpg" alt="Photo Density Map of Paris" width="800" height="404" /></a><p class="wp-caption-text">Photo Density Map of Paris</p></div>
<p>As you would expect, the Eiffel Tower and the Louvre Museum get a lot of interest from photographers. You can also see hot-spots at L&#8217;Arc de Triomphe, La Défense, Montmartre and generally along the banks of the Seine River.</p>
<p>Moscow is my favourite map:</p>
<div id="attachment_98" class="wp-caption alignnone" style="width: 810px"><a href="http://worldofsam.com/blog/wp-content/uploads/2010/03/Moscow.jpg"><img class="size-full wp-image-98" title="Photo Density Map of Moscow" src="http://worldofsam.com/blog/wp-content/uploads/2010/03/Moscow.jpg" alt="Photo Density Map of Moscow" width="800" height="439" /></a><p class="wp-caption-text">Photo Density Map of Moscow</p></div>
<p>The city center clearly gets a lot of attention. Novodevichy Convent, Victory Park and the Moscow State University are also quite popular, as is the All-Russia Exhibition Center. I particularly like the curve of the river as it flows through the city. Very pretty.</p>
<p>There are some other reasonably interesting areas, but I won&#8217;t show them all here. Follow the links if you&#8217;re interested:</p>
<ul>
<li><a href="http://worldofsam.com/blog/wp-content/uploads/2010/03/Tokyo.jpg">Tokyo</a></li>
<li><a href="http://worldofsam.com/blog/wp-content/uploads/2010/03/GrandCanyon.jpg">The Grand Canyon</a></li>
<li><a href="http://worldofsam.com/blog/wp-content/uploads/2010/03/Japan.jpg">Japan and part of China</a></li>
<li><a href="http://worldofsam.com/blog/wp-content/uploads/2010/03/NewYork.jpg">New York</a></li>
</ul>
<p>The next step was to create some movies showing activity through the year. Behold:</p>
<p><object style="width: 800px; height: 439px;" width="800" height="439" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/tIkb33LMJ7c" /><embed style="width: 800px; height: 439px;" width="800" height="439" type="application/x-shockwave-flash" src="http://www.youtube.com/v/tIkb33LMJ7c" /></object></p>
<p><object width="800" height="438" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/hsus2SZ-5WU" /><embed width="800" height="438" type="application/x-shockwave-flash" src="http://www.youtube.com/v/hsus2SZ-5WU" /></object></p>
<p><object width="800" height="404" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/rULX71dnNSQ" /><embed width="800" height="404" type="application/x-shockwave-flash" src="http://www.youtube.com/v/rULX71dnNSQ" /></object></p>
<p>Again, I&#8217;m not going to show every movie here, but you can follow the links for more:</p>
<ul>
<li><a href="http://www.youtube.com/watch?v=R7l7C01sLFw">Japan</a></li>
<li><a href="http://www.youtube.com/watch?v=P3DupR8k74s">The Grand Canyon</a></li>
<li><a href="http://www.youtube.com/watch?v=6t_YJtyLp-c">Auckland</a></li>
</ul>
<p>Finally, for those of you interested in the Haskell code for accessing Panoramio, you can find it here: <a href="http://code.google.com/p/worldofsam-free-code/source/browse/Misc/Panoramio.hs">Panoramio.hs</a></p>
]]></content:encoded>
			<wfw:commentRss>http://worldofsam.com/blog/2010/03/photo-density-maps-from-around-the-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tips for Creating Your Own Little Planet</title>
		<link>http://worldofsam.com/blog/2009/09/tips-for-creating-your-own-little-planet/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tips-for-creating-your-own-little-planet</link>
		<comments>http://worldofsam.com/blog/2009/09/tips-for-creating-your-own-little-planet/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 23:46:31 +0000</pubDate>
		<dc:creator>Sam Birch</dc:creator>
				<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://blog.worldofsam.com/?p=7</guid>
		<description><![CDATA[Creating &#8216;little planet&#8217; style panoramas has become quite the popular thing to do of late, and with examples such as this and this it isn&#8217;t hard to see why. Not wanting to miss out on the fun, I decided I&#8217;d have a go at creating my own little planet. As it turns out, converting a [...]]]></description>
			<content:encoded><![CDATA[<p>Creating &#8216;little planet&#8217; style panoramas has become quite the popular thing to do of late, and with examples such as <a href="http://www.flickr.com/photos/dominic_kamp/2474960220/">this</a> and <a href="http://www.flickr.com/photos/pepeketua/3335215249/">this</a> it isn&#8217;t hard to see why.</p>
<p>Not wanting to miss out on the fun, I decided I&#8217;d have a go at creating my <em>own</em> little planet. As it turns out, converting a 360° panorama into a little planet is a simple process and <a href="http://photojojo.com/content/tutorials/create-your-own-panorama-planets/">this tutorial</a> covers it pretty well &#8211; however I still ran into a couple of issues when I tried it myself:</p>
<h4>The Center of the Earth is Warped!</h4>
<p>I don&#8217;t have a particularly wide angle lens so I couldn&#8217;t easily capture the whole scene from pole to pole (i.e. the resulting panorama didn&#8217;t have 180° vertical coverage). This meant that when I twisted the panorama into a circle, the bottom was stretched until each side met at the center of the &#8220;planet&#8221;, resulting in an ugly warped section right at the center of the image:</p>
<div class="mceTemp">
<dl id="attachment_13" class="wp-caption alignnone" style="width: 260px;">
<dt class="wp-caption-dt"><img class="size-full wp-image-13" title="Stretch Marks" src="http://worldofsam.com/blog/wp-content/uploads/2009/09/StretchMarks.jpg" alt="Yikes" width="250" height="176" /></dt>
</dl>
</div>
<p>Luckily it&#8217;s easily fixed.</p>
<p>I simply took some extra photos of the ground I had been standing on when I made the panorama (after moving my tripod, of course!) and then used those to rebuild the ground at the center of the image after applying the polar coordinates filter in Photoshop.</p>
<h4>Mismatched Exposures at Each End of the Panorama</h4>
<p>I made the panorama for this shot shortly before sunset, which meant that the light was changing quickly as I took the photos. To prevent the sun from dropping too much while I had my back turned, I simply alternated the side that I took each photo from as I worked my way back. The second photo was slightly to the right of the first, the third slightly to the left, etc.</p>
<p>The result is that instead of finishing where I started, but two minutes later and with different light, I finished pointing directly away from where I started and with no sudden changes in exposure to worry about.</p>
<p>Beyond those two things, it was just a matter of applying a little bit of lovin&#8217; in Photoshop until I had the effect I was looking for (click to see it larger)</p>
<p><a title="Little North Head" href="http://worldofsam.com/photography/view/26/"><img class="alignnone" title="Little North Head" src="http://worldofsam.com/photography/view/26/" alt="" width="500" height="409" /></a></p>
<p>Have fun! Follow these instructions and it&#8217;ll be no time at all before we all have our own little planets and the effect becomes totally kitsch <img src='http://worldofsam.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://worldofsam.com/blog/2009/09/tips-for-creating-your-own-little-planet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

