<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom">
 
  <title>Kyle Banker | Hwaet!</title>
  <subtitle>(hwaet - it means, "ho there!")</subtitle>
  
  <link href="http://kylebanker.com/" />
  <updated>2009-11-07T11:05:16-05:00</updated>
  <author>
    <name>Kyle Banker</name>
    <email>kylebanker@gmail.com</email>
  </author>
  <id>http://kylebanker.com/</id>
  
  <link rel="self" href="http://feeds.feedburner.com/KyleBanker" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry>
    <title>MongoDB in Three Minutes</title>
    <link href="/blog/2009/11/mongodb-in-three-minutes/" />
    <id>tag:kylebanker.com,2009-11-05:1257472772</id>
    <updated>2009-11-05T20:59:32-05:00</updated>
    <content type="html">&lt;p&gt;Couple nights back, I was given three minutes to demonstrate MongoDB before a
somewhat large group of people who&amp;#8217;d never heard of it. &lt;a href="http://github.com/banker/mongodb_examples"&gt;Source code is on
github&lt;/a&gt;. At one minute each, the highlights are these:&lt;/p&gt;


	&lt;h3&gt;&lt;strong&gt;1. Schema-free documents.&lt;/strong&gt;&lt;/h3&gt;


	&lt;p&gt;MongoDB is schema-free; this means that the structure of MongoDB data need not be defined up front.
MongoDB stores data as collections of documents. A document can be thought of
as a JSON object, Python dictionary, or Ruby hash (among other things). Documents are natural,
elegant ways of representing data, and are of the essence of MongoDB.&lt;/p&gt;


	&lt;p&gt;Suppose we want to download a few tweets.&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;&lt;span class="Comment"&gt;&lt;span class="Comment"&gt;#&lt;/span&gt; DB connection and collection&lt;/span&gt;
&lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;db&lt;/span&gt;  &lt;span class="Keyword"&gt;=&lt;/span&gt; &lt;span class="Support"&gt;Mongo&lt;/span&gt;::&lt;span class="Entity"&gt;Connection&lt;/span&gt;.&lt;span class="Entity"&gt;new&lt;/span&gt;.&lt;span class="Entity"&gt;db&lt;/span&gt;(&lt;span class="Variable"&gt;DATABASE_NAME&lt;/span&gt;)
&lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;nyc&lt;/span&gt; &lt;span class="Keyword"&gt;=&lt;/span&gt; &lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;db&lt;/span&gt;.&lt;span class="Entity"&gt;collection&lt;/span&gt;(&lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;nyc&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt;)

(&lt;span class="Constant"&gt;1&lt;/span&gt;..&lt;span class="Constant"&gt;5&lt;/span&gt;).&lt;span class="Entity"&gt;each&lt;/span&gt; &lt;span class="Keyword"&gt;do &lt;/span&gt;|&lt;span class="Variable"&gt;page&lt;/span&gt;|
  &lt;span class="Support"&gt;Twitter&lt;/span&gt;::&lt;span class="Entity"&gt;Search&lt;/span&gt;.&lt;span class="Entity"&gt;new&lt;/span&gt;(&lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;nyc&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt;).&lt;span class="Entity"&gt;page&lt;/span&gt;(page).&lt;span class="Entity"&gt;each&lt;/span&gt; &lt;span class="Keyword"&gt;do &lt;/span&gt;|&lt;span class="Variable"&gt;tweet&lt;/span&gt;|
    &lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;nyc&lt;/span&gt;.&lt;span class="Entity"&gt;save&lt;/span&gt;(tweet)
  &lt;span class="Keyword"&gt;end&lt;/span&gt;
&lt;span class="Keyword"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


	&lt;p&gt;That gets us the first five pages of &amp;#8216;nyc&amp;#8217;-related tweets and saves them to the
our &amp;#8216;nyc&amp;#8217; collection in the db. For each tweet, the Twitter gem returns a Ruby
hash, which saves naturally to the database.&lt;/p&gt;


	&lt;h3&gt;&lt;strong&gt;2. Dynamic queries.&lt;/strong&gt;&lt;/h3&gt;


	&lt;p&gt;MongoDB speaks the language of documents, enabling expressive queries. To take
a few examples:&lt;/p&gt;


	&lt;p&gt;We can query for a specific key:&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;  &lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;nyc&lt;/span&gt; &lt;span class="Keyword"&gt;=&lt;/span&gt; &lt;span class="Variable"&gt;DB&lt;/span&gt;.&lt;span class="Entity"&gt;collection&lt;/span&gt;(&lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;nyc&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt;)
  &lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;nyc&lt;/span&gt;.&lt;span class="Entity"&gt;find&lt;/span&gt;(&lt;span class="Constant"&gt;&lt;span class="Constant"&gt;:&lt;/span&gt;username&lt;/span&gt; =&amp;gt; &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;hwaet&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)  
