<?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>Wil Tan</title>
	<atom:link href="http://dready.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://dready.org/blog</link>
	<description>musings on internationalized identifiers: domain names, OpenID, TLDs</description>
	<lastBuildDate>Sat, 10 Jul 2010 10:11:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hash Ring fork</title>
		<link>http://dready.org/blog/2010/07/10/hash-ring-fork/</link>
		<comments>http://dready.org/blog/2010/07/10/hash-ring-fork/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 10:11:17 +0000</pubDate>
		<dc:creator>wil</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[hash_ring]]></category>
		<category><![CDATA[pip]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://dready.org/blog/?p=281</guid>
		<description><![CDATA[Amir Salihefendic&#8217;s hash_ring module is awesome, but it doesn&#8217;t install cleanly with pip (dies with ez_setup import error) and spews some deprecation warning on Python 2.6+ (md5 module deprecated in favour of hashlib.)
In order to keep my deployment recipe sane, I&#8217;ve decided to fork the project on github.
Now, all you need is the following in [...]


Related posts:<ol><li><a href='http://dready.org/blog/2009/10/09/tornado-with-virtualenv-and-pip-quickstart/' rel='bookmark' title='Permanent Link: Tornado with VirtualEnv and Pip Quickstart'>Tornado with VirtualEnv and Pip Quickstart</a> <small>Friendfeed&#8217;s open source Tornado web server is great, and is incredibly easy to get up-and-running. Just install tornado, write your...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://amix.dk/">Amir Salihefendic</a>&#8217;s <a href="http://pypi.python.org/pypi/hash_ring">hash_ring</a> module is awesome, but it doesn&#8217;t install cleanly with <a href="http://pypi.python.org/pypi/pip">pip</a> (dies with <code>ez_setup</code> import error) and spews some deprecation warning on Python 2.6+ (md5 module deprecated in favour of hashlib.)</p>
<p>In order to keep my deployment recipe sane, I&#8217;ve decided to <a href="http://github.com/wil/hash_ring">fork the project on github</a>.</p>
<p>Now, all you need is the following in requirements.txt:</p>
<pre>
-e git://github.com/wil/hash_ring.git#egg=hash-ring
</pre>


<p>Related posts:<ol><li><a href='http://dready.org/blog/2009/10/09/tornado-with-virtualenv-and-pip-quickstart/' rel='bookmark' title='Permanent Link: Tornado with VirtualEnv and Pip Quickstart'>Tornado with VirtualEnv and Pip Quickstart</a> <small>Friendfeed&#8217;s open source Tornado web server is great, and is incredibly easy to get up-and-running. Just install tornado, write your...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://dready.org/blog/2010/07/10/hash-ring-fork/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nginx + Django + FastCGI + SSL</title>
		<link>http://dready.org/blog/2010/07/10/nginx-django-fastcgi-ssl/</link>
		<comments>http://dready.org/blog/2010/07/10/nginx-django-fastcgi-ssl/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 05:36:00 +0000</pubDate>
		<dc:creator>wil</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[flup]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://dready.org/blog/?p=277</guid>
		<description><![CDATA[My favourite method for deploying Django sites in production is with Nginx at the frontend talking FastCGI to a dedicated Django process (either flup or supervisord) via a UNIX or TCP socket.
There are two recurring issues that I keep running into costing hours of fruitless Googling. Hopefully, this will help others:

SCRIPT_NAME is evil! At least [...]


Related posts:<ol><li><a href='http://dready.org/blog/2009/10/09/tornado-with-virtualenv-and-pip-quickstart/' rel='bookmark' title='Permanent Link: Tornado with VirtualEnv and Pip Quickstart'>Tornado with VirtualEnv and Pip Quickstart</a> <small>Friendfeed&#8217;s open source Tornado web server is great, and is incredibly easy to get up-and-running. Just install tornado, write your...</small></li>
<li><a href='http://dready.org/blog/2010/03/29/optimizing-autocomplete-utilizing-browser-cache/' rel='bookmark' title='Permanent Link: Optimizing Autocomplete by Utilizing Browser Cache'>Optimizing Autocomplete by Utilizing Browser Cache</a> <small>Say you have a snazzy AJAXified autocomplete field that gives instantaneous feedback to the user as she types &#8212; perhaps...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>My favourite method for deploying Django sites in production is with Nginx at the frontend talking FastCGI to a dedicated Django process (either <a href="http://trac.saddi.com/flup">flup</a> or <a href="http://supervisord.org/">supervisord</a>) via a UNIX or TCP socket.</p>
<p>There are two recurring issues that I keep running into costing hours of fruitless Googling. Hopefully, this will help others:</p>
<ul>
<li><code>SCRIPT_NAME</code> is evil! At least it&#8217;s useless in Django, and if present as a FastCGI parameter, Django will trip that away from your request URI and you&#8217;re almost certainly going to get <code>/</code> no matter what URI you navigate to! So, save <code>SCRIPT_NAME</code> for your PHP stuff, and leave it out of the parts where you expect to be talking to Django.<br />
If you have <code>include fastcgi_params</code> in your <code>nginx.conf</code>, make sure it&#8217;s not hiding behind the <code>fastcgi_params</code> file.</li>
<li>If you want SSL to work, i.e. for Django to <em>know</em> that it is serving in <code>https</code> mode, and to build proper <code>Location</code> header for redirects, you need to include the following in the appropriate section of your <code>nginx.conf</code>:<br />
<code><br />
fastcgi_param  HTTPS on;<br />
</code></p>
<p>Obviously, if you&#8217;re running both plain and SSL version, you shouldn&#8217;t be sharing that section or Django will just thinking that it is in SSL mode even when it&#8217;s not.</p>
</li>
</ul>


<p>Related posts:<ol><li><a href='http://dready.org/blog/2009/10/09/tornado-with-virtualenv-and-pip-quickstart/' rel='bookmark' title='Permanent Link: Tornado with VirtualEnv and Pip Quickstart'>Tornado with VirtualEnv and Pip Quickstart</a> <small>Friendfeed&#8217;s open source Tornado web server is great, and is incredibly easy to get up-and-running. Just install tornado, write your...</small></li>
<li><a href='http://dready.org/blog/2010/03/29/optimizing-autocomplete-utilizing-browser-cache/' rel='bookmark' title='Permanent Link: Optimizing Autocomplete by Utilizing Browser Cache'>Optimizing Autocomplete by Utilizing Browser Cache</a> <small>Say you have a snazzy AJAXified autocomplete field that gives instantaneous feedback to the user as she types &#8212; perhaps...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://dready.org/blog/2010/07/10/nginx-django-fastcgi-ssl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>httpd exited on signal 11 &#8211; solved</title>
		<link>http://dready.org/blog/2010/07/04/httpd-exited-on-signal-11-solved/</link>
		<comments>http://dready.org/blog/2010/07/04/httpd-exited-on-signal-11-solved/#comments</comments>
		<pubDate>Sat, 03 Jul 2010 14:29:50 +0000</pubDate>
		<dc:creator>wil</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[core]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[segfault]]></category>
		<category><![CDATA[sig11]]></category>

		<guid isPermaLink="false">http://dready.org/blog/?p=270</guid>
		<description><![CDATA[tl;dr
It&#8217;s probably mod_php, and try recompiling PHP without zend_multibyte. If you have WITH_MULTIBYTE=true in /var/db/ports/php5/options, change it to WITHOUT_MULTIBYTE=true and rebuild the port.
Long Story
The Apache 2.2 processes on my FreeBSD box keep dying intermittently, with messages such as:

Jul  3 08:08:37 yama kernel: pid 13526 (httpd), uid 80: exited on signal 10
Jul  3 08:25:58 [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<h4>tl;dr</h4>
<p>It&#8217;s probably mod_php, and try recompiling PHP without zend_multibyte. If you have <code>WITH_MULTIBYTE=true</code> in <code>/var/db/ports/php5/options</code>, change it to <code>WITHOUT_MULTIBYTE=true</code> and rebuild the port.</p>
<h4>Long Story</h4>
<p>The Apache 2.2 processes on my FreeBSD box keep dying intermittently, with messages such as:</p>
<p><code><br />
Jul  3 08:08:37 yama kernel: pid 13526 (httpd), uid 80: exited on signal 10<br />
Jul  3 08:25:58 yama kernel: pid 33050 (httpd), uid 80: exited on signal 11<br />
</code></p>
<p>I&#8217;ve googled around and tried various extensions.ini reordering tricks without luck. Eventually, I figured out how to get Apache to dump core. First, you need to tell Apache where to dump core by adding the <a href="http://httpd.apache.org/docs/2.2/mod/mpm_common.html#coredumpdirectory">CoreDumpDirectory</a> directive to your <code>httpd.conf</code>. Restart apache.</p>
<p>Then, check to make sure that the <code>kern.coredump</code> and <code>kern.sugid_coredump</code> sysctl variables are set to <code>1</code>. Because Apache calls <code>setuid</code> and <code>setgid</code> to the configured user after listening on port 80 (privileged port), FreeBSD by default will refuse to dump core on segfaults. Setting <code>kern.sugid_coredump</code> will make it do so.</p>
<p><code><br />
$ sysctl kern.coredump<br />
kern.coredump: 1<br />
$ sysctl kern.sugid_coredump<br />
kern.sugid_coredump: 0<br />
$ sudo sysctl kern.sugid_coredump=1<br />
kern.sugid_coredump: 0 -> 1<br />
</code></p>
<p>Of course, you&#8217;d also need to make sure that your <code>ulimit</code> doesn&#8217;t prevent it from dumping core:</p>
<p><code><br />
$ ulimit -c<br />
unlimited<br />
</code></p>
<p>Great! Now wait for Apache to segfault (or, if you have a reproducible test case, hit it!)</p>
<p>You should now find <code>httpd.core</code> in the directory that you configured in <code>httpd.conf</code> (in my case, it is <code>/tmp</code>.)</p>
<p>Do the usual gdb stuff:</p>
<p><code><br />
$ gdb /tmp/httpd.core /usr/local/bin/httpd<br />
</code><br />
In my case, I found <code>zend_multibyte_read_script</code> near the top of the stack, so it&#8217;s pretty clear that PHP is to blame.<br />
Did I mention that I abhor PHP? Someday I will get rid of it entirely!</p>
<p>This led me to more googling and <a href="http://lists.freebsd.org/pipermail/freebsd-ports/2010-May/061362.html">found</a> that I may have accidentally enabled Zend Multibyte support (well, its purpose is not very well documented and I just assumed that since I do lots of i18n work, it&#8217;ll come in handy. Okay so it&#8217;s my fault after all but it still shouldn&#8217;t crash!)</p>
<p>Changing <code>WITH_MULTIBYTE=true</code> to <code>WITHOUT_MULTIBYTE=true</code> in <code>/var/db/ports/php5/options</code> and rebuilding the port made the problem go away.</p>
<p>Hopefully, the above will help someone in a similar situation.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://dready.org/blog/2010/07/04/httpd-exited-on-signal-11-solved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trials and Tribulations of Global Communities</title>
		<link>http://dready.org/blog/2010/04/30/trials-tribulations-global-communities/</link>
		<comments>http://dready.org/blog/2010/04/30/trials-tribulations-global-communities/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 03:30:56 +0000</pubDate>
		<dc:creator>wil</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[culture]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tornado]]></category>

		<guid isPermaLink="false">http://dready.org/blog/?p=267</guid>
		<description><![CDATA[I&#8217;m not about to write a lengthy essay on online cultures. Just an interesting observation on some events on the Tornado mailing list.
So, I lurk in that mailing list because Tornado is one of those awesome technologies in the Python world, and there are usually gems flying around.
As with most discussion groups I join, English [...]


Related posts:<ol><li><a href='http://dready.org/blog/2009/10/09/tornado-with-virtualenv-and-pip-quickstart/' rel='bookmark' title='Permanent Link: Tornado with VirtualEnv and Pip Quickstart'>Tornado with VirtualEnv and Pip Quickstart</a> <small>Friendfeed&#8217;s open source Tornado web server is great, and is incredibly easy to get up-and-running. Just install tornado, write your...</small></li>
<li><a href='http://dready.org/blog/2010/07/10/nginx-django-fastcgi-ssl/' rel='bookmark' title='Permanent Link: Nginx + Django + FastCGI + SSL'>Nginx + Django + FastCGI + SSL</a> <small>My favourite method for deploying Django sites in production is with Nginx at the frontend talking FastCGI to a dedicated...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not about to write a lengthy essay on online cultures. Just an interesting observation on some events on the <a href="http://groups.google.com/group/python-tornado">Tornado mailing list</a>.</p>
<p>So, I lurk in that mailing list because Tornado is one of those awesome technologies in the Python world, and there are usually gems flying around.</p>
<p>As with most discussion groups I join, English is the norm. In fact, some have gone as far as to argue that <a href="http://www.codinghorror.com/blog/2009/03/the-ugly-american-programmer.html">English should be the lingua franca of hackers</a>. To a great extent, I agree.</p>
<p>So, all is well until one day some <a href="http://groups.google.com/group/python-tornado/browse_frm/thread/edffb4cffbbe2ef4">Chinese messages</a> started appearing on the list. Now, I read and write Chinese but I can&#8217;t making a living with Chinese geek-speak. Those messages didn&#8217;t bother me though I was thinking it must be annoying to non-Chinese speaking subscribers. And true enough, we got a <a href="http://groups.google.com/group/python-tornado/browse_frm/thread/196a172ca0b0979b">message from one of the subscribers</a> today:</p>
<blockquote><p>
我们看不懂你的中文信息，写英语，请。
</p></blockquote>
<p>Obviously the output of machine translation with an input to the effect of:</p>
<blockquote><p>
We cannot understand your Chinese messages, write in English, please.
</p></blockquote>
<p>I find it pretty amusing, and hope our fellow Chinese hackers don&#8217;t take offense.</p>


<p>Related posts:<ol><li><a href='http://dready.org/blog/2009/10/09/tornado-with-virtualenv-and-pip-quickstart/' rel='bookmark' title='Permanent Link: Tornado with VirtualEnv and Pip Quickstart'>Tornado with VirtualEnv and Pip Quickstart</a> <small>Friendfeed&#8217;s open source Tornado web server is great, and is incredibly easy to get up-and-running. Just install tornado, write your...</small></li>
<li><a href='http://dready.org/blog/2010/07/10/nginx-django-fastcgi-ssl/' rel='bookmark' title='Permanent Link: Nginx + Django + FastCGI + SSL'>Nginx + Django + FastCGI + SSL</a> <small>My favourite method for deploying Django sites in production is with Nginx at the frontend talking FastCGI to a dedicated...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://dready.org/blog/2010/04/30/trials-tribulations-global-communities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>git conflict resolution</title>
		<link>http://dready.org/blog/2010/04/28/git-conflict-resolution/</link>
		<comments>http://dready.org/blog/2010/04/28/git-conflict-resolution/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 18:10:47 +0000</pubDate>
		<dc:creator>wil</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://dready.org/blog/?p=264</guid>
		<description><![CDATA[Logging this mostly for myself.
When a conflict occurs during a pull operation from remote repository, we get this:

$ git pull kumo1 develop
From ssh://kumo0/home/wil/...
 * branch            develop    -> FETCH_HEAD
Auto-merged src/.../file.py
CONFLICT (content): Merge conflict in src/.../file.py
Automatic merge failed; fix conflicts and then commit [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Logging this mostly for myself.</p>
<p>When a conflict occurs during a pull operation from remote repository, we get this:</p>
<pre>
$ git pull kumo1 develop
From ssh://kumo0/home/wil/...
 * branch            develop    -> FETCH_HEAD
Auto-merged src/.../file.py
CONFLICT (content): Merge conflict in src/.../file.py
Automatic merge failed; fix conflicts and then commit the result.
</pre>
<p>What git did was to fetch objects from the remote repository, and tried to merge it in the branch that you specified. Sometimes the merge operation fails due to a conflict, and the conflicting edits are left in the file. It is then up to you to eyeball the file, straighten it and then &#8220;commit the result&#8221; (as the message said.)</p>
<p>However, if you tried to commit that file (after fixing the conflict), you&#8217;d get this:</p>
<pre>
$ git commit -m "my fixes" src/.../file.py
fatal: cannot do a partial commit during a merge.
</pre>
<p>What you&#8217;d want is to add the <code>-i</code> argument to the <code>git commit</code> command, which tells it to stage the additional file before committing.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://dready.org/blog/2010/04/28/git-conflict-resolution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing Autocomplete by Utilizing Browser Cache</title>
		<link>http://dready.org/blog/2010/03/29/optimizing-autocomplete-utilizing-browser-cache/</link>
		<comments>http://dready.org/blog/2010/03/29/optimizing-autocomplete-utilizing-browser-cache/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 08:35:59 +0000</pubDate>
		<dc:creator>wil</dc:creator>
				<category><![CDATA[dns]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[icann]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[tuning]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://dready.org/blog/?p=261</guid>
		<description><![CDATA[Say you have a snazzy AJAXified autocomplete field that gives instantaneous feedback to the user as she types &#8212; perhaps a username field on a signup form or something akin to Google Suggest. Except, it&#8217;s not performing as well as you thought it should. That round trip to the server for each character is taking [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Say you have a snazzy AJAXified autocomplete field that gives instantaneous feedback to the user as she types &#8212; perhaps a username field on a signup form or something akin to Google Suggest. Except, it&#8217;s not performing as well as you thought it should. That round trip to the server for each character is taking too long.</p>
<p>The first thing you should do is to see if HTTP Keep-Alive is supported by your server.</p>
<p>Second, and this may seem obvious, but I&#8217;ve seen too many developers forget to leave a hint to the browser to cache the results. As a result, the page becomes sluggish due to a feature that&#8217;s meant to be responsive.</p>
<p>See what happens behind the scene when you sign up for a new <a href="https://twitter.com/signup">Twitter account</a>. Suppose you try to register the username &#8220;wil&#8221;, but it&#8217;s taken. For each character you type, the browser makes HTTP requests to check that the username in the input field to see if it&#8217;s available.</p>
<p>So that&#8217;s one for &#8220;w&#8221;, &#8220;wi&#8221;, &#8220;wil&#8221;. Then you find that all 3 are taken. Ok, perhaps time to add a numeric suffix? &#8220;wil1&#8243; &#8211; nope, delete the &#8220;1&#8243;, and we&#8217;re back to &#8220;wil&#8221; again. Guess what? Another HTTP request is sent to Twitter for the same string &#8220;wil&#8221;! </p>
<p>Had Twitter set an &#8220;Expires&#8221; header to usernames that are taken, the browser wouldn&#8217;t have had to make that round trip!</p>
<p>Below are the headers sent by Twitter for the https://twitter.com/users/username_available URI (courtesy of <a href="http://hurl.it/">Hurl</a>):</p>
<p><iframe src="http://hurl.it/views/f24fa9d033f6a17feb1321d1531eea42059d5abb" width="440" height="460" style="overflow: auto"></iframe></p>
<p>In the case of signup forms, usernames are rather involatile pieces of data, so it&#8217;s a prime optimization target. As your namespace becomes more scarce, you&#8217;ll tend to have people trying more strange combinations, increasing the number of requests to your servers.</p>
<p>In my case, I&#8217;ve applied it to our <a href="http://www.cloudregistry.net/">TLD management platform</a>. Domain names that are registered gets a 10 minute cache timeout value (which is heaps short but good enough to ensure a snappy UI operations). However, with domain names, it&#8217;s a lot more volatile but we&#8217;re not guaranteeing success at the point of registering a name so anywhere between 1-5 minutes is usually sufficient.</p>
<p>A simple view snippet in Django does the trick and goes a long way to making your users happy.</p>
<p><script src="http://gist.github.com/347596.js"></script></p>
<p>/ Blogging from a HSDPA connection</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://dready.org/blog/2010/03/29/optimizing-autocomplete-utilizing-browser-cache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging without source on Mac</title>
		<link>http://dready.org/blog/2010/03/11/debugging-without-source-on-mac/</link>
		<comments>http://dready.org/blog/2010/03/11/debugging-without-source-on-mac/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 10:04:52 +0000</pubDate>
		<dc:creator>wil</dc:creator>
				<category><![CDATA[hacks]]></category>
		<category><![CDATA[gdb]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://dready.org/blog/?p=256</guid>
		<description><![CDATA[This is probably newbie stuff for hardcore C programmers, but I&#8217;m logging here for posterity and for my own benefit. I don&#8217;t pretend to be one, but recently found myself needing to find out the cause of a curious message while running Python on my Mac OS X 10.5.8:

Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has [...]


Related posts:<ol><li><a href='http://dready.org/blog/2009/10/09/tornado-with-virtualenv-and-pip-quickstart/' rel='bookmark' title='Permanent Link: Tornado with VirtualEnv and Pip Quickstart'>Tornado with VirtualEnv and Pip Quickstart</a> <small>Friendfeed&#8217;s open source Tornado web server is great, and is incredibly easy to get up-and-running. Just install tornado, write your...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This is probably newbie stuff for hardcore C programmers, but I&#8217;m logging here for posterity and for my own benefit. I don&#8217;t pretend to be one, but recently found myself needing to find out the cause of a curious message while running Python on my Mac OS X 10.5.8:</p>
<pre class="code">
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
</pre>
<p>Okay, this means that my program forked, and the child did not immediately <code>exec()</code>. Instead, it went on to call some Core Foundation function. Naturally, I&#8217;d want to find out what is it that it&#8217;s doing! Time to fire up our trusty <code>gdb</code>.</p>
<pre class="code">
macmac:~ $ sudo gdb -p 52772
GNU gdb 6.3.50-20050815 (Apple version gdb-960) (Sun May 18 18:38:33 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".
Attaching to process 52772.
Reading symbols for shared libraries . done
Reading symbols for shared libraries .................................... done
0x9354a6fa in select$DARWIN_EXTSN ()
(gdb) b __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__
Breakpoint 1 at 0x938df314
(gdb) cont
Continuing.
Breakpoint 1, 0x938df314 in __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__ ()
(gdb) bt
#0  0x938df314 in __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__ ()
#1  0x938d97bd in CFRunLoopGetCurrent ()
#2  0x95bf09fa in +[NSThread currentThread] ()
#3  0x95befe39 in _NSInitializePlatform ()
#4  0x918568b8 in _class_initialize ()
#5  0x9185678c in _class_initialize ()
#6  0x91855239 in _class_lookupMethodAndLoadCache ()
#7  0x918656d6 in objc_msgSend ()
#8  0x9185dbdf in call_load_methods ()
#9  0x918570d3 in load_images ()
#10 0x8fe02e38 in __dyld__ZN4dyld12notifySingleE17dyld_image_statesPK11mach_headerPKcl ()
#11 0x8fe0e7cf in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#12 0x8fe0e775 in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#13 0x8fe0e775 in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#14 0x8fe0e775 in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#15 0x8fe0e775 in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#16 0x8fe0e775 in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#17 0x8fe0e8c9 in __dyld__ZN11ImageLoader15runInitializersERKNS_11LinkContextE ()
#18 0x8fe02202 in __dyld__ZN4dyld15runInitializersEP11ImageLoader ()
#19 0x8fe0bbdd in __dyld_dlopen ()
#20 0x935042c2 in dlopen ()
#21 0x001b09ac in _PyImport_GetDynLoadFunc ()
#22 0x001a35a4 in _PyImport_LoadDynamicModule ()
.. (snipped) ..
</pre>
<p>This tells us that Python was trying to call the <code>dlopen()</code> function to load a dynamic library. I know that because the stacktrace went from a bunch of CPython functions to <code>dlopen()</code> (at stack #20) and eventually led up to the function that we were told to break on. Now it&#8217;s time to find out which library it is trying to load.</p>
<pre class="code">
(gdb) frame 20
#20 0x935042c2 in dlopen ()
(gdb) info frame
Stack level 20, frame at 0xb007d6f0:
 eip = 0x935042c2 in dlopen; saved eip 0x1b09ac
 called by frame at 0xb007d9b0, caller of frame at 0xb007d6d0
 Arglist at 0xb007d6e8, args:
 Locals at 0xb007d6e8, Previous frame's sp is 0xb007d6f0
 Saved registers:
  ebx at 0xb007d6e4, ebp at 0xb007d6e8, eip at 0xb007d6ec
</pre>
<p>If you had the source code for <code>dlopen()</code>, <code>gdb</code> would&#8217;ve helpfully printed the arguments for you, but alas we don&#8217;t have the source code!</p>
<p>Thankfully, we know what the function looks like from the <a href="http://developer.apple.com/Mac/library/documentation/Darwin/Reference/ManPages/man3/dlopen.3.html"><code>dlopen</code> man page</a>:</p>
<pre class="code">
     void *dlopen(const char* path, int mode);
</pre>
<p>So we know that the library we&#8217;re looking for is in the first argument, which is a pointer to a C string. And we will find it.</p>
<p>Some googling later, I found the <a href="http://www.fabiensanglard.net/macosxassembly/index.php">layout for darwin stackframes</a>:</p>
<p><img src="http://www.fabiensanglard.net/macosxassembly/stackDetails.jpg" alt="Mac OS X stack frame layout" /></p>
<p>Sweet! According to this, the first function argument is in <code>EBP+8</code>:</p>
<pre class="code">
(gdb) info registers ebp
ebp            0xb007d6e8	0xb007d6e8
</pre>
<p>Aha! But you didn&#8217;t really need to do that; the <code>info frame</code> command output already told us that locals are at <code>0xb007d6e8</code>.</p>
<p>0xb007d6e8 + 8 = 0xb007d6f0, so we shall get the address stored at this address:</p>
<pre class="code">
(gdb) x/a 0xb007d6f0
0xb007d6f0:	0xb007da67
</pre>
<p>Now print the string at the target address:</p>
<pre class="code">
(gdb) x/s 0xb007da67
0xb007da67:	 "/Users/wil/src/proj/root/lib/python2.5/lib-dynload/icglue.so"
</pre>
<p>Et voila! This happens to be the glue code for Python to access the Mac OS X Internet Config settings. In some previous foray, I learned (to my surprise) that Python&#8217;s <code>urllib</code> (on Darwin) actually uses IC to find out your proxy settings and use it! For some reason, I never expected it to do so but I guess it makes sense for a seamless user experience.</p>
<p>Did I find out why it&#8217;s giving me that fork/exec message? No, not really but it doesn&#8217;t matter much.<br />
(Update: I do know the reason for this; it&#8217;s because some code started fetching from HTTP after fork, but that&#8217;s the expected behavior, and I don&#8217;t wish to reexec. Program continues to work, so I just have to ignore it in my development environment. This will be deployed to a Linux or FreeBSD which is why I said it doesn&#8217;t matter much.)</p>
<p>Now, I&#8217;m convinced that there is a better way to do it so if you have any idea, please leave a comment.</p>
<p>p.s. This can probably be easily achieved with DTrace, but it makes my head spin.</p>


<p>Related posts:<ol><li><a href='http://dready.org/blog/2009/10/09/tornado-with-virtualenv-and-pip-quickstart/' rel='bookmark' title='Permanent Link: Tornado with VirtualEnv and Pip Quickstart'>Tornado with VirtualEnv and Pip Quickstart</a> <small>Friendfeed&#8217;s open source Tornado web server is great, and is incredibly easy to get up-and-running. Just install tornado, write your...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://dready.org/blog/2010/03/11/debugging-without-source-on-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>logcheck update on FreeBSD</title>
		<link>http://dready.org/blog/2010/01/23/logcheck-update-on-freebsd/</link>
		<comments>http://dready.org/blog/2010/01/23/logcheck-update-on-freebsd/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 12:21:27 +0000</pubDate>
		<dc:creator>wil</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dready.org/blog/?p=254</guid>
		<description><![CDATA[Logging this quickly for posterity.
If like me, you just updated the logcheck port on your FreeBSD to version 1.2.69_1 and found that it&#8217;s broken, you might have run into the same permission problem I did.
Apparently, the port installed some files with too restrictive permissions and the error message from logcheck does not help. The files [...]


Related posts:<ol><li><a href='http://dready.org/blog/2010/07/04/httpd-exited-on-signal-11-solved/' rel='bookmark' title='Permanent Link: httpd exited on signal 11 &#8211; solved'>httpd exited on signal 11 &#8211; solved</a> <small>tl;dr It&#8217;s probably mod_php, and try recompiling PHP without zend_multibyte. If you have WITH_MULTIBYTE=true in /var/db/ports/php5/options, change it to WITHOUT_MULTIBYTE=true...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Logging this quickly for posterity.</p>
<p>If like me, you just updated the <a href="http://logcheck.org/">logcheck</a> port on your FreeBSD to version 1.2.69_1 and found that it&#8217;s broken, you might have run into the same permission problem I did.</p>
<p>Apparently, the port installed some files with too restrictive permissions and the error message from logcheck does not help. The files in question are some dynamically interpreted Perl plug-ins to detect rotated files in various schemes.</p>
<p>Just change the permissions as follows and it should all work again:</p>
<p><code><br />
# chmod 644 /usr/local/share/logcheck/detectrotate/*.dtr<br />
</code></p>


<p>Related posts:<ol><li><a href='http://dready.org/blog/2010/07/04/httpd-exited-on-signal-11-solved/' rel='bookmark' title='Permanent Link: httpd exited on signal 11 &#8211; solved'>httpd exited on signal 11 &#8211; solved</a> <small>tl;dr It&#8217;s probably mod_php, and try recompiling PHP without zend_multibyte. If you have WITH_MULTIBYTE=true in /var/db/ports/php5/options, change it to WITHOUT_MULTIBYTE=true...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://dready.org/blog/2010/01/23/logcheck-update-on-freebsd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tornado with VirtualEnv and Pip Quickstart</title>
		<link>http://dready.org/blog/2009/10/09/tornado-with-virtualenv-and-pip-quickstart/</link>
		<comments>http://dready.org/blog/2009/10/09/tornado-with-virtualenv-and-pip-quickstart/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 08:50:37 +0000</pubDate>
		<dc:creator>wil</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[webeng]]></category>
		<category><![CDATA[tornado]]></category>

		<guid isPermaLink="false">http://dready.org/blog/?p=243</guid>
		<description><![CDATA[Friendfeed&#8217;s open source Tornado web server is great, and is incredibly easy to get up-and-running. Just install tornado, write your app and run it.
At some point, however, you&#8217;d want more structure in your project and manage dependencies to ease deployment. This is where virtualenv and pip shines. For a few more steps, you can bootstrap [...]


Related posts:<ol><li><a href='http://dready.org/blog/2010/04/30/trials-tribulations-global-communities/' rel='bookmark' title='Permanent Link: Trials and Tribulations of Global Communities'>Trials and Tribulations of Global Communities</a> <small>I&#8217;m not about to write a lengthy essay on online cultures. Just an interesting observation on some events on the...</small></li>
<li><a href='http://dready.org/blog/2010/07/10/hash-ring-fork/' rel='bookmark' title='Permanent Link: Hash Ring fork'>Hash Ring fork</a> <small>Amir Salihefendic&#8217;s hash_ring module is awesome, but it doesn&#8217;t install cleanly with pip (dies with ez_setup import error) and spews...</small></li>
<li><a href='http://dready.org/blog/2010/01/23/logcheck-update-on-freebsd/' rel='bookmark' title='Permanent Link: logcheck update on FreeBSD'>logcheck update on FreeBSD</a> <small>Logging this quickly for posterity. If like me, you just updated the logcheck port on your FreeBSD to version 1.2.69_1...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Friendfeed&#8217;s open source <a href="http://www.tornadoweb.org/">Tornado web server</a> is great, and is incredibly easy to get up-and-running. Just install tornado, write your app and run it.</p>
<p>At some point, however, you&#8217;d want more structure in your project and manage dependencies to ease deployment. This is where <a href="http://pypi.python.org/pypi/virtualenv">virtualenv</a> and <a href="http://pypi.python.org/pypi/pip">pip</a> shines. For a few more steps, you can bootstrap your project and have the warm fuzzy feeling that you can easily deploy the stuff when the code is ready.</p>
<h3>Installing <code>virtualenv</code> and <code>pip</code></h3>
<p>If you haven&#8217;t set up virtualenv, do so (as root):</p>
<pre class="code">
# easy_install virtualenv
</pre>
<p>Decide where you&#8217;d put your project directory. I&#8217;ll use <code>/path/to/myapp</code> for now. The next step is to create a virtualenv where all your Python packages are stored. I like to use the convention of a directory called <code>root</code> where all dependencies are installed. I&#8217;d generally also use it as the prefix for any <acronym title="./configure &amp;&amp; make &amp;&amp; make install">cmmi</acronym> packages that I&#8217;d like to contain within the project.</p>
<pre class="code">
$ cd /path/to/myapp
$ virtualenv --no-site-packages root
</pre>
<p>Activate the environment that we just created:</p>
<pre class="code">
$ . root/bin/activate
(root)[wil@wasabi /path/to/myapp]$
</pre>
<p>From now on, all packages installed with <code>easy_install</code> will be placed in this virtualenv.</p>
<p>Next, we will install <code>pip</code> into this virtualenv:</p>
<pre class="code">
(root)[wil@wasabi /path/to/myapp]$ easy_install pip
</pre>
<p>Once <code>pip</code> is installed, as long as you&#8217;ve got your virtualenv activated, anything installed with <code>pip</code> will also go into the right place (without your having to remember to use the <code>-E</code> command line argument.)</p>
<h3>Installing Tornado</h3>
<p>Tornado (as of the current version) needs two mandatory dependencies, i.e. <a href="http://pycurl.sourceforge.net/">pycURL</a> and <a href="http://pypi.python.org/pypi/simplejson/">simplejson</a>. Make sure you have the right libcURL version installed on your system (using <code>apt-get</code> or other mechanism) and pick the compatible pyCURL version.</p>
<pre class="code">
(root)[wil@wasabi /path/to/myapp]$ pip install pycurl==7.16.4
(root)[wil@wasabi /path/to/myapp]$ pip install simplejson
</pre>
<p>Now we&#8217;ll install tornado proper. I chose to go with the bleeding edge and ask <code>pip</code> to install from the git trunk.</p>
<pre class="code">
(root)[wil@wasabi /path/to/myapp]$ pip install -e \
  git+git://github.com/facebook/tornado.git#egg=tornado
</pre>
<p>Should you not want that, you can tell <code>pip</code> to install from the tarball URL instead (at least until tornado gets added to PyPI.)</p>
<pre class="code">
(root)[wil@wasabi /path/to/myapp]$ pip install \

http://www.tornadoweb.org/static/tornado-0.2.tar.gz
</pre>
<p>Tornado is installed!</p>
<p>Every now and then, it&#8217;s a good idea to save your pip dependencies by running</p>
<pre class="code">
(root)[wil@wasabi /path/to/myapp]$ pip freeze > pip-req.txt
</pre>
<h3>Start your project</h3>
<p>What I like about this is that the project directory has all the dependencies contained within a single directory (<code>root</code>). This is really just my convention; I&#8217;d create a <code>src</code> directory where my application code lives.</p>
<pre class="code">
(root)[wil@wasabi /path/to/myapp]$ mkdir src
(root)[wil@wasabi /path/to/myapp]$ cd src
(root)[wil@wasabi /path/to/myapp/src]$
</pre>
<p>Let&#8217;s test drive Tornado:</p>
<pre class="code">
(root)[wil@wasabi /path/to/myapp/src]$ cp ../root/src/tornado/demos/helloworld/helloworld.py .
(root)[wil@wasabi /path/to/myapp/src]$ python helloworld.py
</pre>
<p>From browser, visit your host at port <code>8888</code> to verify.</p>
<p>That&#8217;s it!</p>


<p>Related posts:<ol><li><a href='http://dready.org/blog/2010/04/30/trials-tribulations-global-communities/' rel='bookmark' title='Permanent Link: Trials and Tribulations of Global Communities'>Trials and Tribulations of Global Communities</a> <small>I&#8217;m not about to write a lengthy essay on online cultures. Just an interesting observation on some events on the...</small></li>
<li><a href='http://dready.org/blog/2010/07/10/hash-ring-fork/' rel='bookmark' title='Permanent Link: Hash Ring fork'>Hash Ring fork</a> <small>Amir Salihefendic&#8217;s hash_ring module is awesome, but it doesn&#8217;t install cleanly with pip (dies with ez_setup import error) and spews...</small></li>
<li><a href='http://dready.org/blog/2010/01/23/logcheck-update-on-freebsd/' rel='bookmark' title='Permanent Link: logcheck update on FreeBSD'>logcheck update on FreeBSD</a> <small>Logging this quickly for posterity. If like me, you just updated the logcheck port on your FreeBSD to version 1.2.69_1...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://dready.org/blog/2009/10/09/tornado-with-virtualenv-and-pip-quickstart/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Forums are so 1999</title>
		<link>http://dready.org/blog/2009/05/22/forums-are-so-1999/</link>
		<comments>http://dready.org/blog/2009/05/22/forums-are-so-1999/#comments</comments>
		<pubDate>Fri, 22 May 2009 10:48:01 +0000</pubDate>
		<dc:creator>wil</dc:creator>
				<category><![CDATA[rant]]></category>
		<category><![CDATA[forums]]></category>

		<guid isPermaLink="false">http://dready.org/blog/?p=239</guid>
		<description><![CDATA[I cringe forums1 or message board every time I visit one.
They are usually cluttered with distracting animated gifs, elaborate signatures and tons of useless stats about the posters (novice/expert level, im status, joining date, etc.)
They are notoriously cumbersome to navigate, let alone find what you need. The forum administrators and moderators know it, so most [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I cringe <a href="http://en.wikipedia.org/wiki/Internet_forum">forums</a><sub>1</sub> or message board every time I visit one.</p>
<p>They are usually cluttered with distracting animated gifs, elaborate signatures and tons of useless stats about the posters (novice/expert level, im status, joining date, etc.)</p>
<p>They are notoriously cumbersome to navigate, let alone find what you need. The forum administrators and moderators know it, so most forums use stickies as a band-aid. For the casual visitor, stickies are usually road signs that tell you where to look for certain things, a summary of important points or FAQs. Needless to say, they&#8217;re pretty effective when you compare them with the rest of the mess, but a band-aid nonetheless.</p>
<p>I&#8217;d blame the user interface for this awkward communication medium. It&#8217;s not so much due to its age, because I&#8217;d rather read stuff on old skool NNTP with vi key bindings than to navigate these forums. Rather, it&#8217;s the constant need for paging (displaying page 1 of 32!!), which means that you can&#8217;t effectively use the browser&#8217;s in-page find feature. Search is usually broken or otherwise less than relevant. No threading, nor ability to easily filter messages. I could go on.</p>
<p>Perhaps it&#8217;s just a matter of tweaking the skin and applying sane user interface design. Certainly, there are some better-designed forums out there that are less painful to use. I haven&#8217;t seen much innovation in that area in a long time, actually not since my first encounter with them. I suspect people actually <em>like</em> and have come to expect those cumbersome features.</p>
<p>Forum communities are an entire subculture of their own, and I don&#8217;t expect a shift anytime soon. Yet, I can&#8217;t help but wonder if we can do better.</p>
<p><sub>1</sub> In case you&#8217;re wondering, I intentionally used the word <a href="http://en.wiktionary.org/wiki/Talk:forum">&#8220;forums&#8221; instead of &#8220;fora&#8221;</a>. </p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://dready.org/blog/2009/05/22/forums-are-so-1999/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
