<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Bearfruit</title>
	
	<link>http://www.bearfruit.org</link>
	<description>Matthew Nuzum's Blog</description>
	<lastBuildDate>Thu, 10 May 2012 14:23:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2-bleeding</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/bearfruit" /><feedburner:info uri="bearfruit" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>41.637638</geo:lat><geo:long>-93.616366</geo:long><item>
		<title>Better tab completion for Mac OS</title>
		<link>http://feedproxy.google.com/~r/bearfruit/~3/57eQajRZHp8/</link>
		<comments>http://www.bearfruit.org/2012/05/10/better-tab-completion-for-mac-os/#comments</comments>
		<pubDate>Thu, 10 May 2012 14:06:51 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.bearfruit.org/?p=558</guid>
		<description><![CDATA[When I use Mac OS I miss Ubuntu. I spend a lot of time in the terminal (in either OS) and find it frustrating how Mac is brain-dead when it comes to tab completion. Fortunately, some helpful souls have worked to fix the issue. There are only three steps: Install Homebrew Install bash-completion with this [...]]]></description>
			<content:encoded><![CDATA[<p>When I use Mac OS I miss Ubuntu. I spend a lot of time in the terminal (in either OS) and find it frustrating how Mac is brain-dead when it comes to tab completion. Fortunately, some helpful souls have worked to fix the issue. There are only three steps:<span id="more-558"></span></p>
<ol>
<li>Install <a href="http://mxcl.github.com/homebrew/">Homebrew</a></li>
<li>Install bash-completion with this command: <em>brew install bash-completion</em>  (optionally rails-completion too)</li>
<li>Activate it by following the instructions from the previous command, which entails adding these lines to ~/.bash_profile:</li>
</ol>
<div>
<pre>if [ -f `brew --prefix`/etc/bash_completion ]; then
  . `brew --prefix`/etc/bash_completion
fi</pre>
</div>
<div>Close your terminal and reopen to get the benefits. The first thing you may notice is that brew install &lt;tab&gt; &lt;tab&gt; gives you a list of things y ou can install.</div>
<div>It&#8217;s not as good as just using Ubuntu but it does ease the pain somewhat.</div>
<img src="http://feeds.feedburner.com/~r/bearfruit/~4/57eQajRZHp8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bearfruit.org/2012/05/10/better-tab-completion-for-mac-os/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bearfruit.org/2012/05/10/better-tab-completion-for-mac-os/</feedburner:origLink></item>
		<item>
		<title>Learning Mock with Michael Foord</title>
		<link>http://feedproxy.google.com/~r/bearfruit/~3/vGkUBOs5p-g/</link>
		<comments>http://www.bearfruit.org/2012/03/31/learning-mock-with-michael-foord/#comments</comments>
		<pubDate>Sat, 31 Mar 2012 04:10:24 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.bearfruit.org/?p=553</guid>
		<description><![CDATA[Mocking is a technique to help you test your code by replacing the pieces that don&#8217;t need to be tested with &#8220;mock&#8221; objects that behave in a similar way. For example, if you want to test a module that returns the weather from a web service, you can &#8220;mock&#8221; the web service so that it [...]]]></description>
			<content:encoded><![CDATA[<p>Mocking is a technique to help you test your code by replacing the pieces that don&#8217;t need to be tested with &#8220;mock&#8221; objects that behave in a similar way. For example, if you want to test a module that returns the weather from a web service, you can &#8220;mock&#8221; the web service so that it returns predictable results. Here is a three part video I&#8217;ve created with Michael Foord, author of the Python Mock library which will be included in Python 3.3.</p>
<p><a href="http://youtu.be/d3_LdLzWSXQ">A Gentle Introduction to Mock for Python</a> (part 1 of 3 &#8211; 13min)</p>
<p><a href="http://youtu.be/ADIcwu2GeEU">Why use Mock?</a> (part 2 of 3 &#8211; 3.5min)</p>
<p><a href="http://youtu.be/yFA-FFaEZPo">Mock and Django</a> (part 3 of 3 &#8211; 38min)</p>
<img src="http://feeds.feedburner.com/~r/bearfruit/~4/vGkUBOs5p-g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bearfruit.org/2012/03/31/learning-mock-with-michael-foord/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bearfruit.org/2012/03/31/learning-mock-with-michael-foord/</feedburner:origLink></item>
		<item>
		<title>Conservatives distrust science? So right, and yet so wrong</title>
		<link>http://feedproxy.google.com/~r/bearfruit/~3/JIiNwQp6S0M/</link>
		<comments>http://www.bearfruit.org/2012/03/30/conservatives-distrust-science-so-right-and-yet-so-wrong/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 04:29:53 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.bearfruit.org/?p=547</guid>
		<description><![CDATA[I should know better than to read the news right before bed. I know I&#8217;m not going to be able to sleep tonight without mentioning this. Daring Fireball author John Gruber posted a link to an article on MSNBC.com that studied 36 years of polling data and came to the conclusion that conservatives&#8217; confidence in [...]]]></description>
			<content:encoded><![CDATA[<p>I should know better than to read the news right before bed. I know I&#8217;m not going to be able to sleep tonight without mentioning this. Daring Fireball author John Gruber posted a <a href="http://daringfireball.net/linked/2012/03/29/conservatives-science">link to an article</a> on MSNBC.com that studied 36 years of polling data and came to the conclusion that conservatives&#8217; confidence in science as an institution has <a href="http://cosmiclog.msnbc.msn.com/_news/2012/03/29/10911111-study-tracks-how-conservatives-lost-their-faith-in-science">steadily declined in America</a>. He&#8217;s right, it is a shame, but it would have helped if the &#8220;news&#8221; article wasn&#8217;t actually written as a PR stunt to sell a book by Chris Mooney.<span id="more-547"></span></p>
<p>Do you remember some time ago when a highly inflammatory story <a href="http://online.wsj.com/article/SB10001424052748704111504576059713528698754.html">hit the news</a> about the Chinese &#8220;Tiger Mom&#8221; method of parenting? It got people very upset but it was a carefully crafted piece designed to do exactly one thing: sell a book.</p>
<p>I don&#8217;t doubt the data in the article about conservatives. As a conservative, I can admit that it does echo my own sentiment. I love science and <a href="http://en.wikipedia.org/wiki/Empirical_research">empirical research</a> but I feel that many leading scientific institutions are driven not be a desire to inform and expand their knowledge but in many cases some other agenda, often times personal greed.</p>
<p>But I laughed out loud as I read down the article and came to this part: (emphasis mine)</p>
<blockquote><p>Gauchat took on this project to assess the claims made by science journalist Chris Mooney in his 2005 book, &#8220;The Republican War on Science&#8221; — and <strong>Mooney, who reviewed the paper before publication</strong>, said the findings confirmed those claims.</p>
<p><strong>Now Mooney is coming out with another book</strong>, titled &#8220;The Republican Brain: The Science of Why They Don&#8217;t Believe in Science.&#8221;</p></blockquote>
<p>What a coincidence! The author has a new book ready to hit the shelves, just at the exact time a study was released that announces exactly the same thing, and, look at this, it uses almost the exact wording as the title of the book!</p>
<p>If you want to learn more about this method of PR, please read the excellent article <a href="http://paulgraham.com/submarine.html">&#8220;The Submarine&#8221; by Paul Graham</a>.</p>
<img src="http://feeds.feedburner.com/~r/bearfruit/~4/JIiNwQp6S0M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bearfruit.org/2012/03/30/conservatives-distrust-science-so-right-and-yet-so-wrong/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bearfruit.org/2012/03/30/conservatives-distrust-science-so-right-and-yet-so-wrong/</feedburner:origLink></item>
		<item>
		<title>Using Selenium Simple Test</title>
		<link>http://feedproxy.google.com/~r/bearfruit/~3/rEMS3tsVEZg/</link>
		<comments>http://www.bearfruit.org/2012/01/06/using-selenium-simple-test/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 04:20:09 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.bearfruit.org/?p=556</guid>
		<description><![CDATA[Unit tests are a great way to test your code but some interactions are hard to verify unless you open a browser and click around. Selenium is a great tool for automating a web browser but the learning curve is a bit steep. Selenium Simple Test is an easy to learn tool that allows you [...]]]></description>
			<content:encoded><![CDATA[<p>Unit tests are a great way to test your code but some interactions are hard to verify unless you open a browser and click around. Selenium is a great tool for automating a web browser but the learning curve is a bit steep. Selenium Simple Test is an easy to learn tool that allows you to harness the power of Selenium for your own projects.</p>
<p>Here is a two-part video series that I recorded to help you understand SST and begin using it for your projects.</p>
<p><a href="http://youtu.be/qGPostUOAEI">Selenium Simple Test quick demo</a> (5 min)</p>
<p><a href="http://youtu.be/TyWMJdWJFE4">Interview with SST creator Corey Goldburg</a> (23 min)</p>
<img src="http://feeds.feedburner.com/~r/bearfruit/~4/rEMS3tsVEZg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bearfruit.org/2012/01/06/using-selenium-simple-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bearfruit.org/2012/01/06/using-selenium-simple-test/</feedburner:origLink></item>
		<item>
		<title>How to turn $10 into $100</title>
		<link>http://feedproxy.google.com/~r/bearfruit/~3/Qf9uv-yVeNY/</link>
		<comments>http://www.bearfruit.org/2011/12/28/how-to-turn-10-into-100/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 20:34:02 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Humor]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.bearfruit.org/?p=543</guid>
		<description><![CDATA[It&#8217;s called &#8220;work.&#8221; It&#8217;s good for you.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s called &#8220;work.&#8221; It&#8217;s good for you.</p>
<p><a href="http://www.bearfruit.org/wp-content/uploads/2011/12/20111226_105356.jpg"><img class="alignnone size-medium wp-image-545" title="A shovel" src="http://www.bearfruit.org/wp-content/uploads/2011/12/20111226_105356-225x300.jpg" alt="" width="225" height="300" /></a></p>
<img src="http://feeds.feedburner.com/~r/bearfruit/~4/Qf9uv-yVeNY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bearfruit.org/2011/12/28/how-to-turn-10-into-100/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bearfruit.org/2011/12/28/how-to-turn-10-into-100/</feedburner:origLink></item>
		<item>
		<title>If the latest news is upsetting you</title>
		<link>http://feedproxy.google.com/~r/bearfruit/~3/OJYeS1JEACs/</link>
		<comments>http://www.bearfruit.org/2011/12/19/if-the-latest-news-is-upsetting-you/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 18:29:56 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.bearfruit.org/?p=538</guid>
		<description><![CDATA[I just want to remind everyone in the USA that this is a special time in our political process. Election season is beginning soon, and furthermore, there is an incumbent in office. Therefore the opposing party&#8217;s #1 goal is to show that the existing president is doing a poor job. It is their only chance. [...]]]></description>
			<content:encoded><![CDATA[<p>I just want to remind everyone in the USA that this is a special time in our political process. Election season is beginning soon, and furthermore, there is an incumbent in office. Therefore the opposing party&#8217;s #1 goal is to show that the existing president is doing a poor job. It is their only chance.</p>
<p>What this means is that every little mistake and unpopular decision, and believe me, everyone in authority makes mistakes and/or unpopular decisions, will be magnified as much as possible.<span id="more-538"></span></p>
<p>Also keep in mind that now, as ever, the media is in the business of selling advertisements and therefore needs to pull out all the stops in order to get your eye-balls on their ads. The aforementioned unrest gives them a lot of opportunities to write tantalizing and alarmist headlines.</p>
<p>This can be quite discouraging to the general public. It will take effort on the part of readers to discern between real news and parading. It will require great self control not to fall into the trap of forwarding the latest ghastly headline or being outraged at the audacity of such events.</p>
<p>Definitely keep up on what&#8217;s happening, speak out against what is wrong, but remember to keep a cool head and don&#8217;t get too upset. If you find yourself getting a little discouraged, remember to <a href="http://youtu.be/WlBiLNN1NhQ">always look at the bright side</a>.</p>
<img src="http://feeds.feedburner.com/~r/bearfruit/~4/OJYeS1JEACs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bearfruit.org/2011/12/19/if-the-latest-news-is-upsetting-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bearfruit.org/2011/12/19/if-the-latest-news-is-upsetting-you/</feedburner:origLink></item>
		<item>
		<title>UI considerations for 2 factor authentication</title>
		<link>http://feedproxy.google.com/~r/bearfruit/~3/eXMk9m-sTk8/</link>
		<comments>http://www.bearfruit.org/2011/05/18/ui-considerations-for-2-factor-authentication/#comments</comments>
		<pubDate>Wed, 18 May 2011 20:07:43 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.bearfruit.org/?p=524</guid>
		<description><![CDATA[As an experimental work project, my team is evaluating the yubikey as a 2 factor authentication device for login.ubuntu.com. The user interface suggested by Yubico leaves me wishing for something better. Here is an idea I have, please let me know your thoughts.]]></description>
			<content:encoded><![CDATA[<p>As an experimental work project, my team is evaluating the <a href="http://www.yubico.com/start">yubikey</a> as a 2 factor authentication device for <a href="https://login.ubuntu.com/+login">login.ubuntu.com</a>. The user interface suggested by Yubico leaves me wishing for something better. Here is an idea I have, please let me know your thoughts.</p>
<p><iframe src="http://www.youtube.com/embed/vwk33dkKgoc?rel=0" frameborder="0" width="560" height="349" style="width:560px; height:349px"></iframe></p>
<img src="http://feeds.feedburner.com/~r/bearfruit/~4/eXMk9m-sTk8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bearfruit.org/2011/05/18/ui-considerations-for-2-factor-authentication/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.bearfruit.org/2011/05/18/ui-considerations-for-2-factor-authentication/</feedburner:origLink></item>
		<item>
		<title>Does the Bible say the world will end May 21st?</title>
		<link>http://feedproxy.google.com/~r/bearfruit/~3/LmumRx_QXXc/</link>
		<comments>http://www.bearfruit.org/2011/05/18/does-the-bible-say-the-world-will-end-may-21st/#comments</comments>
		<pubDate>Wed, 18 May 2011 14:14:47 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[bible]]></category>
		<category><![CDATA[Biblical]]></category>
		<category><![CDATA[Church]]></category>
		<category><![CDATA[Theology]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.bearfruit.org/?p=516</guid>
		<description><![CDATA[Here in America and likely abroad you may have seen billboards or heard news that the world is ending May 21st. The scale of the advertising campaign proclaiming this event lends a little bit of credibility to it. A website erected for this event contains detailed arguments and expositions explaining how this man, Harold Camping, [...]]]></description>
			<content:encoded><![CDATA[<p>Here in America and likely abroad you may have seen billboards or heard news that the world is ending May 21st. The scale of the advertising campaign proclaiming this event lends a little bit of credibility to it. A <a href="http://www.ebiblefellowship.com/outreach/tracts/may21/">website erected for this event</a> contains detailed arguments and expositions explaining how this man, Harold Camping, came to the date. Unfortunately Harold&#8217;s arguments have a very simple flaw that completely ruin this entire premise.<span id="more-516"></span></p>
<p>Unfortunately, to understand the flaw you have to decide where you stand. There are three responses to the claims,</p>
<ol>
<li>You don&#8217;t really care</li>
<li>You believe that God cannot lie and everything he says is true</li>
<li>You think that it is possible for there to be encoded, hidden messages in the text of the Bible</li>
</ol>
<p>Points 2 and 3 don&#8217;t sound like opposites but God says in <a href="http://www.biblegateway.com/passage/?search=Isaiah%2045:19&amp;version=NLT">Isaiah 45:19</a> &#8220;I publicly proclaim bold promises, I don&#8217;t whisper obscurities in some dark corner.&#8221; Therefore if you believe option #2 then you can safely assume that God&#8217;s word is plain and there are no hidden obscurities.</p>
<p>In Hebrews 6:18 it says that &#8220;it is impossible for God to lie.&#8221; Therefore I feel safe in the confidence that when Jesus said of God in <a href="http://www.biblegateway.com/passage/?search=Matthew%2024:36&amp;version=NLT">Matthew 24:36</a> that &#8220;Regarding the [date and time] &#8230; only the Father knows,&#8221; and in <a href="http://www.biblegateway.com/passage/?search=Acts%201:7&amp;version=NLT">Acts 1:7</a>, regarding the date and time the world would end &#8220;&#8230;it is not for you to know,&#8221; he was speaking the plain and simple truth: there is no encoded message about the date the world would end.</p>
<p>The surest way to identify a cult is by the leader proclaiming to have some special, secret knowledge that is not easily found in the Bible. Again, referring back to <a href="http://www.biblegateway.com/passage/?search=Isaiah%2045:19&amp;version=NLT">Isaiah 45:19</a> &#8220;I would not have told [them] to seek me if I could not be found.&#8221; Again in <a href="http://www.biblegateway.com/passage/?search=Psalm%20119:104-105&amp;version=NLT">Psalm 119:104-105</a> &#8220;Your commandments give understanding&#8230; your word is a lamp to guide my feet.&#8221; I could go on and on, you don&#8217;t need special revelation to comprehend God&#8217;s word.</p>
<p>Anytime someone says there&#8217;s a secret hidden in the bible that only a super-smart person (or a person with a special angel or revelation) can locate, they are lying.</p>
<h2>So there&#8217;s nothing to fear, right?</h2>
<p>The end of the world could be today or next week or next century. God has said there will be an end (cf <a href="http://www.biblegateway.com/passage/?search=Revelation%2021:1&amp;version=NLT">Revelation 21:1</a>) and no one but Him knows when it is. Or you very likely could die before the end of the world. In either case, when the time comes you will fall into one of two camps:</p>
<ol>
<li>Those that know Jesus as the son of God</li>
<li>Those that don&#8217;t</li>
</ol>
<p>There is no division for people who were really nice or had good intentions or didn&#8217;t commit any horrible crimes. There&#8217;s not even a special category for people who don&#8217;t believe in God. Either you will stand in front of the throne of glory and be declared righteous because of the great thing that Jesus did, able to offer your good deeds as a gift to lay at God&#8217;s feet, or you will stand in front of the throne of judgement and will be shown unworthy to be in the presence of God.</p>
<p>When your life has ended there is no more that can be done for you, either by yourself or others on your behalf. Follow the <a href="http://www.biblegateway.com/passage/?search=Luke%2023:40-43&amp;version=NLT">example of the thief on the cross</a> next to Jesus. He realized who Jesus was, felt shame for living a life in opposition to God and asked Jesus to remember him. Jesus assured him that he would join Jesus in heaven. That is all it takes. Don&#8217;t wait until the day of your death though.</p>
<img src="http://feeds.feedburner.com/~r/bearfruit/~4/LmumRx_QXXc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bearfruit.org/2011/05/18/does-the-bible-say-the-world-will-end-may-21st/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bearfruit.org/2011/05/18/does-the-bible-say-the-world-will-end-may-21st/</feedburner:origLink></item>
		<item>
		<title>Django: sorting by popularity</title>
		<link>http://feedproxy.google.com/~r/bearfruit/~3/sdj4ShwUzg4/</link>
		<comments>http://www.bearfruit.org/2011/04/28/django-sorting-by-popularity/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 02:35:46 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.bearfruit.org/?p=509</guid>
		<description><![CDATA[Imagine you have a list of categories and you want to sort them by popularity, so that the most used categories are first. Django&#8217;s documentation left me scratching my head a bit. It took some time and fiddling to work out a good way to do it, I hope this is helpful and clear to [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine you have a list of categories and you want to sort them by popularity, so that the most used categories are first. Django&#8217;s <a href="http://docs.djangoproject.com/en/1.3/topics/db/aggregation/">documentation</a> left me scratching my head a bit. It took some time and fiddling to work out a good way to do it, I hope this is helpful and clear to you.<span id="more-509"></span></p>
<div class="highlight">
<pre><span style="color: #007020; font-weight: bold;">class</span> <span style="color: #0e84b5; font-weight: bold;">Pet</span>(models<span style="color: #666666;">.</span>Model):
    user <span style="color: #666666;">=</span> models<span style="color: #666666;">.</span><span style="color: #007020;">ForeignKey</span>(User)
    animal <span style="color: #666666;">=</span> models<span style="color: #666666;">.</span><span style="color: #007020;">ForeignKey</span>(Animal)
    name <span style="color: #666666;">=</span> models<span style="color: #666666;">.</span><span style="color: #007020;">CharField</span>(max_length<span style="color: #666666;">=</span><span style="color: #40a070;">40</span>)

<span style="color: #007020; font-weight: bold;">class</span> <span style="color: #0e84b5; font-weight: bold;">Animal</span>(models<span style="color: #666666;">.</span>Model):
    legs <span style="color: #666666;">=</span> models<span style="color: #666666;">.</span><span style="color: #007020;">IntegerField</span>()
    fur <span style="color: #666666;">=</span> models<span style="color: #666666;">.</span>BoolField()
    name <span style="color: #666666;">=</span> models<span style="color: #666666;">.</span><span style="color: #007020;">CharField</span>(max_length<span style="color: #666666;">=</span><span style="color: #40a070;">40</span>)

animals <span style="color: #666666;">=</span> Animal<span style="color: #666666;">.</span>objects<span style="color: #666666;">.</span>annotate(popularity<span style="color: #666666;">=</span>Count(<span style="color: #4070a0;">'pet'</span>))<span style="color: #666666;">.</span>order_by(<span style="color: #4070a0;">'-popularity'</span>)</pre>
</div>
<p>You see here that Animal is not related to Pet directly, so you need to do a reverse lookup. Whenever I see Django do this I think it must be magic. Notice that there is no field named &#8220;popularity.&#8221; Instead, we define it with our annotation. Then we can sort by it with our order_by.</p>
<img src="http://feeds.feedburner.com/~r/bearfruit/~4/sdj4ShwUzg4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bearfruit.org/2011/04/28/django-sorting-by-popularity/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.bearfruit.org/2011/04/28/django-sorting-by-popularity/</feedburner:origLink></item>
		<item>
		<title>4 hour work week: another way</title>
		<link>http://feedproxy.google.com/~r/bearfruit/~3/T60plpHxhbk/</link>
		<comments>http://www.bearfruit.org/2011/04/22/4-hour-work-week-another-way/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 15:50:12 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Humor]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.bearfruit.org/?p=502</guid>
		<description><![CDATA[There was a book that made a lot of ruckus a while back called &#8220;The four hour workweek&#8221; by Timothy Ferriss. The premise was that you could do some clever stuff and live comfortably now instead of waiting until you retire. I recently had an idea on a different way to enjoy the four hour work week, [...]]]></description>
			<content:encoded><![CDATA[<p>There was a book that made a lot of ruckus a while back called &#8220;<a href="http://amzn.to/eiPt5z">The four hour workweek</a>&#8221; by Timothy Ferriss. The premise was that you could do some clever stuff and live comfortably now instead of waiting until you retire. I recently had an idea on a different way to enjoy the four hour work week, but first we need to revisit some basic principles of high school physics.<span id="more-502"></span></p>
<p>Remember basic electricity concepts? You can dim a light bulb by adding some additional resistance. This is of course the worst way to dim a bulb because it doesn&#8217;t actually use any less energy. The power that would have gone to make the bulb bright is instead going to the resistance and being turned into heat. There&#8217;s a much better way.</p>
<p>Imagine that you could switch the bulb on and off very fast. If you turned it on for 1/100&#8242;th of a second and then back off for 1/100th of a second constantly then it would effectively be on half the time and off half the time. Therefore it would only receive half as much power and would be half as bright. If you turned it on for 1/100th of a second and off for 3/100th&#8217;s of a second it would only get 25% of the power and would be 1/4th as bright.</p>
<p>This is called <a href="http://en.wikipedia.org/wiki/Pulse-width_modulation">pulse width modulation</a> and is in fact how dimmers work (basically). This is also the proper way to slow down motors.</p>
<p>So this is my principle. If you work just 6 seconds out of every minute for 8 hours a day over the course of a 40 hour week you&#8217;ll work the equivalent of only 4 hours per week. (6 out of 60 seconds is 10% duty cycle and 10% of 40 hours is 4) Maybe you can get 10 jobs at once using this technique and retire in only 3.5 years.</p>
<p>I&#8217;ve not actually tried this yet, since I believe I should actually be working the full time I&#8217;m getting paid to work. Therefore I&#8217;m tossing this idea out into the public domain. Feel free to use it to get rich and famous.</p>
<img src="http://feeds.feedburner.com/~r/bearfruit/~4/T60plpHxhbk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bearfruit.org/2011/04/22/4-hour-work-week-another-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bearfruit.org/2011/04/22/4-hour-work-week-another-way/</feedburner:origLink></item>
	</channel>
</rss>