&lt;/pre&gt;&lt;/div&gt;


	&lt;p&gt;Or on a nested key pointing to an array:&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;  &lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;nyc&lt;/span&gt;.&lt;span class="Entity"&gt;find&lt;/span&gt;(&lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;user.followers&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; {&lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;234352343&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt;})  
&lt;/pre&gt;&lt;/div&gt;


	&lt;p&gt;We can search a field using a regular expression:&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;  &lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;nyc&lt;/span&gt;.&lt;span class="Entity"&gt;find&lt;/span&gt;(&lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;text&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class="StringRegexp"&gt;&lt;span class="StringRegexp"&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class="StringRegexp"&gt;z.+&lt;/span&gt;&lt;span class="StringRegexp"&gt;&lt;span class="StringRegexp"&gt;/&lt;/span&gt;&lt;/span&gt;})  
&lt;/pre&gt;&lt;/div&gt;


	&lt;p&gt;Or query across a date range:&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;  &lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;nyc&lt;/span&gt;.&lt;span class="Entity"&gt;find&lt;/span&gt;(&lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;created_at&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; {&lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;$lte&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class="Support"&gt;Time&lt;/span&gt;.&lt;span class="Entity"&gt;now&lt;/span&gt; &lt;span class="Keyword"&gt;-&lt;/span&gt; (&lt;span class="Constant"&gt;60&lt;/span&gt;&lt;span class="Keyword"&gt;*&lt;/span&gt;&lt;span class="Constant"&gt;60&lt;/span&gt;&lt;span class="Keyword"&gt;*&lt;/span&gt;&lt;span class="Constant"&gt;24&lt;/span&gt;)}})  
&lt;/pre&gt;&lt;/div&gt;


	&lt;p&gt;And all of this can be efficient because each collection can define up to 40
secondary indexes:&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;  &lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;nyc&lt;/span&gt;.&lt;span class="Entity"&gt;create_index&lt;/span&gt;([&lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;text&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="Constant"&gt;1&lt;/span&gt;])
  &lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;nyc&lt;/span&gt;.&lt;span class="Entity"&gt;create_index&lt;/span&gt;([&lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;user.followers&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="Constant"&gt;1&lt;/span&gt;])
  &lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;nyc&lt;/span&gt;.&lt;span class="Entity"&gt;create_index&lt;/span&gt;([from_user, &lt;span class="Constant"&gt;1&lt;/span&gt;], [&lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;created_at&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="Keyword"&gt;-&lt;/span&gt;&lt;span class="Constant"&gt;1&lt;/span&gt;])
&lt;/pre&gt;&lt;/div&gt;


	&lt;h3&gt;&lt;strong&gt;3. Binary Storage&lt;/strong&gt;&lt;/h3&gt;


	&lt;p&gt;What if we want to store images, videos, or music? MongoDB stores arbitrary
binary data, too.&lt;/p&gt;


	&lt;p&gt;This code goes through our collection of tweets, fetches each user&amp;#8217;s profile
image, and saves it to the database using GridFS (i.e., MongoDB&amp;#8217;s specification for storing
larger binary objects).&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;&lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;nyc&lt;/span&gt;.&lt;span class="Entity"&gt;find&lt;/span&gt;.&lt;span class="Entity"&gt;each&lt;/span&gt; &lt;span class="Keyword"&gt;do &lt;/span&gt;|&lt;span class="Variable"&gt;tweet&lt;/span&gt;|
  filename &lt;span class="Keyword"&gt;=&lt;/span&gt; tweet[&lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;from_user&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt;].&lt;span class="Entity"&gt;downcase&lt;/span&gt; &lt;span class="Keyword"&gt;+&lt;/span&gt; &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;.jpg&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class="Keyword"&gt;next&lt;/span&gt; &lt;span class="Keyword"&gt;if&lt;/span&gt; &lt;span class="Support"&gt;GridStore&lt;/span&gt;.&lt;span class="Entity"&gt;exist?&lt;/span&gt;(&lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;db&lt;/span&gt;, filename)

  &lt;span class="Support"&gt;GridStore&lt;/span&gt;.&lt;span class="Entity"&gt;open&lt;/span&gt; &lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;db&lt;/span&gt;, filename, &lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;w+&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class="Keyword"&gt;do &lt;/span&gt;|&lt;span class="Variable"&gt;file&lt;/span&gt;|
    data &lt;span class="Keyword"&gt;=&lt;/span&gt; &lt;span class="Entity"&gt;open&lt;/span&gt;(tweet[&lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;profile_image_url&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt;]).&lt;span class="Entity"&gt;read&lt;/span&gt;
    file.&lt;span class="Entity"&gt;content_type&lt;/span&gt; &lt;span class="Keyword"&gt;=&lt;/span&gt; &lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;image/jpeg&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt;
    file.&lt;span class="Entity"&gt;puts&lt;/span&gt; data
  &lt;span class="Keyword"&gt;end&lt;/span&gt;
