<!DOCTYPE html>
<!--[if IE 6]>
<html id="ie6" lang="en-US">
<![endif]-->
<!--[if IE 7]>
<html id="ie7" lang="en-US">
<![endif]-->
<!--[if IE 8]>
<html id="ie8" lang="en-US">
<![endif]-->
<!--[if !(IE 6) | !(IE 7) | !(IE 8) ]><!-->
<html lang="en-US">
<!--<![endif]-->
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>whyhat</title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="http://www.whyhat.com/wp-content/themes/twentyeleven/style.css" />
<link rel="pingback" href="http://www.whyhat.com/xmlrpc.php" />
<!--[if lt IE 9]>
<script src="http://www.whyhat.com/wp-content/themes/twentyeleven/js/html5.js" type="text/javascript"></script>
<![endif]-->
<script type="text/javascript">
// <![CDATA[
var disqus_shortname = 'mathcanfixthis';
(function () {
var nodes = document.getElementsByTagName('span');
for (var i = 0, url; i < nodes.length; i++) {
if (nodes[i].className.indexOf('dsq-postid') != -1) {
nodes[i].parentNode.setAttribute('data-disqus-identifier', nodes[i].getAttribute('rel'));
url = nodes[i].parentNode.href.split('#', 1);
if (url.length == 1) { url = url[0]; }
else { url = url[1]; }
nodes[i].parentNode.href = url + '#disqus_thread';
}
}
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = '//' + 'disqus.com/forums/' + disqus_shortname + '/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
//]]>
</script>
<link rel="alternate" type="application/rss+xml" title="whyhat &raquo; Feed" href="http://www.whyhat.com/feed/" />
<link rel="alternate" type="application/rss+xml" title="whyhat &raquo; Comments Feed" href="http://www.whyhat.com/comments/feed/" />
<link rel='stylesheet' id='moztheme2011-css' href='http://www.whyhat.com/wp-content/plugins/twenty-eleven-theme-extensions/moztheme2011.css?ver=3.5.1' type='text/css' media='all' />
<link rel='stylesheet' id='jetpack-widgets-css' href='http://www.whyhat.com/wp-content/plugins/jetpack/modules/widgets/widgets.css?ver=20121003' type='text/css' media='all' />
<link rel='stylesheet' id='sharedaddy-css' href='http://www.whyhat.com/wp-content/plugins/jetpack/modules/sharedaddy/sharing.css?ver=2.1.1' type='text/css' media='all' />
<link rel='stylesheet' id='wp-syntax-css-css' href='http://www.whyhat.com/wp-content/plugins/wp-syntax/wp-syntax.css?ver=3.5.1' type='text/css' media='all' />
<script type='text/javascript' src='http://www.whyhat.com/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>
<style type="text/css">img.nothumb{border:0;margin:0 0 0 2px !important;}</style>
<!-- Tweet This v1.8.3 b037 mode alpha zeta -->
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://www.whyhat.com/xmlrpc.php?rsd" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://www.whyhat.com/wp-includes/wlwmanifest.xml" />
<meta name="generator" content="WordPress 3.5.1" />
<link rel='shortlink' href='http://wp.me/1UMVW' />

<!-- All in One SEO Pack 1.6.15.3 by Michael Torbert of Semper Fi Web Design[355,396] -->
<meta name="keywords" content="political science, statistics, networks, programming, social science" />
<link rel="canonical" href="http://www.whyhat.com/" />
<!-- /all in one seo pack -->
<link rel="shortcut icon" href="http://www.joshwcutler.com/wp-content/uploads/2011/10/yhat.png" />
<link rel="icon" type="image/png" href="http://www.joshwcutler.com/wp-content/uploads/2011/10/yhat.png" /><link rel="apple-touch-icon" href="http://www.joshwcutler.com/wp-content/uploads/2011/10/yhat.png" />
<!-- Jetpack Open Graph Tags -->
<meta property="og:type" content="blog" />
<meta property="og:title" content="whyhat" />
<meta property="og:description" content="...can math fix this?" />
<meta property="og:url" content="http://www.whyhat.com/" />
<meta property="og:site_name" content="whyhat" />
<style type="text/css">img.latex {
margin-top: 10px;
}
#site-generator{
display:none;
}
#colophon #supplementary {
display:none;
}
.gist .line-number {
height: 19px;
}</style></head>

<body class="home blog single-author two-column right-sidebar">
<div id="page" class="hfeed">
<header id="branding" role="banner">
<hgroup>
<h1 id="site-title"><span><a href="http://www.whyhat.com/" title="whyhat" rel="home">whyhat</a></span></h1>
<h2 id="site-description">&#8230;can math fix this?</h2>
</hgroup>

<form method="get" id="searchform" action="http://www.whyhat.com/">
<label for="s" class="assistive-text">Search</label>
<input type="text" class="field" name="s" id="s" placeholder="Search" />
<input type="submit" class="submit" name="submit" id="searchsubmit" value="Search" />
</form>
<nav id="access" role="navigation">
<h3 class="assistive-text">Main menu</h3>
<div class="skip-link"><a class="assistive-text" href="#content" title="Skip to primary content">Skip to primary content</a></div>
<div class="skip-link"><a class="assistive-text" href="#secondary" title="Skip to secondary content">Skip to secondary content</a></div>
<div class="menu-main-container"><ul id="menu-main" class="menu"><li id="menu-item-105" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-105"><a href="http://www.whyhat.com">Home</a></li>
<li id="menu-item-103" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-103"><a href="http://www.whyhat.com/about/">About</a></li>
<li id="menu-item-116" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-116"><a href="#">Projects</a>
<ul class="sub-menu">
<li id="menu-item-121" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-121"><a href="http://joshcutler.github.com/PS632-Spring2013/">Programming for Political Scientists</a></li>
<li id="menu-item-115" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-115"><a href="http://www.whyhat.com/zistle/">Zistle</a></li>
</ul>
</li>
</ul></div> </nav><!-- #access -->
</header><!-- #branding -->


<div id="main">

<div id="primary">
<div id="content" role="main">

<nav id="nav-above">
<h3 class="assistive-text">Post navigation</h3>
<div class="nav-previous"><a href="http://www.whyhat.com/page/2/" ><span class="meta-nav">&larr;</span> Older posts</a></div>
<div class="nav-next"></div>
</nav><!-- #nav-above -->
<article id="post-144" class="post-144 post type-post status-publish format-standard hentry category-progamming category-python category-r category-ruby category-software">
<header class="entry-header">
<h1 class="entry-title"><a href="http://www.whyhat.com/2013/02/my-work-setup/" title="Permalink to My Work Setup" rel="bookmark">My Work Setup</a></h1>
<div class="entry-meta">
<span class="sep">Posted on </span><a href="http://www.whyhat.com/2013/02/my-work-setup/" title="6:51 pm" rel="bookmark"><time class="entry-date" datetime="2013-02-02T18:51:23+00:00">February 2, 2013</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="http://www.whyhat.com/author/josh/" title="View all posts by josh" rel="author">josh</a></span></span> </div><!-- .entry-meta -->
<div class="comments-link">
<a href="http://www.whyhat.com/2013/02/my-work-setup/#respond" title="Comment on My Work Setup"><span class="dsq-postid" rel="144 http://www.whyhat.com/?p=144"><span class="leave-reply">Reply</span></span></a> </div>
</header><!-- .entry-header -->