&lt;span class="Keyword"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


	&lt;p&gt;If we want to serve those images with sinatra:&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;get &lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;/images/:id&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class="Keyword"&gt;do&lt;/span&gt;
  content_type &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;image/jpeg&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
  filename &lt;span class="Keyword"&gt;=&lt;/span&gt; params[&lt;span class="Constant"&gt;&lt;span class="Constant"&gt;:&lt;/span&gt;id&lt;/span&gt;].&lt;span class="Entity"&gt;downcase&lt;/span&gt; &lt;span class="Keyword"&gt;+&lt;/span&gt; &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;.jpg&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class="Support"&gt;GridStore&lt;/span&gt;.&lt;span class="Entity"&gt;read&lt;/span&gt;(&lt;span class="Variable"&gt;DB&lt;/span&gt;, filename)
&lt;span class="Keyword"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


	&lt;h3&gt;&lt;strong&gt;Speed, scalability, ease of use&amp;#8230;&lt;/strong&gt;&lt;/h3&gt;


	&lt;p&gt;All this is to say nothing of
&lt;a href="http://blog.boxedice.com/2009/07/25/choosing-a-non-relational-database-why-we-migrated-from-mysql-to-mongodb/"&gt;production&lt;/a&gt;
&lt;a href="http://www.businessinsider.com/how-we-use-mongodb-2009-11"&gt;case&lt;/a&gt;
&lt;a href="http://compoundthinking.com/blog/index.php/2009/07/16/turbogears-on-sourceforge/"&gt;studies&lt;/a&gt; or &lt;a href="http://www.mongodb.org/display/DOCS/Sharding"&gt;paths
to scalability&lt;/a&gt;. Interested readers
are encouraged to &lt;a href="http://www.mongodb.org/display/DOCS/Downloads"&gt;download a binary&lt;/a&gt; and start experimenting.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Review: Finite and Infinite Games</title>
    <link href="/blog/2009/08/review-finite-and-infinite-games-carse/" />
    <id>tag:kylebanker.com,2009-08-17:1250528226</id>
    <updated>2009-08-17T12:57:06-04:00</updated>
    <content type="html">&lt;p&gt;Western thinkers are fond of dividing the world in two. Though simplistic,
it&amp;#8217;s effective. The flesh vs. spirit characters in the novels of &lt;a href="http://en.wikipedia.org/wiki/Nikos_Kazantzakis"&gt;Nikos
Kazantzakis&lt;/a&gt;
are memorable. The &lt;a href="http://www.amazon.com/Have-Be-Erich-Fromm/dp/0826409121"&gt;modes of having and
being&lt;/a&gt; in &lt;a href="http://en.wikipedia.org/wiki/Erich_Fromm"&gt;Erich
Fromm&lt;/a&gt; are illustrative.
And when &lt;a href="http://en.wikipedia.org/wiki/James_P._Carse"&gt;James P. Carse&lt;/a&gt; wrote about finite and infinite games, we were given
another dichotomous lens for peering into the mysteries of human being.&lt;/p&gt;


	&lt;p&gt;In &lt;a href="http://www.amazon.com/Finite-Infinite-Games-James-Carse/dp/0345341848"&gt;Finite and Infinite
Games&lt;/a&gt;,
Carse asks us to construe human activities &amp;#8211; working, loving, walking, cooking,
reading, driving &amp;#8211; in fact, anything you can imagine &amp;#8211; as kinds of games, and
invites us to consider whether we play these games finitely or infinitely.&lt;/p&gt;


	&lt;p&gt;Finite games are meant to come to an end. They are played for the purpose of
winning, vanquishing an opponent, or bringing about some desired outcome: a
student gains admission to the Ivy League, a worker receives a promotion, a
country goes to war and wins or loses.&lt;/p&gt;


	&lt;p&gt;Finite games are &lt;i&gt;theatrical&lt;/i&gt;. They require an audience to say who has won, to
agree upon an end, and to confer titles upon the winners, which is all but
certain for finite players:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;The outcome of a finite game is the past waiting to happen. Whoever
plays toward a certain outcome desires a particular past. By competing for a
future prize, finite players compete for a prized past.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;Infinite players, on the other hand, play with the spirit of continuing
play. Such play is not theatrical but &lt;i&gt;dramatic&lt;/i&gt;. The drama lies in choosing an
undefined path that is not ultimately for oneself. Artists and visionaries,
those who revel in spontaneity and laughter, who are aware of their places in
society but do not take their places seriously&amp;#8212;these are infinite players.&lt;/p&gt;


	&lt;p&gt;It soon becomes clear that finitude and infinity are not intrinsic to
particular games but to the attitude of the player. The simple act of eating a
meal can be either a finite or infinite game. I might be eating with a certain
end in mind, to gain energy or lose weight or make a political statement. I 
might also eat spontaneously, for no &lt;i&gt;reason&lt;/i&gt; other than to eat.&lt;/p&gt;


	&lt;p&gt;To read this book is to subject our attitudes to the finite-infinite paradigm,
discover that we&amp;#8217;re engaged in both modes of play, and consider to what extent
we&amp;#8217;re comfortable with this. Our conclusion may depend on our response to the book&amp;#8217;s
compelling final chapter, whose subject is myth and whose main idea is
illustrated by the story of Copernicus:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;Copernicus was a traveler who went with a hundred pairs of eyes,
daring to look again at all that is familiar in the hope of vision. What we
hear in this account is the ancient saga of the solitary wanderer, the
peregrinus, who risks anything for the sake of surprise. True, at a certain
point he stopped to look and may have ended his journey as a Master Player
setting down bounded fact. But what resounds most deeply in the life of
Copernicus is the journey that made knowledge possible and not the knowledge
that made the journey successful.&lt;/p&gt;
	&lt;/blockquote&gt;</content>
  </entry>
  
  <entry>
    <title>Simple Proxy with Squid, SSH, and a VPS</title>
    <link href="/blog/2009/08/fun-with-squid-ssh-and-your-vps/" />
    <id>tag:kylebanker.com,2009-08-15:1250384364</id>
    <updated>2009-08-15T20:59:24-04:00</updated>
    <content type="html">&lt;p&gt;Sometimes, while at home browsing the web, I&amp;#8217;ll enter an erroneous address and receive my ISP&amp;#8217;s custom search page &amp;#8211; with suggested links &amp;#8211; as a response. This is always a little unsettling because it reminds me that all of my network traffic is being mediated, and perhaps recorded, by a powerful media conglomorate.&lt;/p&gt;


	&lt;p&gt;If you have a VPS, it&amp;#8217;s easy to set up your own proxy server, connect securely using SSH, and know that any traffic sniffed by your ISP will be encrypted.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;1. Install and configure Squid.&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;re running Ubuntu, you can install &lt;a href="http://www.squid-cache.org/"&gt;Squid&lt;/a&gt;
as follows:&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;
sudo apt&lt;span class="Keyword"&gt;-&lt;/span&gt;get install squid squid&lt;span class="Keyword"&gt;-&lt;/span&gt;common
&lt;/pre&gt;&lt;/div&gt;


	&lt;p&gt;Before starting the server, you&amp;#8217;ll need to make some changes to the squid configuration file
(&lt;strong&gt;/etc/squid/squid.conf&lt;/strong&gt;).&lt;/p&gt;


	&lt;p&gt;First, decide upon a visible_hostname. Squid won&amp;#8217;t start unless this directive is set.&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;
visible_hostname my_funky_proxy_server 
&lt;/pre&gt;&lt;/div&gt;


	&lt;p&gt;Next, make sure that you allow for all http traffic.&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;
http_access allow all
&lt;/pre&gt;&lt;/div&gt;


	&lt;p&gt;Finally, if you&amp;#8217;d like Squid to run on a port other than the default, search for the
http_port directive:&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;
http_port &lt;span class="Constant"&gt;3128&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


	&lt;p&gt;Save your settings and start the squid server.&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;
sudo &lt;span class="Keyword"&gt;/&lt;/span&gt;etc&lt;span class="Keyword"&gt;/&lt;/span&gt;init.&lt;span class="Entity"&gt;d&lt;/span&gt;&lt;span class="Keyword"&gt;/&lt;/span&gt;squid start
&lt;/pre&gt;&lt;/div&gt;


	&lt;p&gt;If Squid starts without any errors, you&amp;#8217;ll have yourself an http proxy server running on port 3128 of your VPS.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;2. Port forwarding with SSH.&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;The next step is to initiate a secure connection between a port on your home