<div class="entry-content">
<p>I just got a new laptop, so I thought I would detail my work setup for those that care (most likely me next time I have to setup a laptop&#8230;).  Sorry PC folks, but I find that if I am going to work, I do so exclusively on OS X at this point.</p>
<h1>System Setup</h1>
<p><strong>iTerm2:</strong> The first thing I always install is<a href="http://www.iterm2.com/#/section/home"> iTerm2</a>.  It is a terminal emulator that I prefer to the default terminal that ships with OS X.  After downloading it, make sure to manually check for updates the first time to get the latest bits.  I prefer to use docked terminal windows but always forget how to set that up.  To do so, under the &#8220;Profiles&#8221; tab of the Preferences screen, in the Windows section change the style to &#8220;Top of Screen&#8221;.</p>
<p style="text-align: center;"><a href="http://www.whyhat.com/wp-content/uploads/2013/02/Screenshot_2_1_13_10_07_PM-8.jpg"><img class=" wp-image-146 aligncenter" alt="Screenshot_2_1_13_10_07_PM-8" src="http://www.whyhat.com/wp-content/uploads/2013/02/Screenshot_2_1_13_10_07_PM-8.jpg" width="334" height="262" /></a></p>
<p style="text-align: left;"><strong>Homebrew:  </strong>I can&#8217;t reccomend <a href="http://mxcl.github.com/homebrew/">Homebrew</a> enough.  If you are installing packages manually, or even worse, using Mac Ports, then Homebrew will change your life.  To install it just run</p>
<pre>ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"</pre>
<p style="text-align: left;">from any terminal window and follow the on screen prompts.  Once the installation is complete, update your brew recipes with</p>
<pre style="text-align: left;">brew update</pre>
<p style="text-align: left;"><strong>XCode:  </strong>If we want  brew to actually work, we will need to install the Command Line Tools for XCode so that we can actually compile things from source.  To do so you will need to go to Apple&#8217;s <a href="http://connect.apple.com">Developer Center</a>.  Download the command line tools appropriate for your operating system.</p>
<p style="text-align: left;"><strong>ZSH:  </strong>Next I install ZShell in place of the default Bash shell.  You can do this with:</p>
<pre style="text-align: left;">brew install zsh</pre>
<p><strong></strong>After the installation is complete set ZSH as your default shell with the following command</p>
<pre>chsh -s /bin/zsh</pre>
<p>Next install <a href="https://github.com/robbyrussell/oh-my-zsh">Oh-My-ZSH</a>.  Check out the github repo for more info, but you can use the automatic installer</p>
<pre>curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh</pre>
<p>To customize your prompt, edit the ~/.zshrc file.  I normally change my theme to nebirhos, but any theme that has good git/rvm integration will work well.  At the end of your .zshrc file you can also set the plugins to include.  I normally use</p>
<pre>plugins=(brew bundler cap gem git git-flow osx pip pow rails rails3 ruby rvm sublime)</pre>
<p><strong>Git:  </strong>While you already have git installed by default, I like to manage my version of git with brew.  So install it</p>
<pre>brew install git</pre>
<p>Note that you may need to change the order of your path variables.  After your installation is done, try</p>
<pre>which git</pre>
<p>and if it returns anything other than /usr/local/bin/git then make sure that the first entry of your path variable is /usr/local/bin in your .zshrc file.  This will ensure that brew installed binaries are used.</p>
<h1>Academic Work</h1>
<p><strong>Sublime Text 2:  </strong><a href="http://www.sublimetext.com/2">Sublime Text 2</a> is my go to for doing any type of code editing or authoring.  I am a somewhat recent convert (from Textmate), but glad to have made the switch.  It is Python based, so it can be configured using Python.  Similarly, all of the plugins are written in Python so it is easy to customize.</p>
<p>The first few things to setup after you get Sublime installed are: <a href="http://wbond.net/sublime_packages/package_control/installation">Package Control</a> for easier package management (just press cmd+shift+p and type &#8216;install&#8217; to access it), and of course your theme.  I am a big fan of Solarized (Dark).</p>
<p>To run R or Python code from Sublime I use the <a href="https://github.com/wuub/SublimeREPL">SublimeREPL</a> package.</p>
<p><strong>LaTeX:  </strong>First install <a href="http://tug.org/mactex/">MacTex</a> so that you have the command line tools to build latex documents.  It is big (around 2GB).  Additionally, install <a href="http://skim-app.sourceforge.net/">Skim</a> if you want a PDF reader that integrates nicely into this setup.</p>
<p>Next  install the <a href=" https://github.com/SublimeText/LaTeXTools">LatexTools</a> package for Sublime Text 2.  This will give you everything you need to build from ST2 by pressing Cmd+B</p>
<p><strong>Python:  </strong>While OS X ships with a version of Python installed, I manage my Python installations with brew. For some of the advantages of doing it this way, see this <a href="https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python">wiki article</a>.</p>
<pre>brew install python</pre>
<p>Open a new terminal tab and install any python packages that you will need, e.g.</p>
<pre>pip install tweepy</pre>
<p>Installing <a href="http://www.scipy.org/SciPy">scipy</a> and <a href="http://matplotlib.org/">matplotlib</a> can sometimes be a pain, so again I try to use homebrew to accomplish this.  First you will need to tap some <a href="https://github.com/samueljohn/homebrew-python">external homebrew recipes</a>, and then you will need to install some prerequisites:</p>
<pre>brew tap samueljohn/python
brew tap homebrew/science
brew install gfortran
pip install nose
brew install scipy
brew install matplotlib</pre>
<p>When you are all done, open a python console and check that you can import scipy and matplotlib to verify.</p>
<p><strong>R:  </strong>Before we can install R, we must first install <a href="http://xquartz.macosforge.org/landing/">XQuartz</a> so that R can draw its graphs.  After XQuartz is done installing (just use the dmg), you can install R using brew</p>
<pre>brew install R
sudo ln -s "/usr/local/opt/r/R.framework" /Library/Frameworks</pre>
<h1>Development</h1>
<p><strong>RVM: </strong>I use <a href="https://rvm.io/">RVM</a> to both handle compiling different Ruby versions as well as create project specific gemsets.  I&#8217;ve heard good things about <a href="https://github.com/sstephenson/rbenv/">rbenv</a>, but thus far seen no reason to switch.  I also like to set my system ruby to 1.9.3</p>
<pre>curl -L https://get.rvm.io | bash -s stable --ruby
rvm install 1.9.3
rvm use 1.9.3 --default</pre>
<p>The above should install <a href="https://rubygems.org/">rubygems</a> by default.  Using that you can install Bundler.</p>
<pre>gem install bundler</pre>
<p>Some versions of Ruby may require the autoconf library which is not installed by default.  To make sure that you can build these install it first</p>
<pre>brew install automake</pre>
<p><strong>SSH Keys:  </strong>In order to securely interact with github and other remote servers we ned to set up SSH keys for our machine.  Github has a good tutorial <a href="https://help.github.com/articles/generating-ssh-keys">here</a>.</p>
<pre>cd ~/.ssh
ssh-keygen -t rsa -C "[email protected]"</pre>
<p><strong>Git-Flow:  </strong>For my development projects (especially web based ones) I like to use <a href="https://github.com/nvie/gitflow">git-flow</a>. Read more about it on the website, but it is a simple, logical way to manage branching for applications that need to remain relatively stable.</p>
<pre>brew install git-flow</pre>
<p><strong>Postgres:  </strong>Use brew to install postgres on your local machine.  Follow the instructions at the end of the installation if you would like postgres to start when you restart your machine.  I also create a &#8216;rails&#8217; user for my local rails apps.</p>
<pre>brew install postgres
initdb /usr/local/var/postgres -E utf8
createuser rails -s</pre>
<p>If you want a GUI to interface with the DB check out <a href="http://www.postgresql.org/ftp/pgadmin3/release/v1.16.1/osx/">pgAdmin</a>.</p>
<p><strong>POW:  </strong>To run rails applications locally I use <a href="http://pow.cx/">POW</a>.  This allows me to run my rails apps at somedomain.dev by just adding a symlink in the ~/.pow directory.</p>
<pre>curl get.pow.cx | sh</pre>
<p><strong>ElasticSearch:  </strong>I find that ElasticSearch is my current default for fulltext search needs.  It is Lucene based and really easy to work with.</p>
<pre>brew install elasticsearch
ln -sfv /usr/local/opt/elasticsearch/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist</pre>
<h1>Useful Apps</h1>
<p><strong>Dropbox: </strong>I use <a href="https://www.dropbox.com/">Dropbox</a> for syncing and sharing files between my machines.  I am trying to get my colleagues to move away from Dropbox as a coauthoring technique and rely on distributed source control, but occasionally use it for that as well.</p>
<p><strong>1Password:  </strong>For storing, syncing and generating credentials across my various machines I use <a href="https://agilebits.com/onepassword">1Password</a>.  When used in tandem with dropbox it is easy to use lengthy random passwords for all of my various accounts without memorizing (or even knowing) them.</p>
<p><strong>Skitch:</strong> For getting screenshots and annotating them I still use <a href="http://evernote.com/skitch/">Skitch</a>.</p>
<p><strong>MailPlane:  </strong>Almost all of my email accounts are Gmail based, so I use <a href="http://mailplaneapp.com/">MailPlane</a> to manage them.  You get the gmail interface but some nice extra features as well.</p>
<p><strong>Skype:  </strong>For video chat and screen shares I use <a href="http://beta.skype.com/en/">Skype</a>.<strong>  </strong>It&#8217;s free and it works.</p>
<p>That is it for now.  With all of this installed, I can finally get back to work&#8230;.</p>
<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-official sd-sharing"><h3 class="sd-title">Share this:</h3><div class="sd-content"><ul><li class="share-twitter"><div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.whyhat.com%2F2013%2F02%2Fmy-work-setup%2F&#038;counturl=http%3A%2F%2Fwww.whyhat.com%2F2013%2F02%2Fmy-work-setup%2F&#038;count=horizontal&#038;text=My%20Work%20Setup%3A" style="width:101px; height:20px;"></iframe></div></li><li class="share-facebook"><div class="like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.whyhat.com%2F2013%2F02%2Fmy-work-setup%2F&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;height=21&amp;width=90" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:96px; height:21px;" allowTransparency="true"></iframe></div></li><li class="share-google-plus-1"><div class="googleplus1_button"><div class="g-plusone" data-size="medium" data-callback="sharing_plusone" data-href="http://www.whyhat.com/2013/02/my-work-setup/"></div></div></li><li class="share-linkedin"><div class="linkedin_button"><script type="in/share" data-url="http://www.whyhat.com/2013/02/my-work-setup/" data-counter="right"></script></div></li><li class="share-end"></li></ul><div class="sharing-clear"></div></div></div></div> </div><!-- .entry-content -->
<footer class="entry-meta">
<span class="cat-links">
<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> <a href="http://www.whyhat.com/category/progamming/" title="View all posts in progamming" rel="category tag">progamming</a>, <a href="http://www.whyhat.com/category/python/" title="View all posts in python" rel="category tag">python</a>, <a href="http://www.whyhat.com/category/r/" title="View all posts in R" rel="category tag">R</a>, <a href="http://www.whyhat.com/category/ruby/" title="View all posts in ruby" rel="category tag">ruby</a>, <a href="http://www.whyhat.com/category/software/" title="View all posts in software" rel="category tag">software</a> </span>
<span class="sep"> | </span>
<span class="comments-link"><a href="http://www.whyhat.com/2013/02/my-work-setup/#respond" title="Comment on My Work Setup"><span class="dsq-postid" rel="144 http://www.whyhat.com/?p=144"><span class="leave-reply">Leave a reply</span></span></a></span>
</footer><!-- .entry-meta -->
</article><!-- #post-144 -->

<article id="post-136" class="post-136 post type-post status-publish format-standard hentry category-conferences category-progamming">
<header class="entry-header">
<h1 class="entry-title"><a href="http://www.whyhat.com/2012/05/2012-spring-workshop-on-computational-social-science/" title="Permalink to 2012 Spring Workshop on Computational Social Science" rel="bookmark">2012 Spring Workshop on Computational Social Science</a></h1>
<div class="entry-meta">
<span class="sep">Posted on </span><a href="http://www.whyhat.com/2012/05/2012-spring-workshop-on-computational-social-science/" title="3:10 pm" rel="bookmark"><time class="entry-date" datetime="2012-05-29T15:10:27+00:00">May 29, 2012</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="http://www.whyhat.com/author/josh/" title="View all posts by josh" rel="author">josh</a></span></span> </div><!-- .entry-meta -->
<div class="comments-link">
<a href="http://www.whyhat.com/2012/05/2012-spring-workshop-on-computational-social-science/#respond" title="Comment on 2012 Spring Workshop on Computational Social Science"><span class="dsq-postid" rel="136 http://www.whyhat.com/?p=136"><span class="leave-reply">Reply</span></span></a> </div>
</header><!-- .entry-header -->

<div class="entry-content">
<p>The <a href="http://events.iq.harvard.edu/events/node/2858">Spring Workshop on Computational Social Science</a>, a joint effort put together by Harvard, MIT and Northeastern, will be going on this week Wednesday, Thursday and Friday.  I will be attending the Thursday session on network visualization and am looking forward to meeting the other attendees as well as getting my hands dirty with Gephi.  For those can&#8217;t make it, it will be <a href="http://video.isites.harvard.edu/liveVideo/liveView.do?name=Comp_Soc_Science">live streamed</a>.  To watch, either use the previous link or check out this embedded stream:</p>
<p><iframe style="border: 0px;" src=" http://video.isites.harvard.edu/liveVideo/liveEmbed.do?name=Comp_Soc_Science&amp;width=auto&amp;height=auto " width="640" height="360"></iframe></p>
<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-official sd-sharing"><h3 class="sd-title">Share this:</h3><div class="sd-content"><ul><li class="share-twitter"><div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.whyhat.com%2F2012%2F05%2F2012-spring-workshop-on-computational-social-science%2F&#038;counturl=http%3A%2F%2Fwww.whyhat.com%2F2012%2F05%2F2012-spring-workshop-on-computational-social-science%2F&#038;count=horizontal&#038;text=2012%20Spring%20Workshop%20on%20Computational%20Social%20Science%3A" style="width:101px; height:20px;"></iframe></div></li><li class="share-facebook"><div class="like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.whyhat.com%2F2012%2F05%2F2012-spring-workshop-on-computational-social-science%2F&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;height=21&amp;width=90" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:96px; height:21px;" allowTransparency="true"></iframe></div></li><li class="share-google-plus-1"><div class="googleplus1_button"><div class="g-plusone" data-size="medium" data-callback="sharing_plusone" data-href="http://www.whyhat.com/2012/05/2012-spring-workshop-on-computational-social-science/"></div></div></li><li class="share-linkedin"><div class="linkedin_button"><script type="in/share" data-url="http://www.whyhat.com/2012/05/2012-spring-workshop-on-computational-social-science/" data-counter="right"></script></div></li><li class="share-end"></li></ul><div class="sharing-clear"></div></div></div></div> </div><!-- .entry-content -->
<footer class="entry-meta">
<span class="cat-links">
<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> <a href="http://www.whyhat.com/category/conferences/" title="View all posts in conferences" rel="category tag">conferences</a>, <a href="http://www.whyhat.com/category/progamming/" title="View all posts in progamming" rel="category tag">progamming</a> </span>
<span class="sep"> | </span>
<span class="comments-link"><a href="http://www.whyhat.com/2012/05/2012-spring-workshop-on-computational-social-science/#respond" title="Comment on 2012 Spring Workshop on Computational Social Science"><span class="dsq-postid" rel="136 http://www.whyhat.com/?p=136"><span class="leave-reply">Leave a reply</span></span></a></span>
</footer><!-- .entry-meta -->
</article><!-- #post-136 -->

<article id="post-130" class="post-130 post type-post status-publish format-standard hentry category-courses category-progamming category-python category-software category-teaching">
<header class="entry-header">
<h1 class="entry-title"><a href="http://www.whyhat.com/2012/05/course-complete/" title="Permalink to Course Complete!" rel="bookmark">Course Complete!</a></h1>
<div class="entry-meta">
<span class="sep">Posted on </span><a href="http://www.whyhat.com/2012/05/course-complete/" title="9:34 pm" rel="bookmark"><time class="entry-date" datetime="2012-05-22T21:34:06+00:00">May 22, 2012</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="http://www.whyhat.com/author/josh/" title="View all posts by josh" rel="author">josh</a></span></span> </div><!-- .entry-meta -->
<div class="comments-link">
<a href="http://www.whyhat.com/2012/05/course-complete/#respond" title="Comment on Course Complete!"><span class="dsq-postid" rel="130 http://www.whyhat.com/?p=130"><span class="leave-reply">Reply</span></span></a> </div>
</header><!-- .entry-header -->

<div class="entry-content">
<p>So&#8230; it has been a while since my last update.  This spring&#8217;s semester wrapped up well for both me, as well as the students in my Python for social scientists course.</p>
<p>The feedback that I received was that the course was very useful for the students involved, some of whom have already written a number of programs that they are using in their research, though the syllabus could use some minor tweaks.  The syllabus as it is written on the website will be updated with some of the feedback that I received, namely, to spend a little bit more time on databases.  I tried to cram both relational database theory as well as &#8220;here is how to use sql&#8221; into one lecture and I don&#8217;t think it was covered with enough depth.  I  think that in the future I may also cover the use of linux tools to facilitate large file manipulation, as this is something that data scientists frequently have to do.</p>
<p>One topic that I was not able to cover, but I think could be useful, would be an introduction to map-reduce, possibly with a hands on example using <a href="http://aws.amazon.com/elasticmapreduce/">EMR</a>.  It was definitely outside of the scope of this course, but seems like something that people that work with large corpora of text will run into eventually.</p>
<p>While the course did not use a textbook, next time, if the course were taught in Python (which it probably will be) I will suggest that students buy <a href="http://www.amazon.com/gp/product/1449314635/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;tag=whyhat-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1449314635">Think Complexity: Complexity Science  and Computational Modeling</a> by <a href="http://allendowney.blogspot.com/">Allen Downey</a>.  While it does not devote time to web scraping, it does have some good coverage of Python concepts and has some great examples of how to implement well known models in Python.  If I could somehow justify teaching the course in Ruby, <a href="http://ruby.bastardsbook.com/">The Bastards Book of Ruby</a> would be a <em>perfect </em>supplement.</p>
<p>The students&#8217; final projects were great and covered a wide range of technical areas.  One group built an application that integrated with twitter and google translate&#8217;s apis to create a dataset about world leader communication.  A different student started out building a web crawler and then realized that all of the data was in PDF format, so they got to learn about how to use <a href="http://www.unixuser.org/~euske/python/pdfminer/index.html">PDFMiner</a> to extract the information that was needed.  Another discovered that web scraping ia much harder with ajax heavy websites and ended up learning to use <a href="http://seleniumhq.org/">Selenium</a> to solve this problem.  Finally, one student jumped into the world of Python UI and built a GUI for playing a game that used <a href="http://en.wikipedia.org/wiki/Lanchester's_laws">Lanchester&#8217;s Laws</a> to simulate the outcome.  The goal for the final project was to do something that could ultimately end up turning into a paper and I think on that front all of the groups did well.  I am excited to see where these projects end up.</p>
<p>&nbsp;</p>
<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-official sd-sharing"><h3 class="sd-title">Share this:</h3><div class="sd-content"><ul><li class="share-twitter"><div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.whyhat.com%2F2012%2F05%2Fcourse-complete%2F&#038;counturl=http%3A%2F%2Fwww.whyhat.com%2F2012%2F05%2Fcourse-complete%2F&#038;count=horizontal&#038;text=Course%20Complete%21%3A" style="width:101px; height:20px;"></iframe></div></li><li class="share-facebook"><div class="like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.whyhat.com%2F2012%2F05%2Fcourse-complete%2F&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;height=21&amp;width=90" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:96px; height:21px;" allowTransparency="true"></iframe></div></li><li class="share-google-plus-1"><div class="googleplus1_button"><div class="g-plusone" data-size="medium" data-callback="sharing_plusone" data-href="http://www.whyhat.com/2012/05/course-complete/"></div></div></li><li class="share-linkedin"><div class="linkedin_button"><script type="in/share" data-url="http://www.whyhat.com/2012/05/course-complete/" data-counter="right"></script></div></li><li class="share-end"></li></ul><div class="sharing-clear"></div></div></div></div> </div><!-- .entry-content -->
<footer class="entry-meta">
<span class="cat-links">
<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> <a href="http://www.whyhat.com/category/courses/" title="View all posts in courses" rel="category tag">courses</a>, <a href="http://www.whyhat.com/category/progamming/" title="View all posts in progamming" rel="category tag">progamming</a>, <a href="http://www.whyhat.com/category/python/" title="View all posts in python" rel="category tag">python</a>, <a href="http://www.whyhat.com/category/software/" title="View all posts in software" rel="category tag">software</a>, <a href="http://www.whyhat.com/category/teaching/" title="View all posts in teaching" rel="category tag">teaching</a> </span>
<span class="sep"> | </span>
<span class="comments-link"><a href="http://www.whyhat.com/2012/05/course-complete/#respond" title="Comment on Course Complete!"><span class="dsq-postid" rel="130 http://www.whyhat.com/?p=130"><span class="leave-reply">Leave a reply</span></span></a></span>
</footer><!-- .entry-meta -->
</article><!-- #post-130 -->

<article id="post-118" class="post-118 post type-post status-publish format-standard hentry category-progamming category-teaching">
<header class="entry-header">
<h1 class="entry-title"><a href="http://www.whyhat.com/2012/01/computation-frameworks-for-the-social-sciences-aka-im-teaching-a-class/" title="Permalink to Computation Frameworks for the Social Sciences (aka I&#8217;m teaching a class)" rel="bookmark">Computation Frameworks for the Social Sciences (aka I&#8217;m teaching a class)</a></h1>
<div class="entry-meta">
<span class="sep">Posted on </span><a href="http://www.whyhat.com/2012/01/computation-frameworks-for-the-social-sciences-aka-im-teaching-a-class/" title="9:40 pm" rel="bookmark"><time class="entry-date" datetime="2012-01-22T21:40:11+00:00">January 22, 2012</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="http://www.whyhat.com/author/josh/" title="View all posts by josh" rel="author">josh</a></span></span> </div><!-- .entry-meta -->
<div class="comments-link">
<a href="http://www.whyhat.com/2012/01/computation-frameworks-for-the-social-sciences-aka-im-teaching-a-class/#respond" title="Comment on Computation Frameworks for the Social Sciences (aka I&#8217;m teaching a class)"><span class="dsq-postid" rel="118 http://www.whyhat.com/?p=118"><span class="leave-reply">Reply</span></span></a> </div>
</header><!-- .entry-header -->

<div class="entry-content">
<p>This spring I am teaching my first course!  It is a pretty small seminar, 8-10 graduate students, but they all seem excited about the material.  It is a &#8220;Programming for Political Scientists&#8221; course that will use Python to both teach people how to write good software as well as show them how people are using software in the discipline currently.  I hope to spend the first half of the course covering basic software engineering and computer science concepts before moving on to some specific applications.  Hopefully, by the end of the course all of the students will have built something that they can use to further their research agendas (e.g. a web scraper to supplement a data set).</p>
<p>The class website is up at <a href="http://joshcutler.github.com/PS398/">http://joshcutler.github.com/PS398/</a> where you can find my schedule outline as well as the homeworks.  One thing that has worked well so far was requiring that everyone work through <a href="http://zedshaw.com/">Zed Shaw</a>&#8216;s <a href="http://learnpythonthehardway.org/book/">Learn Python the Hard Way</a> before class.  This got everyone (note that most had not done any serious programming before) on the same page and ready to start tackling some more advanced ideas.</p>
<p>For those of you that have experience in the space, I would welcome any feedback on the syllabus (or anything else).  As the course moves along I will try to post about any changes that I make, findings, etc. for those interested in teaching a similar course elsewhere.</p>
<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-official sd-sharing"><h3 class="sd-title">Share this:</h3><div class="sd-content"><ul><li class="share-twitter"><div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.whyhat.com%2F2012%2F01%2Fcomputation-frameworks-for-the-social-sciences-aka-im-teaching-a-class%2F&#038;counturl=http%3A%2F%2Fwww.whyhat.com%2F2012%2F01%2Fcomputation-frameworks-for-the-social-sciences-aka-im-teaching-a-class%2F&#038;count=horizontal&#038;text=Computation%20Frameworks%20for%20the%20Social%20Sciences%20%28aka%20I%27m%20teaching%20a%20class%29%3A" style="width:101px; height:20px;"></iframe></div></li><li class="share-facebook"><div class="like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.whyhat.com%2F2012%2F01%2Fcomputation-frameworks-for-the-social-sciences-aka-im-teaching-a-class%2F&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;height=21&amp;width=90" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:96px; height:21px;" allowTransparency="true"></iframe></div></li><li class="share-google-plus-1"><div class="googleplus1_button"><div class="g-plusone" data-size="medium" data-callback="sharing_plusone" data-href="http://www.whyhat.com/2012/01/computation-frameworks-for-the-social-sciences-aka-im-teaching-a-class/"></div></div></li><li class="share-linkedin"><div class="linkedin_button"><script type="in/share" data-url="http://www.whyhat.com/2012/01/computation-frameworks-for-the-social-sciences-aka-im-teaching-a-class/" data-counter="right"></script></div></li><li class="share-end"></li></ul><div class="sharing-clear"></div></div></div></div> </div><!-- .entry-content -->
<footer class="entry-meta">
<span class="cat-links">
<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> <a href="http://www.whyhat.com/category/progamming/" title="View all posts in progamming" rel="category tag">progamming</a>, <a href="http://www.whyhat.com/category/teaching/" title="View all posts in teaching" rel="category tag">teaching</a> </span>
<span class="sep"> | </span>
<span class="comments-link"><a href="http://www.whyhat.com/2012/01/computation-frameworks-for-the-social-sciences-aka-im-teaching-a-class/#respond" title="Comment on Computation Frameworks for the Social Sciences (aka I&#8217;m teaching a class)"><span class="dsq-postid" rel="118 http://www.whyhat.com/?p=118"><span class="leave-reply">Leave a reply</span></span></a></span>
</footer><!-- .entry-meta -->
</article><!-- #post-118 -->

<article id="post-94" class="post-94 post type-post status-publish format-standard hentry category-blogging category-web-programming">
<header class="entry-header">
<h1 class="entry-title"><a href="http://www.whyhat.com/2012/01/line-numbers-on-embedded-gists/" title="Permalink to Line numbers on embedded Gists" rel="bookmark">Line numbers on embedded Gists</a></h1>
<div class="entry-meta">
<span class="sep">Posted on </span><a href="http://www.whyhat.com/2012/01/line-numbers-on-embedded-gists/" title="4:10 pm" rel="bookmark"><time class="entry-date" datetime="2012-01-03T16:10:23+00:00">January 3, 2012</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="http://www.whyhat.com/author/josh/" title="View all posts by josh" rel="author">josh</a></span></span> </div><!-- .entry-meta -->
<div class="comments-link">
<a href="http://www.whyhat.com/2012/01/line-numbers-on-embedded-gists/#comments" title="Comment on Line numbers on embedded Gists"><span class="dsq-postid" rel="94 http://www.whyhat.com/?p=94">2</span></a> </div>
</header><!-- .entry-header -->

<div class="entry-content">
<p>For all of you bloggers out there that like embedding gists but are frustrated by the lack of line numbers, I found a nice CSS solution.  After a little googling, I found <a href="https://gist.github.com/1243028">this solution</a> by <a href="https://gist.github.com/potch">potch</a>.  It looks as though the structure of an embedded gist has changed slightly so I modified the css to look like the following:</p>
<script src="https://gist.github.com/3991069.js"></script><noscript><pre><code class="language-css css">.gist .highlight {
border-left: 3ex solid #eee;
position: relative;
}
.gist .highlight pre {
counter-reset: linenumbers;
}
.gist .highlight pre div:before {
color: #aaa;
content: counter(linenumbers);
counter-increment: linenumbers;
left: -3ex;
position: absolute;
text-align: right;
width: 2.5ex;
}</code></pre></noscript>
<p>Include this somewhere in your stylesheets and viola, you get nice line numbers for all of your embedded gists (in modern browsers at least).</p>
<p>UPDATE: This no longer appears to be needed!</p>
<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-official sd-sharing"><h3 class="sd-title">Share this:</h3><div class="sd-content"><ul><li class="share-twitter"><div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.whyhat.com%2F2012%2F01%2Fline-numbers-on-embedded-gists%2F&#038;counturl=http%3A%2F%2Fwww.whyhat.com%2F2012%2F01%2Fline-numbers-on-embedded-gists%2F&#038;count=horizontal&#038;text=Line%20numbers%20on%20embedded%20Gists%3A" style="width:101px; height:20px;"></iframe></div></li><li class="share-facebook"><div class="like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.whyhat.com%2F2012%2F01%2Fline-numbers-on-embedded-gists%2F&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;height=21&amp;width=90" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:96px; height:21px;" allowTransparency="true"></iframe></div></li><li class="share-google-plus-1"><div class="googleplus1_button"><div class="g-plusone" data-size="medium" data-callback="sharing_plusone" data-href="http://www.whyhat.com/2012/01/line-numbers-on-embedded-gists/"></div></div></li><li class="share-linkedin"><div class="linkedin_button"><script type="in/share" data-url="http://www.whyhat.com/2012/01/line-numbers-on-embedded-gists/" data-counter="right"></script></div></li><li class="share-end"></li></ul><div class="sharing-clear"></div></div></div></div> </div><!-- .entry-content -->
<footer class="entry-meta">
<span class="cat-links">
<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> <a href="http://www.whyhat.com/category/blogging/" title="View all posts in blogging" rel="category tag">blogging</a>, <a href="http://www.whyhat.com/category/web-programming/" title="View all posts in web programming" rel="category tag">web programming</a> </span>
<span class="sep"> | </span>
<span class="comments-link"><a href="http://www.whyhat.com/2012/01/line-numbers-on-embedded-gists/#comments" title="Comment on Line numbers on embedded Gists"><span class="dsq-postid" rel="94 http://www.whyhat.com/?p=94"><b>2</b> Replies</span></a></span>
</footer><!-- .entry-meta -->
</article><!-- #post-94 -->

<article id="post-80" class="post-80 post type-post status-publish format-standard hentry category-r category-software category-webservices tag-rook">
<header class="entry-header">
<h1 class="entry-title"><a href="http://www.whyhat.com/2011/12/rook/" title="Permalink to Rook" rel="bookmark">Rook</a></h1>
<div class="entry-meta">
<span class="sep">Posted on </span><a href="http://www.whyhat.com/2011/12/rook/" title="4:52 pm" rel="bookmark"><time class="entry-date" datetime="2011-12-30T16:52:18+00:00">December 30, 2011</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="http://www.whyhat.com/author/josh/" title="View all posts by josh" rel="author">josh</a></span></span> </div><!-- .entry-meta -->
<div class="comments-link">
<a href="http://www.whyhat.com/2011/12/rook/#respond" title="Comment on Rook"><span class="dsq-postid" rel="80 http://www.whyhat.com/?p=80"><span class="leave-reply">Reply</span></span></a> </div>
</header><!-- .entry-header -->

<div class="entry-content">
<p>As I said in my <a href="http://www.whyhat.com/2011/12/rook-and-r-webservices/">last post</a>, I am working on setting up a statistical web service using R.  I decided to use the <a href="http://cran.r-project.org/package=Rook">Rook library</a> to do so and wanted to give a brief overview of how Rook works for others who might be interested.</p>
<p>The best way to learn is often to just dig right in and go line by line, so here is a simple rook application:</p>
<script src="https://gist.github.com/1541340.js"></script><noscript><pre><code class="language-r r">require('Rook')

library(Rook)
library(rjson)

rook = Rhttpd$new()
rook$add(
name =&quot;summarize&quot;,
app = function(env) {
req = Rook::Request$new(env)
numbers = as.numeric(unlist(strsplit(req$params()$numbers, &quot;,&quot;)))
results = list()
results$mean = mean(numbers)
results$sd = sd(numbers)

res = Rook::Response$new()
res$write(toJSON(results))
res$finish()
}
)

rook$browse(&quot;summarize&quot;)
</code></pre></noscript>
<p>Line <strong>6</strong> creates a new rook webserver object.  This is what will respond to HTTP requests from the browser.</p>
<p>Line <strong>7 </strong>adds an &#8220;application&#8221; to the webserver.  When you add an application to a Rook server you need to name a route and specify what should happen when a user requests that action.  The route is specified by line <strong>8 </strong>and tells the Rook server that when a user requests &#8220;summarize&#8221; it should execute the code specified in lines <strong>9-21</strong>.  For some reason Rook prefaces all routes with the word &#8220;custom&#8221;, so the url to access the route we specified would be http://server:port/<strong>custom/summarize</strong></p>
<p>The interesting part of the application occurs in the function that is assigned to app on line <strong>9</strong>.  Rook wraps the parameters of the HTTP request in some nice accessors which can be used as seen in line <strong>10</strong>.  While the docs specify all of the information available, the important part of the HTTP request for our app is the params() method.  This returns the union of any variables passed via query string and POST.  For the rails developers it is exactly the Rails params hash.</p>
<p>Line <strong>12</strong> parses the input.  This application is expecting an array of numbers separated by commas assigned to the numbers parameter.  Note that if this isn&#8217;t specified the app will break in its current state.</p>
<p>After parsing the input parameters we compute some simple summary statistics on this array of numbers and store them in the list results (<strong>14-16</strong>).</p>
<p>Rook uses the Rook::Response object to fashion a proper HTTP response.  After instantiating the response on line <strong>18</strong>, we call the write() method on the response object.  This sends whatever string it is passed to the output stream which is returned to the requestor (in our case the web browser).  Note that I am returning the results in JSON format and should probably set HTTP headers as well if I was going to deploy this to production.  Line <strong>20 </strong>flushes the output stream and returns it to the requestor, call this when you are done constructing your response.</p>
<p>Finally, to start our server and see the thing in action we can use the browse() method (line <strong>24</strong>).  We are specifying the action that we want to browse to as the parameter.  This should pop open a web browser pointing to your Rook application&#8211;and you should get an error:</p>
<pre>Error in strsplit(req$params()$numbers, ",") : non-character argument</pre>
<p>This is because we didn&#8217;t validate the input and our application is expecting an array of numbers.  So, lets pass them through the query string.  Append the following to the URL in your browser: &#8220;?numbers=1,2,3,4,5&#8243; and refresh.  No you should get the following:</p>
<pre>{"mean":3,"sd":1.58113883008419}</pre>
<p>And you have a functioning Rook server!</p>
<p>If you want to add other functionality you can just make addition add() calls on the rook object and the new applications will be added.  If you want to change the functionality of an existing application make sure that you remove (rook$remove(&#8216;summarize&#8217;)) it and then re-add it (or just restart everything).</p>
<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-official sd-sharing"><h3 class="sd-title">Share this:</h3><div class="sd-content"><ul><li class="share-twitter"><div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.whyhat.com%2F2011%2F12%2Frook%2F&#038;counturl=http%3A%2F%2Fwww.whyhat.com%2F2011%2F12%2Frook%2F&#038;count=horizontal&#038;text=Rook%3A" style="width:101px; height:20px;"></iframe></div></li><li class="share-facebook"><div class="like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.whyhat.com%2F2011%2F12%2Frook%2F&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;height=21&amp;width=90" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:96px; height:21px;" allowTransparency="true"></iframe></div></li><li class="share-google-plus-1"><div class="googleplus1_button"><div class="g-plusone" data-size="medium" data-callback="sharing_plusone" data-href="http://www.whyhat.com/2011/12/rook/"></div></div></li><li class="share-linkedin"><div class="linkedin_button"><script type="in/share" data-url="http://www.whyhat.com/2011/12/rook/" data-counter="right"></script></div></li><li class="share-end"></li></ul><div class="sharing-clear"></div></div></div></div> </div><!-- .entry-content -->
<footer class="entry-meta">
<span class="cat-links">
<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> <a href="http://www.whyhat.com/category/r/" title="View all posts in R" rel="category tag">R</a>, <a href="http://www.whyhat.com/category/software/" title="View all posts in software" rel="category tag">software</a>, <a href="http://www.whyhat.com/category/webservices/" title="View all posts in webservices" rel="category tag">webservices</a> </span>
<span class="sep"> | </span>
<span class="tag-links">
<span class="entry-utility-prep entry-utility-prep-tag-links">Tagged</span> <a href="http://www.whyhat.com/tag/rook/" rel="tag">rook</a> </span>
<span class="sep"> | </span>
<span class="comments-link"><a href="http://www.whyhat.com/2011/12/rook/#respond" title="Comment on Rook"><span class="dsq-postid" rel="80 http://www.whyhat.com/?p=80"><span class="leave-reply">Leave a reply</span></span></a></span>
</footer><!-- .entry-meta -->
</article><!-- #post-80 -->

<article id="post-68" class="post-68 post type-post status-publish format-standard hentry category-r category-software category-webservices">
<header class="entry-header">
<h1 class="entry-title"><a href="http://www.whyhat.com/2011/12/rook-and-r-webservices/" title="Permalink to Rook and R Webservices" rel="bookmark">Rook and R Webservices</a></h1>
<div class="entry-meta">
<span class="sep">Posted on </span><a href="http://www.whyhat.com/2011/12/rook-and-r-webservices/" title="7:39 pm" rel="bookmark"><time class="entry-date" datetime="2011-12-19T19:39:32+00:00">December 19, 2011</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="http://www.whyhat.com/author/josh/" title="View all posts by josh" rel="author">josh</a></span></span> </div><!-- .entry-meta -->
<div class="comments-link">
<a href="http://www.whyhat.com/2011/12/rook-and-r-webservices/#comments" title="Comment on Rook and R Webservices"><span class="dsq-postid" rel="68 http://www.whyhat.com/?p=68">1</span></a> </div>
</header><!-- .entry-header -->

<div class="entry-content">
<p>Recently I have been working on setting up a webservice that does some non trivial statistical work.  Normally, my go to when building web services is Ruby/Rails due to ease of use, then I offload anything computationally intensive to something more optimized (e.g. a C or Java application on the same box).  In this case however, partly because of my co-author&#8217;s skill, partly discipline norms, and a whole lot of R being awesome for this sort of thing, the statistical work is going to be done in R.</p>
<p>While it would have been possible to still build the webservice wrapper in Ruby and then either use one of the existing Ruby wrappers for R (or even spinning up an R process on its own), I wanted to see if I could build the whole thing in R.  As is almost always the case, I was not the first person to think of this, and most of the hard work has already been done.</p>
<p><a href="http://cran.r-project.org/web/packages/Rook/index.html">Rook</a> is an R package on CRAN written by <a href="http://jeffreyhorner.tumblr.com/">Jeffrey Horner</a>.  For those of you familiar with Ruby and <a href="http://rubygems.org/gems/rack">Rack</a>, Rook is very similar.  It provides an interface, using R&#8217;s built in rApache webserver, to handle http requests, handle routing, etc.  The more I read about it, the more I was convinced that it was a great solution to the problem that I was working on.  Now if only I get it to run on Heroku&#8230;.</p>
<p>Well, running Rook on Heroku was surprisingly simple thanks to Noah Lorang&#8217;s example which you can<a href="https://github.com/noahhl/rookonheroku"> find here</a>.</p>
<p>So, how do you get started?  Almost everything that you&#8217;ll need is in the <a href="https://github.com/noahhl/rookonheroku/blob/master/README.md">README</a> in Noah&#8217;s repository, but there are a couple of tricky things to note.</p>
<p>First make sure that you have a Heroku account.  It is free to sign up and you get one free full-time process per project (one single web server in our case).  There are numerous resources (including their excellent help files) to get you through this part.</p>
<p>Next you can either walk through the instructions in Noah&#8217;s example (which I ended up doing), or you can do the much easier thing by cloning his repository.  If you do this, then you should be able to deploy it directly.</p>
<p>After you get a running instance of Rook, you will want to write some R code.  To run your own custom R script, replace the &#8220;/app/demo.R&#8221; in rackup file (config.ru) with the path of your script.  Otherwise, you can just put your code in demo.R.</p>
<p>Because Heroku is a read-only file system, you will need to include any R packages in your source tree so that they are &#8220;installed&#8221; when you deploy.  Initially you will just have R and Rook installed (if you cloned the existing project).  Because some packages require native compilation, you really should do that compilation on one of heroku&#8217;s servers.  In order to do this, you need to ssh into your app server:</p>
<blockquote>
<pre>heroku run bash</pre>
</blockquote>
<p>Once you are in the bash shell on your app server you can load R.  From there install any packages that will be dependencies for you project.  When you exit the R shell, do not log out of the ssh session.  If you do the app will reset and you will need to start over (remember it is read only so the file system changes persist only as long as your session).  You then need to figure out how you want to get these changes off of your heroku instance.  First zip them up (I zipped up the whole bin directoy):</p>
<blockquote>
<pre>tar -cvzf mybin.tar.gz ./bin</pre>
</blockquote>
<p>Then you can either scp it off of the machine (as Noah suggests):</p>
<blockquote>
<pre>scp mybin.tar.gz [email protected]:~/myproject/bin.tar.gz</pre>
</blockquote>
<p>Or, if you do not have access to a destination that you can scp (heroku does not have ftp installed), you can do the roundabout method of setting up github as a remote, checking in the tarball, pushing it to github and then cloning that repository locally.  Once you have the tarball on your machine, just untar it into your repositories bin directory, checkin, and deploy.  You will now have access to those packages in R.</p>
<p>I&#8217;ll writeup how to actually use Rook in my next post.</p>
<p>&nbsp;</p>
<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-official sd-sharing"><h3 class="sd-title">Share this:</h3><div class="sd-content"><ul><li class="share-twitter"><div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.whyhat.com%2F2011%2F12%2Frook-and-r-webservices%2F&#038;counturl=http%3A%2F%2Fwww.whyhat.com%2F2011%2F12%2Frook-and-r-webservices%2F&#038;count=horizontal&#038;text=Rook%20and%20R%20Webservices%3A" style="width:101px; height:20px;"></iframe></div></li><li class="share-facebook"><div class="like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.whyhat.com%2F2011%2F12%2Frook-and-r-webservices%2F&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;height=21&amp;width=90" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:96px; height:21px;" allowTransparency="true"></iframe></div></li><li class="share-google-plus-1"><div class="googleplus1_button"><div class="g-plusone" data-size="medium" data-callback="sharing_plusone" data-href="http://www.whyhat.com/2011/12/rook-and-r-webservices/"></div></div></li><li class="share-linkedin"><div class="linkedin_button"><script type="in/share" data-url="http://www.whyhat.com/2011/12/rook-and-r-webservices/" data-counter="right"></script></div></li><li class="share-end"></li></ul><div class="sharing-clear"></div></div></div></div> </div><!-- .entry-content -->
<footer class="entry-meta">
<span class="cat-links">
<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> <a href="http://www.whyhat.com/category/r/" title="View all posts in R" rel="category tag">R</a>, <a href="http://www.whyhat.com/category/software/" title="View all posts in software" rel="category tag">software</a>, <a href="http://www.whyhat.com/category/webservices/" title="View all posts in webservices" rel="category tag">webservices</a> </span>
<span class="sep"> | </span>
<span class="comments-link"><a href="http://www.whyhat.com/2011/12/rook-and-r-webservices/#comments" title="Comment on Rook and R Webservices"><span class="dsq-postid" rel="68 http://www.whyhat.com/?p=68"><b>1</b> Reply</span></a></span>
</footer><!-- .entry-meta -->
</article><!-- #post-68 -->

<article id="post-54" class="post-54 post type-post status-publish format-standard hentry category-ai category-ruby category-software">
<header class="entry-header">
<h1 class="entry-title"><a href="http://www.whyhat.com/2011/11/naive-bayes-with-laplacean-smoothing/" title="Permalink to Naive Bayes with Laplacean Smoothing" rel="bookmark">Naive Bayes with Laplacean Smoothing</a></h1>
<div class="entry-meta">
<span class="sep">Posted on </span><a href="http://www.whyhat.com/2011/11/naive-bayes-with-laplacean-smoothing/" title="9:52 pm" rel="bookmark"><time class="entry-date" datetime="2011-11-13T21:52:25+00:00">November 13, 2011</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="http://www.whyhat.com/author/josh/" title="View all posts by josh" rel="author">josh</a></span></span> </div><!-- .entry-meta -->
<div class="comments-link">
<a href="http://www.whyhat.com/2011/11/naive-bayes-with-laplacean-smoothing/#respond" title="Comment on Naive Bayes with Laplacean Smoothing"><span class="dsq-postid" rel="54 http://www.whyhat.com/?p=54"><span class="leave-reply">Reply</span></span></a> </div>
</header><!-- .entry-header -->

<div class="entry-content">
<p>In <a href="http://www.ai-class.com">aiclass.com</a>, we just covered Naive Bayesian Classifiers, and it couldn&#8217;t have been more perfectly timed.  Prior to that lecture series, one of the projects that I am working on required that I build a classifier for a large body of data that was getting funneled into the system.  I spent quite a bit of time searching for the best way to do this, hoping that there would be a rubygem that could save me some effort, but much to my chagrin, nothing quite fit the bill&#8211;so I started in on building my own.</p>
<p>The basic idea behind a Naive Bayes classifier is that we have some set of documents that have been categorized (into n categories) and want to use this information about our existing labeled documents to predict the category of new, not yet labeled, documents.  It is a pretty direct use of Bayes rule and is probably best understood through an example.</p>
<p>Say you have 5 documents:</p>
<ul>
<li>{subject: &#8216;Must read!&#8217;, text: &#8216;Get Viagra cheap!&#8217;, label: &#8216;spam&#8217;}</li>
<li>{subject: &#8216;Gotta see this&#8217;, text: &#8216;Viagra.  You can get it at cut rates&#8217;, label: &#8216;spam&#8217;}</li>
<li>{subject: &#8216;Call me tomorrow&#8217;, text: &#8216;We need to talk about scheduling.  Call me.&#8217;, label: &#8216;not spam&#8217;}</li>
<li>{subject: &#8216;That was hilarious&#8217;, text: &#8216;Just saw that link you sent me&#8217;, label: &#8216;not spam&#8217;}</li>
<li>{subject: &#8216;dinner at 7&#8242;, text: &#8216;I got us a reservation tomorrow at 7&#8242;, label: &#8216;not spam&#8217;}</li>
</ul>
<div>We have 2 spam message, and 3 real messages.  Each of these messages has a subject and some text that we can use to train our classifier.</div>
<div>Given a new message:</div>
<div>
<ul>
<li>{subject: &#8216;See it to believe it&#8217;, text: &#8216;Best rates you&#8217;ll see&#8217;, label: ?}</li>
</ul>
<div>What is the probability that it is a spam message?  Using Bayes rule we can compute it in the following way:</div>
</div>
<div><img src='http://s0.wp.com/latex.php?latex=P%28spam%7Csubject%2Ctext%29%3D%5Cfrac%7BP%28subject%2Ctext%7Cspam%29%2AP%28spam%29%7D%7BP%28subject%2Ctext%7Cspam%29%2AP%28spam%29%2BP%28subject%2Ctext%7Cnotspam%29%2AP%28notspam%29%7D+&#038;bg=ffffff&#038;fg=000&#038;s=0' alt='P(spam|subject,text)=&#92;frac{P(subject,text|spam)*P(spam)}{P(subject,text|spam)*P(spam)+P(subject,text|notspam)*P(notspam)} ' title='P(spam|subject,text)=&#92;frac{P(subject,text|spam)*P(spam)}{P(subject,text|spam)*P(spam)+P(subject,text|notspam)*P(notspam)} ' class='latex' /></div>
<div>All of these values can be computed by inspection of the previous documents:</div>
<div><img src='http://s0.wp.com/latex.php?latex=P%28spam%29%3D%5Cfrac%7B2%7D%7B5%7D+&#038;bg=ffffff&#038;fg=000&#038;s=0' alt='P(spam)=&#92;frac{2}{5} ' title='P(spam)=&#92;frac{2}{5} ' class='latex' /></div>
<div><img src='http://s0.wp.com/latex.php?latex=P%28notspam%29%3D%5Cfrac%7B3%7D%7B5%7D+&#038;bg=ffffff&#038;fg=000&#038;s=0' alt='P(notspam)=&#92;frac{3}{5} ' title='P(notspam)=&#92;frac{3}{5} ' class='latex' /></div>
<div>Note that in the case of Naive Bayes you assume independence of your variables (which is probably not true given that the english language is structured).</div>
<div>
<div><img src='http://s0.wp.com/latex.php?latex=P%28subject%2Ctext%7Cspam%29%3DP%28subject%7Cspam%29%2AP%28subject%7Cspam%29+&#038;bg=ffffff&#038;fg=000&#038;s=0' alt='P(subject,text|spam)=P(subject|spam)*P(subject|spam) ' title='P(subject,text|spam)=P(subject|spam)*P(subject|spam) ' class='latex' /></div>
</div>
<div><img src='http://s0.wp.com/latex.php?latex=P%28subject%7Cspam%29%3D%5Cprod_%7Bword+%5Cin+subject%7DP%28word%7Cspam%29&#038;bg=ffffff&#038;fg=000&#038;s=0' alt='P(subject|spam)=&#92;prod_{word &#92;in subject}P(word|spam)' title='P(subject|spam)=&#92;prod_{word &#92;in subject}P(word|spam)' class='latex' /></div>
<div>So for example, in the document we want to classify:</div>
<div><img src='http://s0.wp.com/latex.php?latex=P%28%27see%27+%5Cin+subject%7Cspam%29+%3D+%5Cfrac%7B1%7D%7B5%7D+&#038;bg=ffffff&#038;fg=000&#038;s=0' alt='P(&#039;see&#039; &#92;in subject|spam) = &#92;frac{1}{5} ' title='P(&#039;see&#039; &#92;in subject|spam) = &#92;frac{1}{5} ' class='latex' /></div>
<div>You will note that the document to classify has some words that are not in any of the existing classified documents (e.g. &#8216;believe&#8217;).  This will give those conditional probabilities a value of 0, thus making the numerator 0 even though there is definitely a greater than 0 chance of this item being classified as spam.</div>
<div>The solution to this problem is known as Laplacean Smoothing.  In order to perform smoothing you pick some parameter k.  In our case we can set k=1.  This smoothing parameter is added to all probabilities as they are calculated and a normalizing constant is added to the denominator to make it a valid probability.</div>
<div>Thus, with a smoother of size 1:</div>
<div><img src='http://s0.wp.com/latex.php?latex=P%28%27believe%27+%5Cin+subject%7Cspam%29%3D%5Cfrac%7B0+%2B+1%7D%7B5%2B5%2A1%7D&#038;bg=ffffff&#038;fg=000&#038;s=0' alt='P(&#039;believe&#039; &#92;in subject|spam)=&#92;frac{0 + 1}{5+5*1}' title='P(&#039;believe&#039; &#92;in subject|spam)=&#92;frac{0 + 1}{5+5*1}' class='latex' /></div>
<div>Where does the 5*1 come from in the denominator?  Well we have a smoothing factor of 1 and we have 5 different known values for words in the subject, thus in order to make the known values a true probability distribution we need to add that to the denominator (so it sums to 1).</div>
<div>Like I said, that math here is pretty straightforward if you can buy the assumptions.  And, even if you can&#8217;t it seems to work pretty well.</div>
<div>So, how did I end up using it in my app?  I built a pretty simple gem to do classification called <a href="https://github.com/joshcutler/Classyfier">Classyfier</a>.  It was based loosely on <a href="https://github.com/mperham/bayes_motel">Bayes Motel</a> but I cleaned up and reorganized some things (as well as added smoothing). I anticipate that I will be adding more features to this package as my need for more sophisticated classification grows.  For more info on how to use the gem see the example below or just checkout the <a href="https://github.com/joshcutler/Classyfier/blob/master/test/test_classyfier.rb">test file</a>.</div>
<div><script src="https://gist.github.com/1363069.js"></script><noscript><pre><code class="language-ruby ruby">require 'classyfier'

@classyfier = Classyfier::NaiveBayes::NaiveBayesClassifier.new
@classyfier.train({:subject =&gt; 'Must read!', :text =&gt; 'Get Viagra cheap!'}, :spam)
@classyfier.train({:subject =&gt; 'Gotta see this', :text =&gt; 'Viagra. You can get it at cut rates'}, :spam)
@classyfier.train({:subject =&gt; 'Call me tomorrow', :text =&gt; 'We need to talk about scheduling. Call me.'}, :not_spam)
@classyfier.train({:subject =&gt; 'That was hilarious', :text =&gt; 'Just saw that link you sent me'}, :not_spam)
@classyfier.train({:subject =&gt; 'dinner at 7', :text =&gt; 'I got us a reservation tomorrow at 7'}, :not_spam)
@scores = @classyfier.classify({:subject =&gt; 'See it to believe it', :text =&gt; 'Best rates you\'ll see'})
</code></pre></noscript></div>
<p>&nbsp;</p>
<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-official sd-sharing"><h3 class="sd-title">Share this:</h3><div class="sd-content"><ul><li class="share-twitter"><div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.whyhat.com%2F2011%2F11%2Fnaive-bayes-with-laplacean-smoothing%2F&#038;counturl=http%3A%2F%2Fwww.whyhat.com%2F2011%2F11%2Fnaive-bayes-with-laplacean-smoothing%2F&#038;count=horizontal&#038;text=Naive%20Bayes%20with%20Laplacean%20Smoothing%3A" style="width:101px; height:20px;"></iframe></div></li><li class="share-facebook"><div class="like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.whyhat.com%2F2011%2F11%2Fnaive-bayes-with-laplacean-smoothing%2F&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;height=21&amp;width=90" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:96px; height:21px;" allowTransparency="true"></iframe></div></li><li class="share-google-plus-1"><div class="googleplus1_button"><div class="g-plusone" data-size="medium" data-callback="sharing_plusone" data-href="http://www.whyhat.com/2011/11/naive-bayes-with-laplacean-smoothing/"></div></div></li><li class="share-linkedin"><div class="linkedin_button"><script type="in/share" data-url="http://www.whyhat.com/2011/11/naive-bayes-with-laplacean-smoothing/" data-counter="right"></script></div></li><li class="share-end"></li></ul><div class="sharing-clear"></div></div></div></div> </div><!-- .entry-content -->
<footer class="entry-meta">
<span class="cat-links">
<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> <a href="http://www.whyhat.com/category/ai/" title="View all posts in ai" rel="category tag">ai</a>, <a href="http://www.whyhat.com/category/ruby/" title="View all posts in ruby" rel="category tag">ruby</a>, <a href="http://www.whyhat.com/category/software/" title="View all posts in software" rel="category tag">software</a> </span>
<span class="sep"> | </span>
<span class="comments-link"><a href="http://www.whyhat.com/2011/11/naive-bayes-with-laplacean-smoothing/#respond" title="Comment on Naive Bayes with Laplacean Smoothing"><span class="dsq-postid" rel="54 http://www.whyhat.com/?p=54"><span class="leave-reply">Leave a reply</span></span></a></span>
</footer><!-- .entry-meta -->
</article><!-- #post-54 -->

<article id="post-30" class="post-30 post type-post status-publish format-standard hentry category-r tag-graphs tag-r">
<header class="entry-header">
<h1 class="entry-title"><a href="http://www.whyhat.com/2011/10/exponential-growth-and-resource-consumption/" title="Permalink to Exponential growth and resource consumption" rel="bookmark">Exponential growth and resource consumption</a></h1>
<div class="entry-meta">
<span class="sep">Posted on </span><a href="http://www.whyhat.com/2011/10/exponential-growth-and-resource-consumption/" title="5:11 pm" rel="bookmark"><time class="entry-date" datetime="2011-10-17T17:11:50+00:00">October 17, 2011</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="http://www.whyhat.com/author/josh/" title="View all posts by josh" rel="author">josh</a></span></span> </div><!-- .entry-meta -->
<div class="comments-link">
<a href="http://www.whyhat.com/2011/10/exponential-growth-and-resource-consumption/#comments" title="Comment on Exponential growth and resource consumption"><span class="dsq-postid" rel="30 http://www.whyhat.com/?p=30">1</span></a> </div>
</header><!-- .entry-header -->

<div class="entry-content">
<p>In August, while on the road moving to Duke, I heard a great interview on <a href="http://www.npr.org/">NPR</a> with <a href="http://en.wikipedia.org/wiki/David_Suzuki">David Suzuki</a>.  During this interview he talked about the relationship between anything that grows exponentially and the resources that it consumes.  In particular he focused on how we are likely to misperceive the remaining level of resources because humans are bad at understanding exponential growth (see anything by <a href="http://en.wikipedia.org/wiki/Ray_Kurzweil">Kurzweil</a>).</p>
<p>I wanted to retell his analogy because it has really stuck with me and then provide a visualization that I found helpful.</p>
<p>Imagine 2 bacteria in a petri dish.  The petri dish is many, many times bigger than they are.  To keep the math simple lets say that it is 1 billion times larger.  The bacteria in the dish look around and realize that they have a bounty of agar on which to live and thus anticipate much prosperity.  So the bacteria, being bacteria, replicate.  After 1 unit of time (lets say they replicate every minute), there are now 4 bacteria.  These 4 bacteria look around and see that they have this vast petri dish at their disposal and thus keep replicating.  Since replicating is fun, this goes on for a while.  Eventually after 20 turns of doubling in size there are 1,048,576 (<img src='http://s0.wp.com/latex.php?latex=2%5E%7B20%7D+&#038;bg=ffffff&#038;fg=000&#038;s=0' alt='2^{20} ' title='2^{20} ' class='latex' />) bacteria.  They realize that they have used up just more than 0.1% of their resources and there is much rejoicing and still more replicating.</p>
<p>By the time that 29 minutes have passed there are now 536,870,912 bacteria.  They have used over half of their resources, but they look around and see that they still have half of them left and it took them 29 turns to get here, so they have to have a little time to figure out how to get out of this mess.  On the 30th turn, the population doubles again and now there are 1,073,741,824 and they are out of room.  When a population grows by doubling in size, it by definition will go from 50% resource utilization to 100% in one time period.  That was both obvious (mathematically) and shocking to me.  How fast is the human population growing?  How close are we to running out of resources on earth?</p>
<p>Well, if there was any doubt about whether human population growth was exponential here is a graph of estimated growth over the past 12,000 years (courtesy of wikipedia):</p>
<p><img class="alignnone" title="Human Growth Chart" alt="Human Growth Chart" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/Population_curve.svg/500px-Population_curve.svg.png" width="500" height="250" /></p>
<p>And the <a href="https://www.cia.gov/library/publications/the-world-factbook/geos/xx.html">CIA factbook</a> estimates the current population growth to be about %1.092 year over year.</p>
<p>Here is a graph that just visualizes the thought experiment proposed by Suzuki:</p>
<p><a href="http://www.whyhat.com/wp-content/uploads/2011/10/growth.png"><img class="alignnone size-full wp-image-46" title="growth" alt="" src="http://www.whyhat.com/wp-content/uploads/2011/10/growth.png" width="863" height="452" /></a></p>
<p>The point of this graph is just to show how quickly the resource level can plunge to zero and how as an inductive species it is easy to fall into the trap of not understanding the rate at which exponential growth can take off by using historical data to improperly predict the future.</p>
<p>Note: For the graph I just picked a time period of 1000 and then decided to drive it to 0 at that point.  Given that there is a finite amount of resources you will get the same graph form, one way or the other after fixing the resource size.  Below is a gist in R to play around with and see how the curve forms change under different growth rates and how the warning time (as a percentage of the species&#8217; history) shrinks as the size of the resource goes up.</p>
<p><script src="https://gist.github.com/1293829.js"></script></p>
<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-official sd-sharing"><h3 class="sd-title">Share this:</h3><div class="sd-content"><ul><li class="share-twitter"><div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.whyhat.com%2F2011%2F10%2Fexponential-growth-and-resource-consumption%2F&#038;counturl=http%3A%2F%2Fwww.whyhat.com%2F2011%2F10%2Fexponential-growth-and-resource-consumption%2F&#038;count=horizontal&#038;text=Exponential%20growth%20and%20resource%20consumption%3A" style="width:101px; height:20px;"></iframe></div></li><li class="share-facebook"><div class="like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.whyhat.com%2F2011%2F10%2Fexponential-growth-and-resource-consumption%2F&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;height=21&amp;width=90" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:96px; height:21px;" allowTransparency="true"></iframe></div></li><li class="share-google-plus-1"><div class="googleplus1_button"><div class="g-plusone" data-size="medium" data-callback="sharing_plusone" data-href="http://www.whyhat.com/2011/10/exponential-growth-and-resource-consumption/"></div></div></li><li class="share-linkedin"><div class="linkedin_button"><script type="in/share" data-url="http://www.whyhat.com/2011/10/exponential-growth-and-resource-consumption/" data-counter="right"></script></div></li><li class="share-end"></li></ul><div class="sharing-clear"></div></div></div></div> </div><!-- .entry-content -->
<footer class="entry-meta">
<span class="cat-links">
<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> <a href="http://www.whyhat.com/category/r/" title="View all posts in R" rel="category tag">R</a> </span>
<span class="sep"> | </span>
<span class="tag-links">
<span class="entry-utility-prep entry-utility-prep-tag-links">Tagged</span> <a href="http://www.whyhat.com/tag/graphs/" rel="tag">graphs</a>, <a href="http://www.whyhat.com/tag/r/" rel="tag">R</a> </span>
<span class="sep"> | </span>
<span class="comments-link"><a href="http://www.whyhat.com/2011/10/exponential-growth-and-resource-consumption/#comments" title="Comment on Exponential growth and resource consumption"><span class="dsq-postid" rel="30 http://www.whyhat.com/?p=30"><b>1</b> Reply</span></a></span>
</footer><!-- .entry-meta -->
</article><!-- #post-30 -->

<article id="post-26" class="post-26 post type-post status-publish format-standard hentry category-courses tag-aiclass">
<header class="entry-header">
<h1 class="entry-title"><a href="http://www.whyhat.com/2011/10/ai-class-com/" title="Permalink to AI-Class.com" rel="bookmark">AI-Class.com</a></h1>
<div class="entry-meta">
<span class="sep">Posted on </span><a href="http://www.whyhat.com/2011/10/ai-class-com/" title="1:10 pm" rel="bookmark"><time class="entry-date" datetime="2011-10-15T13:10:20+00:00">October 15, 2011</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="http://www.whyhat.com/author/josh/" title="View all posts by josh" rel="author">josh</a></span></span> </div><!-- .entry-meta -->
<div class="comments-link">
<a href="http://www.whyhat.com/2011/10/ai-class-com/#respond" title="Comment on AI-Class.com"><span class="dsq-postid" rel="26 http://www.whyhat.com/?p=26"><span class="leave-reply">Reply</span></span></a> </div>
</header><!-- .entry-header -->

<div class="entry-content">
<p>When I found out about <a href="http://www.ai-class.com">ai-class.com</a>, this fall I was really excited. It is an online Intro to AI course taught by <a href="http://robots.stanford.edu/">Sebastian Thrun</a> and <a href="http://norvig.com/">Peter Norvig</a> out of Stanford University.  It is free, they are smart and I hadn&#8217;t thought about AI problems since undergrad.  Well, it has finally started&#8211;and so far so good.</p>
<p>There were a few technical glitches as things got rolling, but that was mostly due to the insanely high demand for the course.  At one point, according to their <a href="https://twitter.com/#!/aiclass">twitter account</a>, they were getting over 7000 web requests per second.  They now claim to have over 160,000 students registered for the course.  As of today everything seems to be running very smoothly.</p>
<p>When I first heard the numbers regarding how big the course was I wasn&#8217;t sure how they were going to administer homework at that scale.  Well, today I turned in my first homework and it is rather cleverly done.  All of the lectures are short video clips (1-6 minutes so far), and at end of each of them they pose some sort of quiz question.  They way that they are presented is pretty clever however, in that they draw out the question in the video via pen and paper and then superimpose an html form on top of it so that you can submit your responses.  For example, here is a multiple choice quiz question:</p>
<p><a href="http://www.whyhat.com/wp-content/uploads/2011/10/Intro-to-AI-1.jpg"><img class="aligncenter size-medium wp-image-27" title="Example AIClass problem" src="http://www.whyhat.com/wp-content/uploads/2011/10/Intro-to-AI-1-300x169.jpg" alt="" width="300" height="169" /></a>This ends up working surprisingly well.  So, for the homework assignments they do the same thing.  One of the presenters draws out a question (a maze, or graph, etc) and then asks some questions about it, the form gets superimposed and you submit your answers.  Thus far it has been really great and I highly recommend that anyone who is interested try it out next time the courses are offered.  They also have a <a href="http://www.ml-class.org/course/auth/welcome">Machine Learning course</a> being taught by <a href="http://cs.stanford.edu/~ang/">Andrew Ng</a> as well as a <a href="http://www.db-class.org/course/auth/welcome">Database course</a> by <a href="http://infolab.stanford.edu/~widom/">Jennifer Widom</a> all being done in the same format.</p>
<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-official sd-sharing"><h3 class="sd-title">Share this:</h3><div class="sd-content"><ul><li class="share-twitter"><div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.whyhat.com%2F2011%2F10%2Fai-class-com%2F&#038;counturl=http%3A%2F%2Fwww.whyhat.com%2F2011%2F10%2Fai-class-com%2F&#038;count=horizontal&#038;text=AI-Class.com%3A" style="width:101px; height:20px;"></iframe></div></li><li class="share-facebook"><div class="like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.whyhat.com%2F2011%2F10%2Fai-class-com%2F&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;height=21&amp;width=90" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:96px; height:21px;" allowTransparency="true"></iframe></div></li><li class="share-google-plus-1"><div class="googleplus1_button"><div class="g-plusone" data-size="medium" data-callback="sharing_plusone" data-href="http://www.whyhat.com/2011/10/ai-class-com/"></div></div></li><li class="share-linkedin"><div class="linkedin_button"><script type="in/share" data-url="http://www.whyhat.com/2011/10/ai-class-com/" data-counter="right"></script></div></li><li class="share-end"></li></ul><div class="sharing-clear"></div></div></div></div> </div><!-- .entry-content -->
<footer class="entry-meta">
<span class="cat-links">
<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> <a href="http://www.whyhat.com/category/courses/" title="View all posts in courses" rel="category tag">courses</a> </span>
<span class="sep"> | </span>
<span class="tag-links">
<span class="entry-utility-prep entry-utility-prep-tag-links">Tagged</span> <a href="http://www.whyhat.com/tag/aiclass/" rel="tag">aiclass</a> </span>
<span class="sep"> | </span>
<span class="comments-link"><a href="http://www.whyhat.com/2011/10/ai-class-com/#respond" title="Comment on AI-Class.com"><span class="dsq-postid" rel="26 http://www.whyhat.com/?p=26"><span class="leave-reply">Leave a reply</span></span></a></span>
</footer><!-- .entry-meta -->
</article><!-- #post-26 -->

<nav id="nav-below">
<h3 class="assistive-text">Post navigation</h3>
<div class="nav-previous"><a href="http://www.whyhat.com/page/2/" ><span class="meta-nav">&larr;</span> Older posts</a></div>
<div class="nav-next"></div>
</nav><!-- #nav-above -->
</div><!-- #content -->
</div><!-- #primary -->

<div id="secondary" class="widget-area" role="complementary">
<aside id="text-5" class="widget widget_text"> <div class="textwidget"><script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-26373244-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script></div>
</aside><aside id="text-3" class="widget widget_text"> <div class="textwidget">Find me on <a href="https://github.com/joshcutler" taret="_blank">Github</a></div>
</aside><aside id="categories-3" class="widget widget_categories"><h3 class="widget-title">Categories</h3> <ul>
<li class="cat-item cat-item-16"><a href="http://www.whyhat.com/category/ai/" title="View all posts filed under ai">ai</a>
</li>
<li class="cat-item cat-item-19"><a href="http://www.whyhat.com/category/blogging/" title="View all posts filed under blogging">blogging</a>
</li>
<li class="cat-item cat-item-8"><a href="http://www.whyhat.com/category/conferences/" title="View all posts filed under conferences">conferences</a>
</li>
<li class="cat-item cat-item-11"><a href="http://www.whyhat.com/category/courses/" title="View all posts filed under courses">courses</a>
</li>
<li class="cat-item cat-item-3"><a href="http://www.whyhat.com/category/presentations/" title="View all posts filed under presentations">presentations</a>
</li>
<li class="cat-item cat-item-24"><a href="http://www.whyhat.com/category/progamming/" title="View all posts filed under progamming">progamming</a>
</li>
<li class="cat-item cat-item-25"><a href="http://www.whyhat.com/category/python/" title="View all posts filed under python">python</a>
</li>
<li class="cat-item cat-item-13"><a href="http://www.whyhat.com/category/r/" title="View all posts filed under R">R</a>
</li>
<li class="cat-item cat-item-15"><a href="http://www.whyhat.com/category/ruby/" title="View all posts filed under ruby">ruby</a>
</li>
<li class="cat-item cat-item-4"><a href="http://www.whyhat.com/category/software/" title="View all posts filed under software">software</a>
</li>
<li class="cat-item cat-item-23"><a href="http://www.whyhat.com/category/teaching/" title="View all posts filed under teaching">teaching</a>
</li>
<li class="cat-item cat-item-20"><a href="http://www.whyhat.com/category/web-programming/" title="View all posts filed under web programming">web programming</a>
</li>
<li class="cat-item cat-item-17"><a href="http://www.whyhat.com/category/webservices/" title="View all posts filed under webservices">webservices</a>
</li>
</ul>
</aside><aside id="archives-3" class="widget widget_archive"><h3 class="widget-title">Archives</h3> <ul>
<li><a href='http://www.whyhat.com/2013/02/' title='February 2013'>February 2013</a></li>
<li><a href='http://www.whyhat.com/2012/05/' title='May 2012'>May 2012</a></li>
<li><a href='http://www.whyhat.com/2012/01/' title='January 2012'>January 2012</a></li>
<li><a href='http://www.whyhat.com/2011/12/' title='December 2011'>December 2011</a></li>
<li><a href='http://www.whyhat.com/2011/11/' title='November 2011'>November 2011</a></li>
<li><a href='http://www.whyhat.com/2011/10/' title='October 2011'>October 2011</a></li>
</ul>
</aside><aside id="linkcat-2" class="widget widget_links"><h3 class="widget-title">Friends</h3>
<ul class='xoxo blogroll'>
<li><a href="http://www.brendan-nyhan.com/" rel="friend met co-worker" title="Brendan Nyhan&#8217;s Blog" target="_blank">Brendan Nyhan</a></li>
<li><a href="http://yspr.wordpress.com/" rel="friend met co-worker" title="Matt Dickenson&#8217;s Blog" target="_blank">You Study Politics, Right?</a></li>

</ul>
</aside>
<aside id="text-4" class="widget widget_text"> <div class="textwidget"><div style="margin:0px; margin-top:10px">
<embed width="190" height="300" src="http://www.goodreads.com/images/widget/widget2.swf"
quality="high" wmode="transparent"
FlashVars="id=1238032&shelf=read&title=Josh's bookshelf&host=www.goodreads.com&sort=date_added&order=d&params=amazon,whyhat-20,dest_site,amazon">
</embed>
</div>
<div id="gr-fl-widget-1318350873">
<div style="border: 1px solid #d7d7d7;-moz-border-radius:10px;-webkit-border-radius:10px;width: 165px;padding:10px; margin-bottom: 4px"><span style="color: #aaa;font-style:italic">Josh's bookshelf</span><br/><br/>
<a href="http://www.goodreads.com/book/show/324748.The_Dip" style="float: left; padding: 2px" title="The Dip: A Little Book That Teaches You When to Quit (and When to Stick)"><img alt="The Dip: A Little Book That Teaches You When to Quit" border="0" height="70" src="http://photo.goodreads.com/books/1311282216s/324748.jpg" width="50" /></a><a href="http://www.goodreads.com/book/show/6683549-you-are-not-a-gadget" style="float: left; padding: 2px" title="You Are Not a Gadget: A Manifesto"><img alt="You Are Not a Gadget: A Manifesto" border="0" height="70" src="http://photo.goodreads.com/books/1275624947s/6683549.jpg" width="50" /></a><a href="http://www.goodreads.com/book/show/11088769-4-hour-body" style="float: left; padding: 2px" title="4 Hour Body (Easy as Pie)"><img alt="4 Hour Body" border="0" height="70" src="http://ecx.images-amazon.com/images/I/31CXfsT%2BGIL._SL75_.jpg" width="50" /></a><a href="http://www.goodreads.com/book/show/9402297-the-bed-of-procrustes" style="float: left; padding: 2px" title="The Bed of Procrustes: Philosophical and Practical Aphorisms"><img alt="The Bed of Procrustes: Philosophical and Practical Aphorisms" border="0" height="70" src="http://ecx.images-amazon.com/images/I/41xbo16fpSL._SL75_.jpg" width="50" /></a><a href="http://www.goodreads.com/book/show/867247.Book_of_Five_Rings" style="float: left; padding: 2px" title="Book of Five Rings: The Classic Guide to Strategy"><img alt="Book of Five Rings: The Classic Guide to Strategy" border="0" height="70" src="http://photo.goodreads.com/books/1179031481s/867247.jpg" width="50" /></a><a href="http://www.goodreads.com/book/show/6237780-against-all-things-ending" style="float: left; padding: 2px" title="Against All Things Ending"><img alt="Against All Things Ending" border="0" height="70" src="http://ecx.images-amazon.com/images/I/51A8jTHWOTL._SL75_.jpg" width="50" /></a><br style="clear:both"/><br/><a href="http://www.goodreads.com/user/show/1238032-josh" style="color: #aaa;font-size: .9em">More of Josh's books &raquo;</a>
</div>
</div>
<script type="text/javascript">document.getElementById('gr-fl-widget-1318350873').innerHTML=""; // in case no flash/js</script>
<div style="margin:0px;">
<a href="http://www.goodreads.com/"><img alt="Book recommendations, book reviews, quotes, book clubs, book trivia, book lists" border="0" height="32" src="http://www.goodreads.com/images/widget/widget_logo.gif" title="Book recommendations, book reviews, quotes, book clubs, book trivia, book lists" width="190" /></a>
</div>
</div>
</aside> </div><!-- #secondary .widget-area -->

</div><!-- #main -->

<footer id="colophon" role="contentinfo">

<div id="supplementary" class="one">
<div id="first" class="widget-area" role="complementary">
<aside id="text-6" class="widget widget_text"> <div class="textwidget"><script type="text/javascript">
var clicky_site_ids = clicky_site_ids || [];
clicky_site_ids.push(66516974);
(function() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//static.getclicky.com/js';
( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild( s );
})();
</script>
<noscript><p><img alt="Clicky" width="1" height="1" src="//in.getclicky.com/66516974ns.gif" /></p></noscript></div>
</aside> </div><!-- #first .widget-area -->
</div><!-- #supplementary -->
<div id="site-generator">
<a href="http://wordpress.org/" title="Semantic Personal Publishing Platform">Proudly powered by WordPress</a>
</div>
</footer><!-- #colophon -->
</div><!-- #page -->

<div style="display:none">
</div>
<script type='text/javascript' src='http://www.whyhat.com/wp-content/plugins/jetpack/modules/sharedaddy/sharing.js?ver=20121205'></script>
<script type="text/javascript" charset="utf-8">
jQuery(document).on( 'ready post-load', function(){
jQuery( 'a.share-twitter' ).on( 'click', function() {
window.open( jQuery(this).attr( 'href' ), 'wpcomtwitter', 'menubar=1,resizable=1,width=600,height=350' );
return false;
});
});
</script>
<script type="text/javascript" charset="utf-8">
jQuery(document).on( 'ready post-load', function(){
jQuery( 'a.share-facebook' ).on( 'click', function() {
window.open( jQuery(this).attr( 'href' ), 'wpcomfacebook', 'menubar=1,resizable=1,width=600,height=400' );
return false;
});
});
</script>
<script type="text/javascript" charset="utf-8">
function sharing_plusone( obj ) {
jQuery.ajax( {
url: 'http://www.whyhat.com/2011/10/ai-class-com/?share=google-plus-1',
type: 'POST',
data: obj
} );
}
jQuery( document.body ).on( 'post-load', function() {
gapi.plusone.go();
});
</script>
<script type="text/javascript" src="//apis.google.com/js/plusone.js"></script> <script type="text/javascript">
jQuery( document ).ready( function() {
jQuery.getScript( 'http://platform.linkedin.com/in.js?async=true', function success() {
IN.init();
});
});
jQuery( document.body ).on( 'post-load', function() {
IN.parse();
});
</script><script type='text/javascript' src='http://s0.wp.com/wp-content/js/devicepx-jetpack.js?ver=201307'></script>
<script type='text/javascript' src='http://s.gravatar.com/js/gprofiles.js?ver=2013Febaa'></script>
<script type='text/javascript'>
/* <![CDATA[ */
var WPGroHo = {"my_hash":""};
/* ]]> */
</script>
<script type='text/javascript' src='http://www.whyhat.com/wp-content/plugins/jetpack/modules/wpgroho.js?ver=3.5.1'></script>
<script type="text/javascript">
(function() {
var t = document.createElement('script');
t.type = 'text/javascript';
t.async = true;
t.id = 'gauges-tracker';
t.setAttribute('data-site-id', '4f04d8b2844d523267000001');
t.src = '//secure.gaug.es/track.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
})();
</script>
<script src="http://stats.wordpress.com/e-201307.js" type="text/javascript"></script>
<script type="text/javascript">
st_go({v:'ext',j:'1:2.1.1',blog:'28310808',post:'0',tz:'-4'});
var load_cmc = function(){linktracker_init(28310808,0,2);};
if ( typeof addLoadEvent != 'undefined' ) addLoadEvent(load_cmc);
else load_cmc();
</script>
</body>
</html>