computer and port 3128 (or whichever port Squid is running on) on your VPS. Suppose we choose a local port 2600. Then
we can use SSH to connect like so:&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;
ssh &lt;span class="Keyword"&gt;-&lt;/span&gt;&lt;span class="Variable"&gt;N&lt;/span&gt; &lt;span class="Keyword"&gt;-&lt;/span&gt;&lt;span class="Variable"&gt;L&lt;/span&gt; &lt;span class="Constant"&gt;2600&lt;/span&gt;&lt;span class="Constant"&gt;&lt;span class="Constant"&gt;:&lt;/span&gt;localhost&lt;/span&gt;:&lt;span class="Constant"&gt;3128&lt;/span&gt; me&lt;span class="Variable"&gt;&lt;span class="Variable"&gt;@&lt;/span&gt;myvps&lt;/span&gt;.&lt;span class="Entity"&gt;com&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


	&lt;p&gt;This command connects to myvps.com with the username &lt;strong&gt;me&lt;/strong&gt; and, when connected,
forwards port 2600 on my local computer to port 3128 on myvps.com.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;3. Point your web browser to the new secure port.&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;re using Firefox, open up the preferences, choose &lt;strong&gt;Advanced&lt;/strong&gt; &amp;gt; &lt;strong&gt;Network&lt;/strong&gt;
&amp;gt; &lt;strong&gt;Settings&lt;/strong&gt;.  Choose &lt;strong&gt;Manual proxy configuration&lt;/strong&gt;, enter &lt;strong&gt;localhost&lt;/strong&gt; as the
&amp;gt; HTTP proxy and 2600 (or whichever local port you configured in the last
&amp;gt; set) as your port.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Nginx Subdomains Gotcha</title>
    <link href="/blog/2009/07/nginx-subdomains-gotcha/" />
    <id>tag:kylebanker.com,2009-07-18:1247951703</id>
    <updated>2009-07-18T17:15:03-04:00</updated>
    <content type="html">&lt;p&gt;I was trying to set up a subdomain, &lt;strong&gt;photos.kylebanker.com&lt;/strong&gt;, using &lt;a href="http://wiki.nginx.org/Main"&gt;nginx&lt;/a&gt;. No problems, until I realized that *.kylebanker.com (e.g., whatever.kylebanker.com) was resolving to the content at photos.kylebanker.com. Here&amp;#8217;s my initial configuration. Do you see the what&amp;#8217;s wrong?&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;   2 &lt;/span&gt; &lt;span class="Comment"&gt;&lt;span class="Comment"&gt;#&lt;/span&gt; Redirect all requests containing 'www.kylebanker.com' &lt;/span&gt;
&lt;span class="line-numbers"&gt;   3 &lt;/span&gt; &lt;span class="Comment"&gt;&lt;span class="Comment"&gt;#&lt;/span&gt; to 'kylebanker.com' &lt;/span&gt;
&lt;span class="line-numbers"&gt;   4 &lt;/span&gt; server {
&lt;span class="line-numbers"&gt;   5 &lt;/span&gt;     listen &lt;span class="Constant"&gt;80&lt;/span&gt;;
&lt;span class="line-numbers"&gt;   6 &lt;/span&gt;     server_name  www.&lt;span class="Entity"&gt;kylebanker&lt;/span&gt;.&lt;span class="Entity"&gt;com&lt;/span&gt;;
&lt;span class="line-numbers"&gt;   7 &lt;/span&gt;     rewrite &lt;span class="Keyword"&gt;^&lt;/span&gt;(.&lt;span class="Keyword"&gt;*&lt;/span&gt;) http&lt;span class="Constant"&gt;&lt;span class="Constant"&gt;:&lt;/span&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;/&lt;/span&gt;kylebanker.&lt;span class="Entity"&gt;com&lt;/span&gt;&lt;span class="Variable"&gt;&lt;span class="Variable"&gt;$&lt;/span&gt;1&lt;/span&gt; permanent;
&lt;span class="line-numbers"&gt;   8 &lt;/span&gt; }
&lt;span class="line-numbers"&gt;   9 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;  10 &lt;/span&gt; &lt;span class="Comment"&gt;&lt;span class="Comment"&gt;#&lt;/span&gt; Listen for kylebanker.com&lt;/span&gt;
&lt;span class="line-numbers"&gt;  11 &lt;/span&gt; server {
&lt;span class="line-numbers"&gt;  12 &lt;/span&gt;         listen   &lt;span class="Constant"&gt;80&lt;/span&gt;;
&lt;span class="line-numbers"&gt;  13 &lt;/span&gt;         server_name  kylebanker.&lt;span class="Entity"&gt;com&lt;/span&gt;;
&lt;span class="line-numbers"&gt;  14 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;  15 &lt;/span&gt;         access_log  &lt;span class="Keyword"&gt;/&lt;/span&gt;var&lt;span class="Keyword"&gt;/&lt;/span&gt;log&lt;span class="Keyword"&gt;/&lt;/span&gt;nginx&lt;span class="Keyword"&gt;/&lt;/span&gt;blog.&lt;span class="Entity"&gt;access&lt;/span&gt;.&lt;span class="Entity"&gt;log&lt;/span&gt;;
&lt;span class="line-numbers"&gt;  16 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;  17 &lt;/span&gt;         location &lt;span class="Keyword"&gt;/&lt;/span&gt; { 
&lt;span class="line-numbers"&gt;  18 &lt;/span&gt;                 root   &lt;span class="Keyword"&gt;/&lt;/span&gt;home&lt;span class="Keyword"&gt;/&lt;/span&gt;blog&lt;span class="Keyword"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;public&lt;/span&gt;; 
&lt;span class="line-numbers"&gt;  19 &lt;/span&gt;                 index  index.&lt;span class="Entity"&gt;html&lt;/span&gt; index.&lt;span class="Entity"&gt;htm&lt;/span&gt;; 
&lt;span class="line-numbers"&gt;  20 &lt;/span&gt;         } 
&lt;span class="line-numbers"&gt;  21 &lt;/span&gt; }
&lt;span class="line-numbers"&gt;  22 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;  23 &lt;/span&gt; &lt;span class="Comment"&gt;&lt;span class="Comment"&gt;#&lt;/span&gt; Listen for photos.kylebanker.com&lt;/span&gt;
&lt;span class="line-numbers"&gt;  24 &lt;/span&gt; server {
&lt;span class="line-numbers"&gt;  25 &lt;/span&gt;         listen   &lt;span class="Constant"&gt;80&lt;/span&gt;;
&lt;span class="line-numbers"&gt;  26 &lt;/span&gt;         server_name  photos.&lt;span class="Entity"&gt;kylebanker&lt;/span&gt;.&lt;span class="Entity"&gt;com&lt;/span&gt;;
&lt;span class="line-numbers"&gt;  27 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;  28 &lt;/span&gt;         access_log  &lt;span class="Keyword"&gt;/&lt;/span&gt;var&lt;span class="Keyword"&gt;/&lt;/span&gt;log&lt;span class="Keyword"&gt;/&lt;/span&gt;nginx&lt;span class="Keyword"&gt;/&lt;/span&gt;photos.&lt;span class="Entity"&gt;access&lt;/span&gt;.&lt;span class="Entity"&gt;log&lt;/span&gt;;
&lt;span class="line-numbers"&gt;  29 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;  30 &lt;/span&gt;         location &lt;span class="Keyword"&gt;/&lt;/span&gt; { 
&lt;span class="line-numbers"&gt;  31 &lt;/span&gt;                 root   &lt;span class="Keyword"&gt;/&lt;/span&gt;home&lt;span class="Keyword"&gt;/&lt;/span&gt;photos&lt;span class="Keyword"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;public&lt;/span&gt;; 
&lt;span class="line-numbers"&gt;  32 &lt;/span&gt;                 index  index.&lt;span class="Entity"&gt;html&lt;/span&gt; index.&lt;span class="Entity"&gt;htm&lt;/span&gt;; 
&lt;span class="line-numbers"&gt;  33 &lt;/span&gt;         } 
&lt;span class="line-numbers"&gt;  34 &lt;/span&gt; }
&lt;span class="line-numbers"&gt;  35 &lt;/span&gt; 
&lt;/pre&gt;&lt;/div&gt;


	&lt;p&gt;Turns out that I needed to add a wildcard alias. Line 6 should read as follows:&lt;/p&gt;



&lt;div class="UltraViolet"&gt;&lt;pre class="twilight"&gt;
        server_name  kylebanker.&lt;span class="Entity"&gt;com&lt;/span&gt; &lt;span class="Keyword"&gt;*&lt;/span&gt;.&lt;span class="Entity"&gt;kylebanker&lt;/span&gt;.&lt;span class="Entity"&gt;com&lt;/span&gt;;
&lt;/pre&gt;&lt;/div&gt;


	&lt;p&gt;Was this simply too obvious to be documented elsewhere?&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Javascript, Tetris, and Hanami</title>
    <link href="/blog/2009/04/hanami/" />
    <id>tag:kylebanker.com,2009-04-27:1240877117</id>
    <updated>2009-04-27T20:05:17-04:00</updated>
    <content type="html">&lt;p&gt;Javascript and Hanami are the topics of this post, though they really have
nothing in common aside from being at the forefront of my mind.&lt;/p&gt;


	&lt;p&gt;See, just the other day, I gave myself the challenge of writing a Tetris clone
using Javascript and CSS. It also happens that I had recently visited the
Brooklyn Botanic Garden to witness the great blossoming (&lt;a href="http://www.flickr.com/photos/dkbanker/sets/72157617408572024/"&gt;photos&lt;/a&gt;).&lt;/p&gt;


	&lt;p&gt;The result? A &lt;a href="http://kylebanker.com/projects/hanami"&gt;Hanami-themed version of
Tetris&lt;/a&gt;, to play in your broweser. &lt;a href="http://kylebanker.com/projects/hanami"&gt;Try
it out!&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Incidentally, Javascript&amp;#8217;s functional paradigm is slick. Genuinely wowed by
this elegant little language. The code is on &lt;a href="http://github.com/banker/Hanami/tree/master"&gt;github&lt;/a&gt;.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>The Perils of Simplicity</title>
    <link href="/blog/2009/03/perils-of-simplicity/" />
    <id>tag:kylebanker.com,2009-03-31:1238544513</id>
    <updated>2009-03-31T20:08:33-04:00</updated>
    <content type="html">&lt;p&gt;Michael Osinski&amp;#8217;s software helped create the morgage-backed securities that
have undermined our banking system. He reflects on the easy
manipulation of systems we don&amp;#8217;t wholly understand:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;The power we all hold in our hands is shocking, yet
it’s controlled by a few swipes of a finger. The drive to simplify the
user’s contact with the machine has an inherent side effect of
disguising the complexity of a given task. Over time, the users of any
software are inured to the intricate nature of what they are doing.
Also, as the software does more of the “thinking,” the user does less.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;How do we reconcile this &amp;#8220;shocking&amp;#8221; power with the simplicity enabled
by modern software? As more and more human systems submit to control by
software, how do we avoid rendering what&amp;#8217;s supposed to be too difficult or
too dangerous all too doable?&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.printthis.clickability.com/pt/cpt?action=cpt&amp;#38;title=My+Manhattan+Project&amp;#38;expire=&amp;#38;urlID=35003522&amp;#38;fb=Y&amp;#38;url=http%3A%2F%2Fnymag.com%2Fnews%2Fbusiness%2F55687%2F&amp;#38;partnerID=73272"&gt;Osinski&amp;#8217;s story&lt;/a&gt; is worth reading.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Decluttering</title>
    <link href="/blog/2009/03/decluttering/" />
    <id>tag:kylebanker.com,2009-03-29:1238380304</id>
    <updated>2009-03-29T22:31:44-04:00</updated>
    <content type="html">&lt;p&gt;A cable modem, wireless router, and power strip can still equal a mess under
the desk. A few cheap materials and two hours of enjoyable labor yielded
this from the front:&lt;/p&gt;


&lt;div class="clear"&gt;
&lt;img src="/assets/content/2009/decluttered_desk_front.jpg" /&gt;
&lt;/div&gt;

	&lt;p&gt;And this underneath:&lt;/p&gt;


&lt;div class="clear"&gt;
&lt;img src="/assets/content/2009/decluttered_desk_bottom.jpg" /&gt;
&lt;/div&gt;

	&lt;p&gt;Alas, this clever idea is not my own. Check out &lt;a href="http://www.decluttered.com"&gt;Declutter Your
Desk&lt;/a&gt; for the original implementation.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>The Tyranny of the Fixed Price</title>
    <link href="/blog/2009/03/the-tyranny-of-the-fixed-price/" />
    <id>tag:kylebanker.com,2009-03-19:1237514185</id>
    <updated>2009-03-19T21:56:25-04:00</updated>
    <content type="html">&lt;p&gt;From Philip Greenspun&amp;#8217;s &lt;a href="http://blogs.law.harvard.edu/philg/2009/03/16/how-rich-countries-die/"&gt;book report&lt;/a&gt; on &lt;a href="http://www.amazon.com/gp/product/0300030797?ie=UTF8&amp;#38;tag=pgreenspun-20&amp;#38;linkCode=as2&amp;#38;camp=1789&amp;#38;creative=390957&amp;#38;creativeASIN=0300030797"&gt;The Rise and Decline of Nations: Economic Growth, Stagflation, and Social Rigidities&lt;/a&gt;.  The book&amp;#8217;s author, Mancur Olson, argues that national economies fall with the rise of special interest groups, which prevent markets from correcting themselves:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;How could the Great Depression have lasted so long?  [Mancur] Olson suggests assuming that a lot of prices are fixed by colluding business cartels and/or by government regulation.  The prices are fixed higher than they would be in a free market, which imposes costs on society and guarantees supranormal profits to cartel members.  If there is inflation, the losses to the economy from the cartel are ameliorated.  The fixed price is no longer much higher than what would have been the market price.  In the event of deflation, however, the fixed price is now ridiculously high, demand for such an overpriced product plummets, and production plummets.  Investment in new factories will fall to zero almost immediately.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;The government bailouts seem all the more deplorable and misguided.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Recipe: Salmon and Sweet Potatoes</title>
    <link href="/blog/2009/03/recipe-salmon-and-sweet-potatoes/" />
    <id>tag:kylebanker.com,2009-03-18:1237351512</id>
    <updated>2009-03-18T00:45:12-04:00</updated>
    <content type="html">&lt;h3&gt;A simple, relatively inexpensive, fancy dinner (and, no, I can&amp;#8217;t believe I&amp;#8217;m posting a recipe to my blog.)&lt;/h3&gt;


	&lt;p&gt;Gourmets can still eat well, even as we enter recession times. Try on this salmon recipe instead of going out; it won&amp;#8217;t break the bank.&lt;/p&gt;


	&lt;h4&gt;Salmon&lt;/h4&gt;


	&lt;ul&gt;
	&lt;li&gt;2 Salmon steaks&lt;/li&gt;
		&lt;li&gt;4 tbsp mustard (dijon, spicy brown)&lt;/li&gt;
		&lt;li&gt;1 tbsp honey&lt;/li&gt;
		&lt;li&gt;1/2 cup chopped fresh herbs (mostly parsley, with some thyme)&lt;/li&gt;
		&lt;li&gt;Parchment paper&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Preheat oven to 450F. Mix the mustard and honey. Line a cookie sheet with the parchement paper, placing the Salmon on top. Spread the honey-mustard mixture over the surface of the Salmon steaks and sprinkle with the herbs. Bake around 20 minutes, or until flaky.&lt;/p&gt;


	&lt;h4&gt;Sweet Potatoes&lt;/h4&gt;


	&lt;ul&gt;
	&lt;li&gt;4 tbsp unsalted butter (cut into four pieces)&lt;/li&gt;
		&lt;li&gt;2 tbsp heavy cream&lt;/li&gt;
		&lt;li&gt;1/2 tsp salt&lt;/li&gt;
		&lt;li&gt;1 tsp sugar&lt;/li&gt;
		&lt;li&gt;2lbs sweet potatoes, peeled, quartered, cut into 1/4-inch-thick slices.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Combine the butter, cream, salt, sugar, and potatoes in a medium saucepan. Cover and cook over low heat until the potatoes become mashable, 30-45 minutes. Remove from heat and mash.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Review: No Country for Old Men</title>
    <link href="/blog/2009/03/review-no-country-for-old-men/" />
    <id>tag:kylebanker.com,2009-03-04:1236222913</id>
    <updated>2009-03-04T22:15:13-05:00</updated>
    <content type="html">&lt;p&gt;Several scenes from Cormac McCarthy&amp;#8217;s &lt;a href="http://www.amazon.com/Country-Old-Men-Vintage-International/dp/0307387135/ref=pd_bbs_sr_2?ie=UTF8&amp;#38;s=books&amp;#38;qid=1236226697&amp;#38;sr=8-2"&gt;No Country for Old Men&lt;/a&gt; made me sick to my stomach. Yet somehow I finished this novel, impelled by a deep respect for McCarthy&amp;#8217;s other works (e.g., The Border Trilogy, The Road) and the inescapable allure of violence.&lt;/p&gt;


	&lt;p&gt;For this novel is indeed horrific. The remorseless Chigurh, unmoved by any power save the caprice of a coin flip, casts a dark pall across this story. Intermixed are the reflections of an old sheriff trying to make sense of the downfall of American civilization, of civility itself, and the turning away from the simple truths of right and wrong.&lt;/p&gt;


	&lt;p&gt;Sure, there&amp;#8217;s also a narcotics plot featuring a suitcase stuffed with millions of dollars, decaying bodies, Ford Broncos, innumerable dreary hotels, border crossings, cafe diners, and anonymous powerful men working behind the scenes from Houston skyscrapers. But the novel seems indifferent to these details in the end. Even certain sympathetic characters, when brutally murdered, are apparently forgotten, the narrative not skipping a beat.&lt;/p&gt;


	&lt;p&gt;What stand out are Sheriff Bell and Chigurh; their names cannot be unintentional. Bell serves as a reminder, a call to ponder, and not ignore, the brutality we witness in the news daily and the horror that may be to come.&lt;/p&gt;


	&lt;p&gt;That horror would be Chigurgh, the amorphous and frightening embodiment of civilization as it stands taken its logical extreme. I don&amp;#8217;t believe I&amp;#8217;ve ever encountered a character so heinous in all of literature, an eerie and sobering portrait I won&amp;#8217;t soon forget.&lt;/p&gt;</content>
  </entry>
  
</feed>
