<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[hmmm....]]></title>
  <link href="http://michael.thegrebs.com/atom.xml" rel="self"/>
  <link href="http://michael.thegrebs.com/"/>
  <updated>2013-01-18T15:17:18-05:00</updated>
  <id>http://michael.thegrebs.com/</id>
  <author>
    <name><![CDATA[mikegrb]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Alfred 2 Workflow for Audio Device Selection]]></title>
    <link href="http://michael.thegrebs.com/2013/01/18/alfred2-audio-device/"/>
    <updated>2013-01-18T16:12:32-05:00</updated>
    <id>http://michael.thegrebs.com/2013/01/18/alfred2-audio-device</id>
    <content type="html"><![CDATA[<p><a href="http://blog.alfredapp.com/2012/12/05/alfred-v2-coming-soon/">Alfred V2</a> has a great new feature called <a href="http://blog.alfredapp.com/2012/12/14/v2-sneak-peek-workflows/">workflows</a>.  I&#8217;ve been playing with a few others wrote and had ported my old custom commands to workflows but was looking for something to really make use of their power.</p>

<p><img src="http://michael.thegrebs.com/assets/2013/old_busted.png" width="337" height="347" alt="Changing OSX Audio device from menubar" style="float: right" />
Changing the selected audio output device was just the thing to implement as a workflow.  OS X has a nice shortcut for doing this without heading to system preferences.  Option clicking the speaker in the menu bar well let you change the input or output device, but I wanted to do it easily from the keyboard.</p>

<p>The &#8216;Script Filter&#8217; option under the input menu is the magic for this workflow.  It allows a script to output a list of items for display and selection in the Alfred GUI.  You get Alfred&#8217;s great predictive auto complete which makes selecting a device a breeze.</p>

<p><img src="http://michael.thegrebs.com/assets/2013/select.png" width="620" height="345" alt="Selecting output audio device in Alfred" /></p>

<p>Output via Growl or Notification Center provides feedback of the completed action.</p>

<p><img src="http://michael.thegrebs.com/assets/2013/growl.png" width="353" height="178" alt="Growl confirmation"/></p>

<p>The workflow is pretty simple in Alfred&#8217;s workflow editor, it ends up looking like this:</p>

<p><img src="http://michael.thegrebs.com/assets/2013/workflow.png" width="832" height="548" alt="Alfred work flow" /></p>

<p>Alfred makes sharing workflows insanely easy by throwing all the necessary files for each workflow in a dedicated directory.  Right clicking a workflow in Alfred gives an export workflow option which creates a zip file of this directory with the &#8216;.alfredworkflow&#8217; extension.</p>

<p><a href="http://michael.thegrebs.com/assets/2013/SwitchAudio.alfredworkflow">Grab SwitchAudio.alfredworkflow</a></p>

<p>The heavy lifting is done by <a href="https://github.com/deweller/switchaudio-osx">switchaudio-osx</a> by deweller on GitHub with a simple perl glue script to pass data back and forth between Alfred and switchaudio-osx.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
<span class='line-number'>49</span>
<span class='line-number'>50</span>
</pre></td><td class='code'><pre><code class='perl'><span class='line'><span class="c1">#!/usr/bin/env perl</span>
</span><span class='line'>
</span><span class='line'><span class="k">use</span> <span class="n">strict</span><span class="p">;</span>
</span><span class='line'><span class="k">use</span> <span class="n">warnings</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">use</span> <span class="n">FindBin</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">my</span> <span class="nv">$action</span> <span class="o">=</span> <span class="nb">shift</span> <span class="o">||</span> <span class="s">&#39;list&#39;</span><span class="p">;</span>
</span><span class='line'><span class="k">my</span> <span class="nv">$direction</span> <span class="o">=</span> <span class="nb">shift</span> <span class="o">||</span> <span class="s">&#39;output&#39;</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">if</span> <span class="p">(</span><span class="nv">$action</span> <span class="ow">eq</span> <span class="s">&#39;list&#39;</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$devices</span> <span class="o">=</span> <span class="n">get_possibilities</span><span class="p">(</span><span class="nv">$direction</span><span class="p">);</span>
</span><span class='line'>    <span class="k">print</span> <span class="sx">qq{&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;items&gt;\n}</span><span class="p">;</span>
</span><span class='line'>    <span class="k">print</span> <span class="n">output_device</span><span class="p">(</span><span class="nv">$_</span><span class="p">)</span> <span class="k">for</span> <span class="nv">@$devices</span><span class="p">;</span>
</span><span class='line'>    <span class="k">print</span> <span class="s">&quot;&lt;/items&gt;\n&quot;</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="k">if</span> <span class="p">(</span> <span class="nv">$action</span> <span class="ow">eq</span> <span class="s">&#39;set&#39;</span> <span class="p">)</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$device</span> <span class="o">=</span> <span class="nb">shift</span><span class="p">;</span>
</span><span class='line'>    <span class="k">print</span> <span class="n">set_device</span><span class="p">(</span><span class="nv">$direction</span><span class="p">,</span> <span class="nv">$device</span><span class="p">)</span> <span class="o">.</span> <span class="s">&quot;\n&quot;</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="k">sub </span><span class="nf">get_possibilities</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$direction</span> <span class="o">=</span> <span class="nb">shift</span><span class="p">;</span>
</span><span class='line'>    <span class="k">my</span> <span class="nv">@devices</span><span class="p">;</span>
</span><span class='line'>    <span class="nb">open</span><span class="p">(</span> <span class="k">my</span> <span class="nv">$fh</span><span class="p">,</span> <span class="s">&#39;-|&#39;</span><span class="p">,</span> <span class="nv">$</span><span class="nn">FindBin::</span><span class="nv">Bin</span> <span class="o">.</span> <span class="s">&#39;/SwitchAudioSource&#39;</span><span class="p">,</span>
</span><span class='line'>        <span class="s">&#39;-at&#39;</span><span class="p">,</span> <span class="nv">$direction</span> <span class="p">);</span>
</span><span class='line'>    <span class="k">while</span> <span class="p">(</span> <span class="k">my</span> <span class="nv">$line</span> <span class="o">=</span> <span class="sr">&lt;$fh&gt;</span> <span class="p">)</span> <span class="p">{</span>
</span><span class='line'>        <span class="nb">chomp</span> <span class="nv">$line</span><span class="p">;</span>
</span><span class='line'>        <span class="nv">$line</span> <span class="o">=~</span> <span class="sr">s/ \(\Q$direction\E\)$//</span><span class="p">;</span>
</span><span class='line'>        <span class="nb">push</span> <span class="nv">@devices</span><span class="p">,</span> <span class="nv">$line</span><span class="p">;</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>    <span class="nb">close</span> <span class="nv">$fh</span><span class="p">;</span>
</span><span class='line'>    <span class="k">return</span> <span class="o">\</span><span class="nv">@devices</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="k">sub </span><span class="nf">set_device</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">my</span> <span class="p">(</span> <span class="nv">$direction</span><span class="p">,</span> <span class="nv">$device</span> <span class="p">)</span> <span class="o">=</span> <span class="nv">@_</span><span class="p">;</span>
</span><span class='line'>    <span class="nb">open</span><span class="p">(</span> <span class="k">my</span> <span class="nv">$fh</span><span class="p">,</span> <span class="s">&#39;-|&#39;</span><span class="p">,</span> <span class="nv">$</span><span class="nn">FindBin::</span><span class="nv">Bin</span> <span class="o">.</span> <span class="s">&#39;/SwitchAudioSource&#39;</span><span class="p">,</span>
</span><span class='line'>        <span class="s">&#39;-t&#39;</span><span class="p">,</span> <span class="nv">$direction</span><span class="p">,</span> <span class="s">&#39;-s&#39;</span><span class="p">,</span> <span class="nv">$device</span> <span class="p">);</span>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$output</span> <span class="o">=</span> <span class="nb">join</span> <span class="s">&quot;\n&quot;</span><span class="p">,</span> <span class="sr">&lt;$fh&gt;</span><span class="p">;</span>
</span><span class='line'>    <span class="nb">close</span> <span class="nv">$fh</span><span class="p">;</span>
</span><span class='line'>    <span class="k">return</span> <span class="nv">$output</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="k">sub </span><span class="nf">output_device</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$device</span> <span class="o">=</span> <span class="nb">shift</span><span class="p">;</span>
</span><span class='line'>    <span class="p">(</span> <span class="k">my</span> <span class="nv">$device_no_space</span> <span class="o">=</span> <span class="nv">$device</span> <span class="p">)</span> <span class="o">=~</span> <span class="nb">tr</span><span class="sr">/ /</span><span class="n">_</span><span class="o">/</span><span class="p">;</span>
</span><span class='line'>    <span class="k">return</span> <span class="sx">qq{&lt;item arg=&quot;$device&quot; uid=&quot;$device_no_space&quot;&gt;&lt;title&gt;$device&lt;/title&gt;&lt;subtitle/&gt;&lt;icon&gt;icon.png&lt;/icon&gt;&lt;/item&gt;\n}</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Fair Trade Coffee Price Premium]]></title>
    <link href="http://michael.thegrebs.com/2012/09/17/fair-trade-cofee-price-premium/"/>
    <updated>2012-09-17T17:12:32-04:00</updated>
    <id>http://michael.thegrebs.com/2012/09/17/fair-trade-cofee-price-premium</id>
    <content type="html"><![CDATA[<p><a href="http://www.gtnj.org">Galloway Township</a> considered a resolution last week that
would support fair trade practices. <a href="http://galloway.patch.com/articles/galloway-council-tables-fair-trade-resolution">The resolution was tabled</a>
after some brief discussion.  The cost difference between fair trade and non fair
trade items was brought up and I was curious how much of a difference there was.</p>

<p>The town currently gets most office supplies from WB Mason.  I do not know if this
includes coffee but at work we get our coffee from WB Mason so as any Geek would
do, I made a spread sheet.</p>

<iframe width='325' height='475' frameborder='0' src='https://docs.google.com/spreadsheet/pub?key=0ApQLyevSltTgdGVWX1lfY2xUV0kweGhXelpMNlh5d0E&single=true&gid=0&output=html&widget=true'></iframe>


<p><a href="https://docs.google.com/a/thegrebs.com/spreadsheet/pub?key=0ApQLyevSltTgdGVWX1lfY2xUV0kweGhXelpMNlh5d0E&amp;single=true&amp;gid=0&amp;output=html&amp;widget=true">Direct Link to Google Docs Spreadsheet</a></p>

<p>There are only two fair trade items in this category but they are right in line
with prices for non fair trade varieties.  If you are already using one of the
non fair trade blends from the two companies with a fair trade blend, there is 0
price difference.</p>

<p>This lack of price difference surprised me.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[ZSH Completion Waiting Dots]]></title>
    <link href="http://michael.thegrebs.com/2012/09/04/zsh-completion-waiting-dots/"/>
    <updated>2012-09-04T00:11:27-04:00</updated>
    <id>http://michael.thegrebs.com/2012/09/04/zsh-completion-waiting-dots</id>
    <content type="html"><![CDATA[<p>ZSH has some pretty nice tab completion but some of the completion modules can make things slow when you have a high latency conection.  This can be extra harsh for me as I have failure to complete beeps turned off so I&#8217;m not sure if it&#8217;s still trying to complete or if there were no matches.  When reading some zshrc snippts on <a href="http://stackoverflow.com">Stack Overflow</a> I came accross my favorite new snippit.</p>

<p><a href="http://stackoverflow.com/a/844299">This snippet</a> from <a href="http://stackoverflow.com/users/102704/a-paid-nerd">a paid nerd</a> adds &#8216;&#8230;&#8217; output during completion that is replaced with the completion or removed once the completion engine is finished.</p>

<p>Here&#8217;s the snippet:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'><span class="c"># http://stackoverflow.com/a/844299</span>
</span><span class='line'>expand-or-complete-with-dots<span class="o">()</span> <span class="o">{</span>
</span><span class='line'>  <span class="nb">echo</span> -n <span class="s2">&quot;\e[31m...\e[0m&quot;</span>
</span><span class='line'>  zle expand-or-complete
</span><span class='line'>  zle redisplay
</span><span class='line'><span class="o">}</span>
</span><span class='line'>zle -N expand-or-complete-with-dots
</span><span class='line'>bindkey <span class="s2">&quot;^I&quot;</span> expand-or-complete-with-dots
</span></code></pre></td></tr></table></div></figure>


<p>Also, get yourself in the habbit of including a comment with a url for stuff like this.  I once wanted to write a blog post about something I found somewhere and couldn&#8217;t remember where I found it online!  I&#8217;ll never make that mistake again.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Syncing zsh named directories]]></title>
    <link href="http://michael.thegrebs.com/2012/08/06/syncing-zsh-named-directories/"/>
    <updated>2012-08-06T22:45:21-04:00</updated>
    <id>http://michael.thegrebs.com/2012/08/06/syncing-zsh-named-directories</id>
    <content type="html"><![CDATA[<p>One of my most used features of zsh is <a href="http://zsh.sourceforge.net/Guide/zshguide02.html#l20">named directories</a>.  I keep my dotfiles synced across multiple machines via <a href="http://db.tt/InZto9O">Dropbox</a> (referral link) and a Makefile that creates symlinks automagically.</p>

<p>My named directories start with ~ for my home directory so they need to exist for expansion to work properly and not output errors when I log in.  When I first implemented syncing I added this check with a very simple test:</p>

<!-- more -->




<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'><span class="o">[[</span> -d ~/Dropbox/wiki           <span class="o">]]</span> <span class="o">&amp;&amp;</span> <span class="nv">wiki</span><span class="o">=</span>~/Dropbox/wiki
</span></code></pre></td></tr></table></div></figure>


<p>One line like this isn&#8217;t too bad but when you have 30, it gets a little silly looking.</p>

<p>I finally took the time to sit down and read the docs on zsh <a href="http://zsh.sourceforge.net/Guide/zshguide05.html#l122">associative arrays</a> and whipped up a much better solution.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'><span class="nb">typeset</span> -A NAMED_DIRS
</span><span class='line'>
</span><span class='line'><span class="nv">NAMED_DIRS</span><span class="o">=(</span>
</span><span class='line'>    bin      ~/Dropbox/Documents/bin
</span><span class='line'>    docs     ~/Dropbox/Documents
</span><span class='line'>    lbin     ~/Documents/bin
</span><span class='line'>    wiki     ~/Dropbox/wiki
</span><span class='line'>    dot      ~/Dropbox/Documents/dotfiles
</span><span class='line'>    octo     ~/Dropbox/Documents/octopress
</span><span class='line'><span class="o">)</span>
</span><span class='line'>
</span><span class='line'><span class="k">for </span>key in <span class="k">${</span><span class="p">(k)NAMED_DIRS</span><span class="k">}</span>
</span><span class='line'><span class="k">do</span>
</span><span class='line'><span class="k">    if</span> <span class="o">[[</span> -d <span class="k">${</span><span class="nv">NAMED_DIRS</span><span class="p">[</span><span class="nv">$key</span><span class="p">]</span><span class="k">}</span> <span class="o">]]</span>; <span class="k">then</span>
</span><span class='line'><span class="k">        </span><span class="nb">export</span> <span class="nv">$key</span><span class="o">=</span><span class="k">${</span><span class="nv">NAMED_DIRS</span><span class="p">[</span><span class="nv">$key</span><span class="p">]</span><span class="k">}</span>
</span><span class='line'>    <span class="k">else</span>
</span><span class='line'><span class="k">        </span><span class="nb">unset</span> <span class="s2">&quot;NAMED_DIRS[$key]&quot;</span>
</span><span class='line'>    <span class="k">fi</span>
</span><span class='line'><span class="k">done</span>
</span></code></pre></td></tr></table></div></figure>


<p>The unset isn&#8217;t necessary here for the base functionality.  I had another problem.  With 30 or 40 named dirs, some belonging to projects that I might not have looked at in 6 months and suddenly need to come back to, it&#8217;s hard to remember the name I gave for a directory.  I added an lsdirs function that lists just the named directories that existing on the machine I&#8217;m on.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'><span class="k">function </span>lsdirs <span class="o">()</span> <span class="o">{</span>
</span><span class='line'>    <span class="k">for </span>key in <span class="k">${</span><span class="p">(k)NAMED_DIRS</span><span class="k">}</span>
</span><span class='line'>    <span class="k">do</span>
</span><span class='line'><span class="k">        </span><span class="nb">printf</span> <span class="s2">&quot;%-10s %s\n&quot;</span> <span class="nv">$key</span>  <span class="k">${</span><span class="nv">NAMED_DIRS</span><span class="p">[</span><span class="nv">$key</span><span class="p">]</span><span class="k">}</span>
</span><span class='line'>    <span class="k">done</span>
</span><span class='line'><span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>This gives me nice easy to read output with both the names and the full path.</p>

<p>This blog post is more future reference for myself but perhaps it may be useful to you.</p>

<p>For those interested, here is the Makefile I use:</p>

<figure class='code'><figcaption><span> (Makefile)</span> <a href='http://michael.thegrebs.com/downloads/code/2012/Makefile'>download</a></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
</pre></td><td class='code'><pre><code class='makefile'><span class='line'><span class="nv">DOTFILES</span> <span class="o">?=</span> <span class="k">$(</span>shell <span class="nb">pwd</span><span class="k">)</span>
</span><span class='line'>HOSTNAME ?<span class="o">=</span> <span class="k">$(</span>shell hostname<span class="k">)</span>
</span><span class='line'>
</span><span class='line'>all: shell code perl web mail
</span><span class='line'>
</span><span class='line'>shell:
</span><span class='line'>  ln -fs <span class="k">$(</span>DOTFILES<span class="k">)</span>/zsh/zshrc        <span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/.zshrc
</span><span class='line'>  ln -fns <span class="k">$(</span>DOTFILES<span class="k">)</span>/zsh/zsh.d       <span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/.zsh.d
</span><span class='line'>  ln -fs <span class="k">$(</span>DOTFILES<span class="k">)</span>/gnupg            <span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/.gnupg
</span><span class='line'>  ln -fs <span class="k">$(</span>DOTFILES<span class="k">)</span>/ssh/config       <span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/.ssh/config
</span><span class='line'>
</span><span class='line'><span class="cp">    ifeq ($(HOSTNAME),orion)</span>
</span><span class='line'>      ln -fs <span class="k">$(</span>DOTFILES<span class="k">)</span>/screen/screenrc_orion <span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/.screenrc
</span><span class='line'><span class="cp">    else</span>
</span><span class='line'>      ln -fs <span class="k">$(</span>DOTFILES<span class="k">)</span>/screen/screenrc  <span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/.screenrc
</span><span class='line'><span class="cp">    endif</span>
</span><span class='line'>
</span><span class='line'>code:
</span><span class='line'>  ln -fs <span class="k">$(</span>DOTFILES<span class="k">)</span>/gitconfig        <span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/.gitconfig
</span><span class='line'>  ln -fs <span class="k">$(</span>DOTFILES<span class="k">)</span>/vimrc            <span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/.vimrc
</span><span class='line'>  ln -fns <span class="k">$(</span>DOTFILES<span class="k">)</span>/vim             <span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/.vim
</span><span class='line'>  ln -fs <span class="k">$(</span>DOTFILES<span class="k">)</span>/.tm_properties  <span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/.tm_properties
</span><span class='line'>
</span><span class='line'>perl:
</span><span class='line'>  ln -fs <span class="k">$(</span>DOTFILES<span class="k">)</span>/perltidyrc       <span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/.perltidyrc
</span><span class='line'>  ln -fs <span class="k">$(</span>DOTFILES<span class="k">)</span>/perlcritic       <span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/.perlcriticrc
</span><span class='line'>
</span><span class='line'>web:
</span><span class='line'>  ln -fs <span class="k">$(</span>DOTFILES<span class="k">)</span>/vimperatorrc   <span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/.vimperatorrc
</span><span class='line'>
</span><span class='line'>mail:
</span><span class='line'>  ln -fs <span class="k">$(</span>DOTFILES<span class="k">)</span>/muttrc           <span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/.muttrc
</span></code></pre></td></tr></table></div></figure>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[DHS NOC MNC Poor Security Examples]]></title>
    <link href="http://michael.thegrebs.com/2012/05/29/DHS-NOC-MNC-Security-Example/"/>
    <updated>2012-05-29T20:32:10-04:00</updated>
    <id>http://michael.thegrebs.com/2012/05/29/DHS-NOC-MNC-Security-Example</id>
    <content type="html"><![CDATA[<p><img src="http://michael.thegrebs.com/images/2012/US_Department_of_Homeland_Security_Seal.png" width="220" height="219" style="float: left;margin-right: 25px;margin-bottom:25px" />
The Media Monitoring Capability of the The Department of Homeland Security&#8217;s National Operations Center is tasked with keeping existing situation summaries for both domestic and international events up to date with open source media information.  Their second mission is &#8220;to constantly monitor all available open source information with the goal of expeditiously alerting the NOC Watch Team and other key Department personnel of emergent situations&#8221;.  This means monitoring both various online news sites as well as social networking.</p>

<p>Through a Freedom of Information Act request their <a href="http://michael.thegrebs.com/assets/2012/AnalystDesktopBinder-Redacted-.pdf">Analyst&#8217;s Desktop Binder</a> (4.4 MB PDF) was made publicly available.  This is essentially the employee manual for MMC analysts, describing how to preform their job.  There are quite a few very interesting tid bits in it such as the list of keywords and search terms used when searching social media sites.</p>

<!-- more -->


<p>Section 2.6 beginning on page 14 lists credible sources broken out into various tiers.  Local affiliates of the major networks are considered first tier sources and don&#8217;t require any additional corroboration prior to release.  Meanwhile, all blogs &#8220;even if they are of a serious, political nature,&#8221; are considered third tier sources and must be corroborated by a first tier source.</p>

<p>Also of interest were screen shots of various interfaces they use such as the Item Of Interest (IOI) report screen used to log an article and useful metadata.</p>

<p><img src="http://michael.thegrebs.com/images/2012/create-ioi.png" width="789" height="511" /></p>

<p>The real problem with this document is the peak inside Homeland Security at how they do things.</p>

<p>Near the end, in section 8 &#8216;Usernames, Passwords &amp; Contact Information,&#8217; we see that a common username and password are shared amongst analysts to log in to computers, shared drives, DHS email, and more.</p>

<p><img src="http://michael.thegrebs.com/images/2012/sharing-is-caring.png" width="457" height="500" .></p>

<p>I am interested in the twitter information in this section. <a href="https://twitter.com/#!/DHSNOCMMC1">@DHSNOCMMC1</a> is a protected twitter account with no tweets and following 339 users.  I&#8217;d love to see the followers list but I&#8217;m sure it is filled with just a lot of boring traditional news organizations.</p>

<p>Jumping back a bit, to section 7, we find something even worse.  This section is called &#8220;HSIN <strong><em>REDACTED</em></strong> Connection Instructions.&#8221;  Here we see that <strong><em>REDACTED</em></strong> is a system that is so vital to our security that even it&#8217;s name must not be known.</p>

<p><img src="http://michael.thegrebs.com/images/2012/sekrit.png" width="753" height="312" /></p>

<p>See?!?  It&#8217;s obvious even to my seven year old that this is a system so vital to keep secret that even the name must be secret.</p>

<p>If one continues reading this section you come across this very surprising passage:</p>

<p><img src="http://michael.thegrebs.com/images/2012/security-is-for-wuss.png" width="675" height="301" /></p>

<p>For those using screen readers due to blindness or those not trusting their eyes, this is the sentence in that image:</p>

<blockquote><p>After clicking on next, the following screen will appear and you must select “Accept for all sessions”</p></blockquote>

<p>This is followed by an image of an invalid SSL certificate warning dialog.  All along experts have worried about teaching everyone&#8217;s mother not to blindly accept invalid certificate warnings.  If Homeland Security is instructing their analysts to blindly accept invalid SSL certificate warnings then not only have we lost the war, the enemy is dancing on our grave as the baby jesus cries dark tears in the corner.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Thermostat RRD display with Javascript]]></title>
    <link href="http://michael.thegrebs.com/2012/05/25/thermostat-rrd-javascript/"/>
    <updated>2012-05-25T08:50:21-04:00</updated>
    <id>http://michael.thegrebs.com/2012/05/25/thermostat-rrd-javascript</id>
    <content type="html"><![CDATA[<p>In the <a href="http://michael.thegrebs.com/2012/05/20/tweeting-thermostat/">last post</a> I described my new <a href="http://www.homedepot.com/buy/electrical-home-automation-security-home-automation-climate-control/filtrete-7-day-touchscreen-wifi-enabled-programmable-thermostat-with-backlight-182800.html">Filtrete 3M-50 thermostat</a> and my data collection using a <a href="http://central.isaroach.com/wiki/index.php/Perl#Poller">script</a> from a <a href="http://central.isaroach.com/wiki/index.php/Main_Page">wiki</a>.  I wanted an easy way to get values for datapoints on the graphs and have been looking for a use for <a href="http://javascriptrrd.sourceforge.net/">javascriptRRD</a> since discovering it a year or more ago.</p>

<p>I ended up having to modify the library slightly to get it to pass the yaxes option on to flot.  My source is over on <a href="https://github.com/mikegrb/jsrrdthermostat">github</a>.</p>

<p><img src="http://michael.thegrebs.com/images/2012/jsthermrrd.png" /></p>

<p>You can see the real time data <a href="http://thegrebs.com/~michael/thermostat/jsrrd.html">over here</a>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Tweeting Thermostat]]></title>
    <link href="http://michael.thegrebs.com/2012/05/20/tweeting-thermostat/"/>
    <updated>2012-05-20T18:45:05-04:00</updated>
    <id>http://michael.thegrebs.com/2012/05/20/tweeting-thermostat</id>
    <content type="html"><![CDATA[<p><img src="http://michael.thegrebs.com/images/2012/3m-50.jpg" /></p>

<p>I recently replaced the thermostat in our new house with a <a href="http://www.homedepot.com/buy/electrical-home-automation-security-home-automation-climate-control/filtrete-7-day-touchscreen-wifi-enabled-programmable-thermostat-with-backlight-182800.html">Filtrete 3M-50</a>.  This thermostat has a wifi module and is available at your local Home Depot for $99.  I&#8217;d been aware of it for a while but had planned on purchasing the $250 <a href="http://www.nest.com/">nest</a>.  The turning point for me came one even as I was going to bed.  I was hot, the heat was running and I chose to turn the fan on instead of going downstairs and adjusting the thermostat.  In my defense, I knew the thermostat would switch to night mode in another 45 minutes and reduce the set point but I was still wasting energy.</p>

<p>Comparing the Filtrete to the nest the main features you are missing out on are:</p>

<!-- more -->


<ul>
<li>automatic occupancy detection</li>
<li>humidity detection</li>
<li>automatic schedule learning</li>
</ul>


<p>Automatic scheduling is a big win for the average person but our schedule isn&#8217;t static enough for this to be much benifit to us.  The location of our thermostat is about the best place for a thermostat, but not for occupancy detection so this feature isn&#8217;t missed.  I&#8217;m a bit sad with the loss of humidity detection, the next model up Filtrete has it for $200 but it&#8217;s not a deal breaker.</p>

<p>The real win for geeks with a WIFI thermostat isn&#8217;t the iPhone or Android Apps, it&#8217;s the ability to interface with it and do geeky things.  The Filtrete 3M-50 is a rebadged <a href="http://www.radiothermostat.com/control.html">Radio Thermostat Company of America CT30</a>.  Radio Thermostat has the API documentation hidden on their website in the <a href="http://www.radiothermostat.com/latestnews.html#advanced">latest news section</a>.  Scroll to the bottom of the page and click the &#8216;I Accept&#8217; checkbox.  There is also a <a href="http://central.isaroach.com/wiki/index.php/Main_Page">3rd party wiki</a> with API documentation and sample code.</p>

<p>I started with the <a href="http://central.isaroach.com/wiki/index.php/Perl#Poller">poller.pl</a> script available on the wiki to go from nothing to something quickly.  There&#8217;s a lack of error checking in it and the non CPANed Radio::Thermostat module available on that page but it gets you up and running quickly.</p>

<p><img src="http://michael.thegrebs.com/images/2012/temperature-daily.png" /></p>

<p>After this, I wrote a simple script to tweet daily thermostat information.</p>

<figure class='code'><figcaption><span> (tweetstat.pl)</span> <a href='http://michael.thegrebs.com/downloads/code/2012/tweetstat.pl'>download</a></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
<span class='line-number'>49</span>
<span class='line-number'>50</span>
<span class='line-number'>51</span>
<span class='line-number'>52</span>
<span class='line-number'>53</span>
<span class='line-number'>54</span>
<span class='line-number'>55</span>
<span class='line-number'>56</span>
<span class='line-number'>57</span>
<span class='line-number'>58</span>
<span class='line-number'>59</span>
<span class='line-number'>60</span>
<span class='line-number'>61</span>
<span class='line-number'>62</span>
<span class='line-number'>63</span>
<span class='line-number'>64</span>
<span class='line-number'>65</span>
<span class='line-number'>66</span>
<span class='line-number'>67</span>
<span class='line-number'>68</span>
<span class='line-number'>69</span>
<span class='line-number'>70</span>
<span class='line-number'>71</span>
<span class='line-number'>72</span>
<span class='line-number'>73</span>
<span class='line-number'>74</span>
<span class='line-number'>75</span>
<span class='line-number'>76</span>
<span class='line-number'>77</span>
<span class='line-number'>78</span>
<span class='line-number'>79</span>
<span class='line-number'>80</span>
<span class='line-number'>81</span>
<span class='line-number'>82</span>
<span class='line-number'>83</span>
<span class='line-number'>84</span>
<span class='line-number'>85</span>
<span class='line-number'>86</span>
<span class='line-number'>87</span>
<span class='line-number'>88</span>
<span class='line-number'>89</span>
<span class='line-number'>90</span>
<span class='line-number'>91</span>
<span class='line-number'>92</span>
<span class='line-number'>93</span>
<span class='line-number'>94</span>
<span class='line-number'>95</span>
<span class='line-number'>96</span>
<span class='line-number'>97</span>
<span class='line-number'>98</span>
<span class='line-number'>99</span>
<span class='line-number'>100</span>
<span class='line-number'>101</span>
</pre></td><td class='code'><pre><code class='perl'><span class='line'><span class="c1">#!/usr/bin/perl </span>
</span><span class='line'>
</span><span class='line'><span class="k">use</span> <span class="mf">5.010</span><span class="p">;</span>
</span><span class='line'><span class="k">use</span> <span class="n">strict</span><span class="p">;</span>
</span><span class='line'><span class="k">use</span> <span class="n">warnings</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">use</span> <span class="n">RRDs</span><span class="p">;</span>
</span><span class='line'><span class="k">use</span> <span class="n">DateTime</span><span class="p">;</span>
</span><span class='line'><span class="k">use</span> <span class="nn">Net::</span><span class="n">Twitter</span><span class="p">;</span>
</span><span class='line'><span class="k">use</span> <span class="nn">Mojo::</span><span class="n">UserAgent</span><span class="p">;</span>
</span><span class='line'><span class="k">use</span> <span class="nn">List::</span><span class="n">Util</span> <span class="s">&#39;sum&#39;</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">my</span> <span class="nv">$runtime</span>  <span class="o">=</span> <span class="n">get_runtime_string</span><span class="p">();</span>
</span><span class='line'><span class="k">my</span> <span class="nv">$averages</span> <span class="o">=</span> <span class="n">get_averages_string</span><span class="p">();</span>
</span><span class='line'>
</span><span class='line'><span class="nb">die</span> <span class="k">unless</span> <span class="nv">$runtime</span> <span class="o">&amp;&amp;</span> <span class="nv">$averages</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">my</span> <span class="nv">$tweet</span> <span class="o">=</span> <span class="s">&quot;Yesterday $averages with $runtime.&quot;</span><span class="p">;</span>
</span><span class='line'><span class="n">say</span> <span class="nv">$tweet</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">my</span> <span class="nv">$consumer_key</span>    <span class="o">=</span> <span class="s">&#39;&#39;</span><span class="p">;</span>
</span><span class='line'><span class="k">my</span> <span class="nv">$consumer_secret</span> <span class="o">=</span> <span class="s">&#39;&#39;</span><span class="p">;</span>
</span><span class='line'><span class="k">my</span> <span class="nv">$token</span>           <span class="o">=</span> <span class="s">&#39;&#39;</span><span class="p">;</span>
</span><span class='line'><span class="k">my</span> <span class="nv">$token_secret</span>    <span class="o">=</span> <span class="s">&#39;&#39;</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">my</span> <span class="nv">$thermostat_url</span>  <span class="o">=</span> <span class="s">&#39;http://10.8.8.98/tstat/datalog&#39;</span><span class="p">;</span>
</span><span class='line'><span class="k">my</span> <span class="nv">$rrd_path</span>        <span class="o">=</span> <span class="s">&#39;/home/michael/srv/therm/poller/data/temperature.rrd&#39;</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">my</span> <span class="nv">$nt</span> <span class="o">=</span> <span class="nn">Net::</span><span class="n">Twitter</span><span class="o">-&gt;</span><span class="k">new</span><span class="p">(</span>
</span><span class='line'>    <span class="n">traits</span>   <span class="o">=&gt;</span> <span class="p">[</span><span class="sx">qw/OAuth API::REST/</span><span class="p">],</span>
</span><span class='line'>    <span class="n">consumer_key</span>        <span class="o">=&gt;</span> <span class="nv">$consumer_key</span><span class="p">,</span>
</span><span class='line'>    <span class="n">consumer_secret</span>     <span class="o">=&gt;</span> <span class="nv">$consumer_secret</span><span class="p">,</span>
</span><span class='line'>    <span class="n">access_token</span>        <span class="o">=&gt;</span> <span class="nv">$token</span><span class="p">,</span>
</span><span class='line'>    <span class="n">access_token_secret</span> <span class="o">=&gt;</span> <span class="nv">$token_secret</span><span class="p">,</span>
</span><span class='line'><span class="p">);</span>
</span><span class='line'>
</span><span class='line'><span class="nv">$nt</span><span class="o">-&gt;</span><span class="n">update</span><span class="p">(</span><span class="nv">$tweet</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>
</span><span class='line'><span class="k">sub </span><span class="nf">get_runtime_string</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$ua</span> <span class="o">=</span> <span class="nn">Mojo::</span><span class="n">UserAgent</span><span class="o">-&gt;</span><span class="k">new</span><span class="p">;</span>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$res</span> <span class="o">=</span> <span class="nv">$ua</span><span class="o">-&gt;</span><span class="n">get</span><span class="p">(</span><span class="nv">$thermostat_url</span><span class="p">)</span><span class="o">-&gt;</span><span class="n">res</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>    <span class="nb">die</span> <span class="s">&quot;Didn&#39;t get runtimes for yesterday&quot;</span> <span class="k">unless</span> <span class="nv">$res</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$data</span> <span class="o">=</span> <span class="nv">$res</span><span class="o">-&gt;</span><span class="n">json</span><span class="p">;</span>
</span><span class='line'>    <span class="k">return</span> <span class="n">build_runtime_string</span><span class="p">(</span><span class="s">&#39;heat&#39;</span><span class="p">,</span> <span class="nv">$data</span><span class="o">-&gt;</span><span class="p">{</span> <span class="n">yesterday</span> <span class="p">}</span> <span class="p">)</span>
</span><span class='line'>        <span class="o">||</span> <span class="n">build_runtime_string</span><span class="p">(</span><span class="s">&#39;cool&#39;</span><span class="p">,</span> <span class="nv">$data</span><span class="o">-&gt;</span><span class="p">{</span> <span class="n">yesterday</span> <span class="p">}</span> <span class="p">)</span>
</span><span class='line'>        <span class="o">||</span> <span class="s">&quot;no heat or A/C used&quot;</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="k">sub </span><span class="nf">build_runtime_string</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">my</span> <span class="p">(</span><span class="nv">$mode</span><span class="p">,</span> <span class="nv">$data</span><span class="p">)</span>  <span class="o">=</span> <span class="nv">@_</span><span class="p">;</span>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$times</span> <span class="o">=</span> <span class="nv">$data</span><span class="o">-&gt;</span><span class="p">{</span> <span class="nv">$mode</span> <span class="o">.</span> <span class="s">&#39;_runtime&#39;</span> <span class="p">};</span>
</span><span class='line'>    <span class="k">return</span> <span class="k">unless</span> <span class="nv">$times</span><span class="o">-&gt;</span><span class="p">{</span> <span class="n">hour</span> <span class="p">}</span> <span class="o">||</span> <span class="nv">$times</span><span class="o">-&gt;</span><span class="p">{</span> <span class="n">minute</span> <span class="p">};</span>
</span><span class='line'>    <span class="k">return</span> <span class="nb">sprintf</span> <span class="s">&#39;%sing runtime of %i:%02i&#39;</span><span class="p">,</span>
</span><span class='line'>        <span class="nv">$mode</span><span class="p">,</span> <span class="nv">$times</span><span class="o">-&gt;</span><span class="p">{</span> <span class="n">hour</span> <span class="p">},</span> <span class="nv">$times</span><span class="o">-&gt;</span><span class="p">{</span> <span class="n">minute</span> <span class="p">};</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="k">sub </span><span class="nf">get_averages_string</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$yesterday</span> <span class="o">=</span> <span class="n">DateTime</span><span class="o">-&gt;</span><span class="n">now</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">subtract</span><span class="p">(</span> <span class="n">days</span> <span class="o">=&gt;</span> <span class="mi">1</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$start_of_day</span> <span class="o">=</span> <span class="n">DateTime</span><span class="o">-&gt;</span><span class="k">new</span><span class="p">(</span>
</span><span class='line'>        <span class="n">year</span>    <span class="o">=&gt;</span> <span class="nv">$yesterday</span><span class="o">-&gt;</span><span class="n">year</span><span class="p">,</span>
</span><span class='line'>        <span class="n">month</span>   <span class="o">=&gt;</span> <span class="nv">$yesterday</span><span class="o">-&gt;</span><span class="n">month</span><span class="p">,</span>
</span><span class='line'>        <span class="n">day</span>     <span class="o">=&gt;</span> <span class="nv">$yesterday</span><span class="o">-&gt;</span><span class="n">day</span><span class="p">,</span>
</span><span class='line'>        <span class="n">hour</span>   <span class="o">=&gt;</span> <span class="mi">0</span><span class="p">,</span>
</span><span class='line'>        <span class="n">minute</span> <span class="o">=&gt;</span> <span class="mi">0</span><span class="p">,</span>
</span><span class='line'>        <span class="n">second</span> <span class="o">=&gt;</span> <span class="mi">0</span><span class="p">,</span>
</span><span class='line'>        <span class="n">time_zone</span> <span class="o">=&gt;</span> <span class="s">&#39;America/New_York&#39;</span>
</span><span class='line'>    <span class="p">);</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$end_of_day</span> <span class="o">=</span> <span class="nv">$start_of_day</span><span class="o">-&gt;</span><span class="n">clone</span><span class="o">-&gt;</span><span class="n">add</span><span class="p">(</span> <span class="n">hours</span> <span class="o">=&gt;</span> <span class="mi">24</span> <span class="p">);</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">my</span> <span class="p">(</span><span class="nv">$start</span><span class="p">,</span><span class="nv">$step</span><span class="p">,</span><span class="nv">$names</span><span class="p">,</span><span class="nv">$data</span><span class="p">)</span> <span class="o">=</span> <span class="nn">RRDs::</span><span class="n">fetch</span> <span class="p">(</span>
</span><span class='line'>        <span class="nv">$rrd_path</span><span class="p">,</span>
</span><span class='line'>        <span class="s">&#39;AVERAGE&#39;</span><span class="p">,</span>
</span><span class='line'>        <span class="s">&#39;-s &#39;</span> <span class="o">.</span> <span class="nv">$start_of_day</span><span class="o">-&gt;</span><span class="n">epoch</span><span class="p">,</span>
</span><span class='line'>        <span class="s">&#39;-e &#39;</span> <span class="o">.</span> <span class="nv">$end_of_day</span><span class="o">-&gt;</span><span class="n">epoch</span>
</span><span class='line'>    <span class="p">);</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">if</span> <span class="p">(</span><span class="k">my</span> <span class="nv">$error</span> <span class="o">=</span> <span class="nn">RRDs::</span><span class="n">error</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>        <span class="nb">die</span> <span class="s">&quot;Error reading RRD data: $error&quot;</span><span class="p">;</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">my</span> <span class="p">(</span><span class="nv">@ext_temp</span><span class="p">,</span> <span class="nv">@int_temp</span><span class="p">);</span>
</span><span class='line'>    <span class="k">for</span> <span class="k">my</span> <span class="nv">$row</span> <span class="p">(</span><span class="nv">@$data</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>        <span class="k">next</span> <span class="k">unless</span> <span class="nb">grep</span> <span class="p">{</span> <span class="nv">$_</span> <span class="p">}</span> <span class="nv">@$row</span><span class="p">;</span>
</span><span class='line'>        <span class="k">my</span> <span class="p">(</span><span class="nv">$outside</span><span class="p">,</span> <span class="nv">$inside</span><span class="p">)</span> <span class="o">=</span> <span class="nv">@$row</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">];</span>
</span><span class='line'>        <span class="nb">push</span> <span class="nv">@ext_temp</span><span class="p">,</span> <span class="nv">$outside</span><span class="p">;</span>
</span><span class='line'>        <span class="nb">push</span> <span class="nv">@int_temp</span><span class="p">,</span> <span class="nv">$inside</span><span class="p">;</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>   <span class="k">return</span>  <span class="nb">sprintf</span> <span class="s">&quot;averaged %.1fF outside and %.1fF inside&quot;</span><span class="p">,</span>
</span><span class='line'>        <span class="n">average</span><span class="p">(</span> <span class="o">\</span><span class="nv">@ext_temp</span><span class="p">),</span> <span class="n">average</span><span class="p">(</span><span class="o">\</span><span class="nv">@int_temp</span><span class="p">);</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="k">sub </span><span class="nf">average</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$list</span> <span class="o">=</span> <span class="nb">shift</span><span class="p">;</span>
</span><span class='line'>    <span class="k">return</span> <span class="n">sum</span><span class="p">(</span><span class="nv">@$list</span><span class="p">)</span> <span class="o">/</span> <span class="nv">@$list</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>Tweets look like:</p>

<ul>
<li>Yesterday averaged 59.5F outside and 67.9F inside with no heat or A/C used.</li>
<li>Yesterday averaged 64.2F outside and 70.1F inside with heating runtime of 0:17.</li>
<li>Yesterday averaged 58.9F outside and 69.0F inside with heating runtime of 0:31.</li>
</ul>


<p>You can follow my house on Twitter as <a href="https://twitter.com/#!/mikegrbs_house">@mikegrbs_house</a>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Migrating Post Tags from Wordpress to Octopress]]></title>
    <link href="http://michael.thegrebs.com/2012/05/08/migrate-tags-wordpress-to/"/>
    <updated>2012-05-08T20:50:05-04:00</updated>
    <id>http://michael.thegrebs.com/2012/05/08/migrate-tags-wordpress-to</id>
    <content type="html"><![CDATA[<p>I&#8217;ve migrated from Wordpress to Octopress and used the Jekyll <a href="https://github.com/mojombo/jekyll/wiki/Blog-Migrations">wordpress migrator</a> to move my posts over.  Unfortunately, this doesn&#8217;t preserve post tags.  The output looks like this:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='yaml'><span class='line'><span class="nn">---</span>
</span><span class='line'><span class="l-Scalar-Plain">layout</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">post</span>
</span><span class='line'><span class="l-Scalar-Plain">title</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Devops w/ Perl @ Linode PPW Talk Slides</span>
</span><span class='line'><span class="l-Scalar-Plain">wordpress_id</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">330</span>
</span><span class='line'><span class="l-Scalar-Plain">wordpress_url</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">http://michael.thegrebs.com/?p=330</span>
</span><span class='line'><span class="l-Scalar-Plain">date</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">2011-10-27 14:46:31 -04:00</span>
</span><span class='line'><span class="nn">---</span>
</span><span class='line'><span class="l-Scalar-Plain">Earlier this month I gave a talk about...</span>
</span></code></pre></td></tr></table></div></figure>


<p>Having the wordpress post id means extracting the post tags from the db should be quite easy.  First we define our desired output:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class='yaml'><span class='line'><span class="nn">---</span>
</span><span class='line'><span class="l-Scalar-Plain">layout</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">post</span>
</span><span class='line'><span class="l-Scalar-Plain">title</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Devops w/ Perl @ Linode PPW Talk Slides</span>
</span><span class='line'><span class="l-Scalar-Plain">wordpress_id</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">330</span>
</span><span class='line'><span class="l-Scalar-Plain">wordpress_url</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">http://michael.thegrebs.com/?p=330</span>
</span><span class='line'><span class="l-Scalar-Plain">date</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">2011-10-27 14:46:31 -04:00</span>
</span><span class='line'><span class="l-Scalar-Plain">tags</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">geek perl slides</span>
</span><span class='line'><span class="nn">---</span>
</span><span class='line'><span class="l-Scalar-Plain">Earlier this month I gave a talk about ...</span>
</span></code></pre></td></tr></table></div></figure>


<p>The tags field really can appear anywhere in this YAML fragment but I chose to throw it at the end.  With 103 posts to loop over, run a query and insert a new line a short script makes sense.  The real win for our script though is using the <a href="https://metacpan.org/module/Tie::File">Tie::File</a> module which presents each file as an array with an element for each line.</p>

<!-- more -->


<p>From there it&#8217;s simply a matter of reverse engineering the Wordpress schema to come up with a query that will return a space delimited list of tags for a given post id.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='sql'><span class='line'><span class="k">SELECT</span> <span class="n">GROUP_CONCAT</span><span class="p">(</span><span class="n">t</span><span class="p">.</span><span class="o">`</span><span class="n">name</span><span class="o">`</span> <span class="n">SEPARATOR</span> <span class="ss">&quot; &quot;</span><span class="p">)</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">wp_term_relationships</span><span class="o">`</span> <span class="n">r</span>
</span><span class='line'><span class="k">INNER</span> <span class="k">JOIN</span> <span class="o">`</span><span class="n">wp_term_taxonomy</span><span class="o">`</span> <span class="n">tax</span> <span class="k">ON</span> <span class="n">r</span><span class="p">.</span><span class="o">`</span><span class="n">term_taxonomy_id</span><span class="o">`</span> <span class="o">=</span> <span class="n">tax</span><span class="p">.</span><span class="o">`</span><span class="n">term_taxonomy_id</span><span class="o">`</span>
</span><span class='line'><span class="k">INNER</span> <span class="k">JOIN</span> <span class="o">`</span><span class="n">wp_terms</span><span class="o">`</span> <span class="n">t</span> <span class="k">ON</span> <span class="n">tax</span><span class="p">.</span><span class="o">`</span><span class="n">term_id</span><span class="o">`</span> <span class="o">=</span> <span class="n">t</span><span class="p">.</span><span class="o">`</span><span class="n">term_id</span><span class="o">`</span>
</span><span class='line'><span class="k">WHERE</span> <span class="n">r</span><span class="p">.</span><span class="o">`</span><span class="n">object_id</span><span class="o">`</span> <span class="o">=</span> <span class="o">?</span>
</span><span class='line'><span class="k">AND</span> <span class="n">tax</span><span class="p">.</span><span class="o">`</span><span class="n">taxonomy</span><span class="o">`</span> <span class="o">=</span> <span class="ss">&quot;post_tag&quot;</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>


<p>Throw that query in a script that iterates over the list of files and uses <a href="https://metacpan.org/module/Tie::File">Tie::File</a> to add a line to the post and we get:</p>

<figure class='code'><figcaption><span> (word2octo-tags.pl)</span> <a href='http://michael.thegrebs.com/downloads/code/2012/word2octo-tags.pl'>download</a></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
<span class='line-number'>49</span>
</pre></td><td class='code'><pre><code class='perl'><span class='line'><span class="c1">#!/usr/bin/perl </span>
</span><span class='line'>
</span><span class='line'><span class="k">use</span> <span class="mf">5.010</span><span class="p">;</span>
</span><span class='line'><span class="k">use</span> <span class="n">strict</span><span class="p">;</span>
</span><span class='line'><span class="k">use</span> <span class="n">warnings</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">use</span> <span class="n">DBI</span><span class="p">;</span>
</span><span class='line'><span class="k">use</span> <span class="nn">Tie::</span><span class="n">File</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">my</span> <span class="nv">$path_to_posts</span> <span class="o">=</span> <span class="s">&#39;source/_posts&#39;</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">my</span> <span class="nv">$dbh</span> <span class="o">=</span> <span class="n">DBI</span><span class="o">-&gt;</span><span class="nb">connect</span><span class="p">(</span><span class="s">&#39;DBI:mysql:db_name:db_host&#39;</span><span class="p">,</span><span class="s">&#39;db_user&#39;</span><span class="p">,</span><span class="s">&#39;db_pass&#39;</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'><span class="k">my</span> <span class="nv">$get_tags</span> <span class="o">=</span> <span class="nv">$dbh</span><span class="o">-&gt;</span><span class="n">prepare</span><span class="p">(</span><span class="sx">q{</span>
</span><span class='line'><span class="sx">    SELECT GROUP_CONCAT(t.`name` SEPARATOR &quot; &quot;) FROM `wp_term_relationships` r</span>
</span><span class='line'><span class="sx">    INNER JOIN `wp_term_taxonomy` tax ON r.`term_taxonomy_id` = tax.`term_taxonomy_id`</span>
</span><span class='line'><span class="sx">    INNER JOIN `wp_terms` t ON tax.`term_id` = t.`term_id`</span>
</span><span class='line'><span class="sx">    WHERE r.`object_id` = ?</span>
</span><span class='line'><span class="sx">    AND tax.`taxonomy` = &quot;post_tag&quot;;</span>
</span><span class='line'><span class="sx">    }</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>
</span><span class='line'><span class="k">for</span> <span class="k">my</span> <span class="nv">$file</span> <span class="p">(</span><span class="nb">glob</span> <span class="s">&quot;$path_to_posts/*.markdown&quot;</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>    <span class="n">say</span> <span class="nv">$file</span><span class="p">;</span>
</span><span class='line'>    <span class="n">add_tags_to_file</span><span class="p">(</span><span class="nv">$file</span><span class="p">);</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="k">sub </span><span class="nf">add_tags_to_file</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$filename</span> <span class="o">=</span> <span class="nb">shift</span><span class="p">;</span>
</span><span class='line'>    <span class="nb">tie</span> <span class="k">my</span> <span class="nv">@file</span><span class="p">,</span> <span class="s">&#39;Tie::File&#39;</span><span class="p">,</span> <span class="nv">$filename</span> <span class="ow">or</span> <span class="nb">die</span> <span class="s">&quot;No tie: $!&quot;</span><span class="p">;</span>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$tags</span><span class="p">;</span>
</span><span class='line'>    <span class="k">while</span> <span class="p">(</span><span class="k">my</span> <span class="p">(</span><span class="nv">$rec</span><span class="p">,</span> <span class="nv">$data</span><span class="p">)</span> <span class="o">=</span> <span class="nb">each</span> <span class="nv">@file</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>        <span class="k">if</span> <span class="p">(</span><span class="nv">$data</span> <span class="o">=~</span> <span class="sr">m/^wordpress_id: (\d+)$/</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>            <span class="nv">$tags</span> <span class="o">=</span> <span class="n">get_tag</span><span class="p">(</span><span class="nv">$1</span><span class="p">);</span>
</span><span class='line'>        <span class="p">}</span>
</span><span class='line'>        <span class="k">if</span><span class="p">(</span> <span class="nv">$data</span> <span class="o">=~</span><span class="sr"> /^date:/</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>            <span class="nb">splice</span> <span class="nv">@file</span><span class="p">,</span> <span class="nv">$rec</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">$tags</span> <span class="k">if</span> <span class="nv">$tags</span><span class="p">;</span>
</span><span class='line'>            <span class="k">return</span><span class="p">;</span>
</span><span class='line'>        <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="k">sub </span><span class="nf">get_tag</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">my</span> <span class="nv">$post</span> <span class="o">=</span> <span class="nb">shift</span><span class="p">;</span>
</span><span class='line'>    <span class="nv">$get_tags</span><span class="o">-&gt;</span><span class="n">execute</span><span class="p">(</span><span class="nv">$post</span><span class="p">);</span>
</span><span class='line'>    <span class="k">my</span> <span class="p">(</span><span class="nv">$tags</span><span class="p">)</span> <span class="o">=</span> <span class="nv">$get_tags</span><span class="o">-&gt;</span><span class="n">fetchrow_array</span><span class="p">();</span>
</span><span class='line'>    <span class="k">return</span> <span class="s">&quot;tags: &quot;</span> <span class="o">.</span> <span class="nv">$tags</span> <span class="k">if</span> <span class="nv">$tags</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Devops w/ Perl @ Linode PPW Talk Slides]]></title>
    <link href="http://michael.thegrebs.com/2011/10/27/devops-w-perl-linode-ppw-talk-slides/"/>
    <updated>2011-10-27T14:46:31-04:00</updated>
    <id>http://michael.thegrebs.com/2011/10/27/devops-w-perl-linode-ppw-talk-slides</id>
    <content type="html"><![CDATA[<p>Earlier this month I gave a talk about <a href="http://www.linode.com">Linode&#8217;s</a> use of <a href="http://www.perl.org/">Perl</a> for <a href="http://en.wikipedia.org/wiki/DevOps">devopsy</a> things at the<a href="http://pghpw.org/ppw2011/"> Pittsburgh Perl Workshop</a>.  Finally getting around to posting the slides online.  I wanted to add some details so more of the slides made since on their own but haven&#8217;t gotten around to it yet.</p>

<p><a href='http://michael.thegrebs.com/assets/2011/Linode-DevOps-w-Perl.pdf'>DevOps w/ Perl @ Linode.pdf</a> (2.1MB)</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Local Growl Notifications from Remote Irssi]]></title>
    <link href="http://michael.thegrebs.com/2011/06/12/local-growl-notifications-from-remote-irssi/"/>
    <updated>2011-06-12T00:50:05-04:00</updated>
    <id>http://michael.thegrebs.com/2011/06/12/local-growl-notifications-from-remote-irssi</id>
    <content type="html"><![CDATA[<p><strong>What I&#8217;ve tried, What I want</strong></p>

<p>Skip to the next section if you just care about the end result.  In the past, I&#8217;ve had my remote <a href="http://irssi.org/">Irssi</a> client send UDP <a href="http://growl.info/">Growl</a> packets to my static home IP that were then forwarded to the broadcast address on the local network.  This worked great and allowed me to get Growl notifications on which ever computer I happened to be sitting at.  These days, I&#8217;m always on my laptop, even when sitting at another computer (<a href="http://www.abyssoft.com/software/teleport/">Teleport</a> for the mega win).</p>

<p>I wanted a solution that would allow me to receive Growl notifications without having to forward any ports and no matter what the public IP for my laptop may be.  I use <a href="http://beta.metacpan.org/module/App::PersistentSSH">App::PersistentSSH</a> to maintain a persistent SSH control master connection to my <a href="http://www.linode.com/">Linode</a> so the ideal solution uses a reverse tunnel over this connection to get the notifications too my laptop.</p>

<p><strong>My Current Solution</strong></p>

<ul>
<li>Added <code>--ssh_opts -R 127.0.0.1:22992:127.0.0.1:22</code> to my <a href="http://beta.metacpan.org/module/App::PersistentSSH">App::PersistentSSH</a> command line.  This connects localhost:22992 on my Linode to port 22 on my laptop.</li>
<li><a href="https://github.com/mikegrb/irssi-scripts/blob/master/local-growl.pl">local-growl.pl</a> &#8211; an Irssi script that uses growlnotify to send growl notifications</li>
<li><a href="https://github.com/mikegrb/irssi-scripts/blob/master/growlnotify.pl">growlnotify.pl</a> &#8211; an ssh proxy for growlnotify, passes it&#8217;s arguments to growlnotify on a remote system via ssh</li>
</ul>


<p>Simple push growl notifications from my <a href="http://www.linode.com">Linode</a> -> my MacBook Air whenever it is online.  The scripts and an irssi.png to use in the notifications are available on <a href="https://github.com/mikegrb/irssi-scripts">GitHub</a>.</p>

<p>Configuration for local-growl.pl is via Irssi&#8217;s in built settings, type <code>/set growl</code> to see a list of possibilites:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>[local-growl]
</span><span class='line'>growl_enabled = ON
</span><span class='line'>growl_growlnotifypath = /home/michael/bin/growlnotify
</span><span class='line'>growl_image_path = /Users/mgreb/Documents/irssi.png
</span><span class='line'>growl_show_hilights = ON
</span><span class='line'>growl_show_private_messages = ON
</span><span class='line'>growl_sticky = OFF</span></code></pre></td></tr></table></div></figure>


<p>Configuration for growlnotify.pl is via a set of config variables near the top:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='perl'><span class='line'><span class="k">my</span> <span class="nv">$ssh_host</span>    <span class="o">=</span> <span class="s">&#39;localhost&#39;</span><span class="p">;</span>
</span><span class='line'><span class="k">my</span> <span class="nv">$ssh_port</span>    <span class="o">=</span> <span class="mi">22992</span><span class="p">;</span>
</span><span class='line'><span class="k">my</span> <span class="nv">$ssh_user</span>    <span class="o">=</span> <span class="s">&#39;mgreb&#39;</span><span class="p">;</span>
</span><span class='line'><span class="k">my</span> <span class="nv">$growlnotify</span> <span class="o">=</span> <span class="s">&#39;/usr/local/bin/growlnotify&#39;</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>


<p>Hopefully you will find this useful.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Whole House Energy Monitoring]]></title>
    <link href="http://michael.thegrebs.com/2011/02/27/whole-house-energy-monitoring/"/>
    <updated>2011-02-27T19:18:20-05:00</updated>
    <id>http://michael.thegrebs.com/2011/02/27/whole-house-energy-monitoring</id>
    <content type="html"><![CDATA[<p>I placed an order for a <a href="http://www.theenergydetective.com/ted-5000/features">TED 5000</a> on February
10th. The <em>TED 5000</em> is a whole house energy monitor &#8211; a kill-a-watt for the whole house.  I&#8217;ve spent a lot
of time reading about the products available in this space.  I&#8217;ve looked at about 10 products for whole house
energy monitoring and three jump to the top.  The <a href="http://www.wattvision.com/">wattvision</a>, <a
href="http://www.powerhousedynamics.com/content/solutions">PowerHouse Dynamics&#8217;s eMonitor</a>, and the <a
href="http://www.theenergydetective.com/ted-5000/features">TED 5000</a>.</p>

<p><a href="http://michael.thegrebs.com/assets/2011/wattvision-analog-sensor-beta.jpg"><img
class="alignright" title="wattvision-analog-sensor-beta"
src="http://michael.thegrebs.com/assets/2011/wattvision-analog-sensor-beta-300x168.jpg" alt=""
width="300" height="168" /></a></p>

<!-- more -->


<p>The <a href="http://www.wattvision.com/">wattvision</a> (~$250) most closely
resembles the TED in terms of price and features.  The wattvision uses an optical sensor that counts the rotation
of the disk in the utility meter.  This sensor is connected to the device, which is powered by an AC adapter and
sends the data to wattvision&#8217;s servers via your home wifi network.  This is the easiest to install, but would
require running the sensor cable from the outside to inside. Additionally, all data is sent to wattvision&#8217;s
servers.  I&#8217;d also need to subscribe to wattvision&#8217;s <a href="http://www.wattvision.com/info/pricing">$8.99/month
service</a> for the other features I want (like API access.)</p>

<p><img class="alignright" title="powerhouse dynamics eMonitor" src="http://michael.thegrebs.com/assets/2011/Picture29-300x276.png" alt="" width="300" height="276" /></p>

<p>The <a href="http://www.powerhousedynamics.com/content/solutions">eMonitor</a> (starting around $688 for 12 circuits) is something I just recently discovered.  Really, this is my ideal solution: for <a href="http://www.smarthome.com/90428/PowerHouse-Dynamics-eMonitor-44-Intelligent-Residential-Power-Usage-Monitor/p.aspx">$1,277</a>, you get the necessary equipment for monitoring the power feed plus 44 individual breakers.  This gives a much better view of where your power consumption is going.  Per-circuit monitoring also enables nifty alerts &#8211; an SMS for power draw in the kids room after school starts on a week day, or if the compressor on the fridge is running longer than normal (time to clean the coils, etc.) I just can&#8217;t justify the expense at $1,277.  The price is certainly reasonable for what you are getting, but there is no way the wife would approve the purchase :/</p>

<p><img class="alignright size-full wp-image-285" title="ted-5000-g" src="http://michael.thegrebs.com/assets/2011/ted-5000-g.png" alt="" width="265" height="265" /></p>

<p><a href="http://www.theenergydetective.com/ted-5000/features">The Energy Detective</a> (TED, ~$200) from Energy Inc provides full house consumption monitoring like the wattvision.  Unlike the wattvision, the data is stored and served from a gateway device on your home network.  Two current transformers go around the two lines for the incoming split phase feed.  These are connected to a box, which is installed next-to-or-inside the breaker panel. The breaker panel is powered and communicates via a connection to a breaker on each phase.  The gateway is installed elsewhere in the house and plugs into an outlet for power and communication with the current sensor, and via Ethernet to serve its precious data up.</p>

<p>So, February 10th I finally got approval from the wife to order the TED and purchased the <a href="http://www.theenergydetective.com/ted5000-g">TED 5000-G</a> with overnight shipping. It arrived as expected on the 11th and I was eager to install it.  A coworker (also interested in the TED,) came over for dinner and to help out with the installation.  I was too excited to wait for his arrival and finished the install before he got there ;-).</p>

<p>It&#8217;s now February 27th and I still don&#8217;t have a working TED system.  The gateway I was originally shipped has a defective Ethernet port. It&#8217;s already been to Energy Inc and back and is <span style="text-decoration: underline;">still</span> defective.  They finally agreed to ship me a replacement gateway on the 25th but sent it with 2nd day shipping, which has the same transit time as ground (just more expensive.) The new unit should arrive March 1st.</p>

<p><a href="http://michael.thegrebs.com/assets/2011/TED5000-display.png"><img src="http://michael.thegrebs.com/assets/2011/TED5000-display-e1298852839843-133x150.png" alt="" title="Optional TED Display" width="133" height="150" class="size-thumbnail wp-image-318" /></a></p>

<p>I&#8217;m quite eager to get things up and running, and anticipate no problems once I have a working gateway. The most common issue people run into is excessive noise or attenuation of the <a href="http://en.wikipedia.org/wiki/Power_line_communication">power line communications</a> (PLC) signal between the sensor and gateway. The forums seem to be full of people with lots of grief around this issue. The gateway does contain a <a href="http://en.wikipedia.org/wiki/Zigbee">ZigBee</a> transceiver but that is for communication with the <a href="http://www.theenergydetective.com/additonal-ted-5000-display">optional wireless display</a>. Some have questioned switching from PLC to <a href="http://en.wikipedia.org/wiki/Zigbee">ZigBee</a> for the current data but a device inside the metal breaker box would have a hard time getting any sort of RF signal out, and PLC seems the most logical solution (even with it&#8217;s inherent issues.)  Of course, this is easy for me to say since I don&#8217;t anticipate having any issue with PLC. I can see a clear ~3-4Vpk signal on the zero crossing of the A/C at the outlet I plan to install the gateway:</p>

<p><img src="http://michael.thegrebs.com/assets/2011/plc_w_ac.png" alt="AC with TED MCU transmissions" width="320" height="234" /></p>

<p>I have another blog post in the works documenting my seemingly unending issues with the other half of the TED solution: the support staff and engineers backing the product. To be fair, the support staff is 1:2 &#8211; the second guy I spoke to there was great, but I&#8217;m pretty sure their engineers shouldn&#8217;t be allowed to know customers even exist, let alone talk to them on the phone. But, this is a story for my next blog post.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Bacon Salad & Zinik Owes Me]]></title>
    <link href="http://michael.thegrebs.com/2010/10/29/bacon-salad-zinik-owes-me/"/>
    <updated>2010-10-29T14:04:12-04:00</updated>
    <id>http://michael.thegrebs.com/2010/10/29/bacon-salad-zinik-owes-me</id>
    <content type="html"><![CDATA[<p>First off, Zinik owes me bacon flavored donuts, the Internet says it, it must be true.</p>

<p>I composed my first recipe the other night and figured I&#8217;d share it with you in the hopes that your doctor might hate me as much as mine does.</p>

<h2>Bacon Salad</h2>

<h3>Ingredients</h3>

<ul>
<li>1lb Pancetta</li>
<li>1lb Virginia Bacon</li>
<li>1lb Peppered Bacon</li>
<li>1lb Canadian Bacon</li>
<li>1lb Apple-Wood Smoked Bacon</li>
<li>1lb Irish Bacon</li>
<li>1lb Slab Bacon</li>
<li>2lb Hog Jowl</li>
<li>1   Bottle reduced fat Bacon Ranch Salad Dressing</li>
</ul>


<h3>Directions</h3>

<ol>
<li>Fry each, crispy.</li>
<li>Cut into 1x2 inch rectangles.</li>
<li>Toss in bowl with salad dressing.</li>
</ol>


<p>Makes 2, snack sized, servings.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Task Management with Hiveminder and Perl]]></title>
    <link href="http://michael.thegrebs.com/2010/03/13/task-management-with-hiveminder-and-perl/"/>
    <updated>2010-03-13T18:08:25-05:00</updated>
    <id>http://michael.thegrebs.com/2010/03/13/task-management-with-hiveminder-and-perl</id>
    <content type="html"><![CDATA[<p>This is how I manage my tasks with <a href="http://hiveminder.com/">Hiveminder</a> on a weekly basis and the Perl script that helps me do it.  I don&#8217;t really expect the Perl script to be useful to anyone as-is but portions of it may be useful to others, as well as the general work flow, so I&#8217;ve decided to share them.</p>




<p>At <a href="http://www.linode.com/">Linode</a> we have a wiki page where we list 5 or more tasks we wish to accomplish during the week.  There is a heading for each employee and below the heading we place our tasks.   Throughout the week we can add additional tasks or mark existing ones as done.</p>




<p>I&#8217;ve used <a href="http://hiveminder.com/">Hiveminder</a> for some time.  When we started the weekly task lists at <a href="http://www.linode.com/">Linode</a> I found that taking a few minutes to figure out which tasks I wish to complete in the coming week works quite well for me.  I started marking these tasks with the &#8216;week&#8217; tag in <a href="http://hiveminder.com/">Hiveminder</a>.  I quickly ended up writing a perl script, <a href="http://thegrebs.com/~michael/tasks/week.txt">week.pl</a>, to help me manage hem.</p>




<!-- more -->




<h3>My Weekly Workflow</h3>




<p>First thing Monday morning I run:</p>


<pre><code>$ week.pl report
</code></pre>

<p>This prints a report with two sections.  The first section lists tasks that currently have the &#8216;week&#8217; tag with a line through the task ID if it is completed.  This gives me a nice summary of what I planned on accomplishing the previous week and how I did.  The second section lists all of my tasks currently visible in <a href="http://hiveminder.com/">Hiveminder</a>.  I hide tasks that I know I&#8217;m not going to work on in the next few weeks so this list is usually no more than 20 or 30 items.</p>


<p><img src="http://thegrebs.com/~michael/tasks/report.png" height="260" width="334" alt="Sample report Image"/></p>

<p>I take this report into the Monday morning meeting with me.  During the meeting, I&#8217;ll glance over this list and select items for the upcoming week.  I also use this page to take notes on during the meeting, writing down any new tasks that come up in the meeting.</p>




<p>After the meeting, I add any new tasks generated in the meeting that I won&#8217;t be working on this week to <a href="http://hiveminder.com/">Hiveminder</a>.</p>


<pre><code>$ todo.pl braindump
</code></pre>

<p>`todo.pl` comes from <a href="http://search.cpan.org/~alexmv/App-Todo-0.97/bin/todo.pl">App::Todo</a>, a command line <a href="http://hiveminder.com/">Hiveminder</a> interface.  The braindump command launches $EDITOR where I add new tasks, one per line.  The <a href="http://hiveminder.com/help/reference/tasklists/braindump.html">braindump syntax</a> allows for specifying tags, setting priorities, and other things as well.</p>




<p>Next, I prepare the task list for the upcoming week:</p>


<pre><code>$ week.pl edit
Carry over the following tasks?
bring about world peace (y or n) [default y] y
write some awesome pre
do some other cool stuff
create practical cold fusion (y or n) [default y] n
return library book
</code></pre>

<p>The `edit` command iterates over each task tagged with &#8216;week&#8217; if  the task is not marked completed. It prompts whether or not I wish to carry the task over to this week (leave the tag). Any tasks marked completed have the tag removed automatically.</p>


<pre><code>$ week.pl add
Created:
        #YRVK write an awesome report for Tom [week dev]
        #YRVL test some new stuff for deployment [week admin]
</code></pre>

<p>The `add</tt` command works the same as todo.pl's braindump command except the 'week' tag is automatically applied to the newly created tasks.  The full braindump syntax is available for specifying other properties of the tasks.</p>


<pre><code>$ week.pl update https://path.to.trac/wiki/Tasks/2010-03-15
Sup dawg, I heard you like tasks so I did ur shit for you
</code></pre>

<p>The `update` command grabs my tasks tagged with &#8216;week&#8217; and formats them one per line started with &#8217; * &#8216;, a wiki bullet list.  It grabs the current wiki page, finds my heading, substitutes the formatted task list under the heading, and submits the change.  It also stores the path given in the YAML config file.</p>


<pre><code>$week.pl go
</code></pre>

<p>This opens the stored URL for this week&#8217;s tasks wiki page in my default browser, allowing me to confirm week.pl did what it&#8217;s supposed to.</p>




<p>Later in the week once I&#8217;ve done something:</p>


<pre><code>$ week.pl done tom
#YH7T bring about world peace [dev week]
#YRVL test some new stuff for deployment [week admin]
[DONE] #YRVK write an awesome report for Tom [week dev]
</code></pre>

<p>This retrieves the task(s) tagged &#8216;week&#8217; that are not marked completed containing the given string.  If there was only one match, the script marks it as done and then outputs the current state of tasks tagged &#8216;week&#8217;.</p>


<pre><code>$ week.pl update
Sup dawg, I heard you like tasks so I did ur shit for you
</code></pre>

<p>Same as `update` before, except when no URL is given, the URL is read from the configuration file.  This way I only need to worry about the URL once per week, the first time I update for the week.</p>




<h3>Conclusion</h3>




<p>So there you have it.  If you are also using <a href="http://hiveminder.com/">Hiveminder</a>, maybe aspects of my work flow will make sense for you and pieces of the Perl script may be useful.  If you aren&#8217;t using <a href="http://hiveminder.com/">Hiveminder</a>, maybe you will be inspired to check it out.  I use michael@thegrebs.com on <a href="http://hiveminder.com/">Hiveminder</a> in case you feel the need to assign me a task or wish to gift me another year of Hiveminder Pro ;)</p>


<p><a href="http://thegrebs.com/~michael/tasks/week.txt">week.pl</a></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Comic Genius]]></title>
    <link href="http://michael.thegrebs.com/2009/09/29/comic-genius/"/>
    <updated>2009-09-29T19:26:56-04:00</updated>
    <id>http://michael.thegrebs.com/2009/09/29/comic-genius</id>
    <content type="html"><![CDATA[<p>This guy is a comic genius!  Sheer hilarity.</p>

<object width="425" height="344"><param name="movie" value="http://www.youtube-nocookie.com/v/kCvkatCGNFY&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/kCvkatCGNFY&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[WebService::MobileMe uploaded to the CPAN]]></title>
    <link href="http://michael.thegrebs.com/2009/07/26/webservicemobileme-uploaded-to-the-cpan/"/>
    <updated>2009-07-26T18:06:23-04:00</updated>
    <id>http://michael.thegrebs.com/2009/07/26/webservicemobileme-uploaded-to-the-cpan</id>
    <content type="html"><![CDATA[<p>Just a quick post to announce a new perl module I uploaded to the CPAN the other day.  It&#8217;s still to be considered alpha quality as it is lacking error checking and other such necessary stuffs but is working for me.</p>

<p>Usage looks like:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='perl'><span class='line'><span class="k">use</span> <span class="nn">WebService::</span><span class="n">MobileMe</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">my</span> <span class="nv">$mme</span> <span class="o">=</span> <span class="nn">WebService::</span><span class="n">MobileMe</span><span class="o">-&gt;</span><span class="k">new</span><span class="p">(</span>
</span><span class='line'>    <span class="n">username</span> <span class="o">=&gt;</span> <span class="s">&#39;yaakov&#39;</span><span class="p">,</span> <span class="n">password</span> <span class="o">=&gt;</span> <span class="s">&#39;HUGELOVE&#39;</span> <span class="p">);</span>
</span><span class='line'><span class="k">my</span> <span class="nv">$location</span> <span class="o">=</span> <span class="nv">$mme</span><span class="o">-&gt;</span><span class="n">locate</span><span class="p">;</span>
</span><span class='line'><span class="k">print</span> <span class="o">&lt;</span> <span class="o">&lt;</span><span class="s">&quot;EOT&quot;</span><span class="p">;</span>
</span><span class='line'>    <span class="n">As</span> <span class="n">of</span> <span class="nv">$location</span><span class="o">-&gt;</span><span class="p">{</span><span class="n">date</span><span class="p">},</span> <span class="nv">$location</span><span class="o">-&gt;</span><span class="p">{</span><span class="nb">time</span><span class="p">},</span> <span class="n">Yaakov</span> <span class="n">was</span> <span class="n">at</span>
</span><span class='line'>    <span class="nv">$location</span><span class="o">-&gt;</span><span class="p">{</span><span class="n">latitude</span><span class="p">},</span> <span class="nv">$location</span><span class="o">-&gt;</span><span class="p">{</span><span class="n">longitude</span><span class="p">}</span> <span class="p">(</span><span class="n">plus</span> <span class="ow">or</span> <span class="n">minus</span>
</span><span class='line'>    <span class="nv">$location</span><span class="o">-&gt;</span><span class="p">{</span><span class="n">accuracy</span><span class="p">}</span> <span class="n">meters</span><span class="p">)</span><span class="o">.</span>
</span><span class='line'><span class="n">EOT</span>
</span><span class='line'><span class="nv">$mme</span><span class="o">-&gt;</span><span class="n">sendMessage</span><span class="p">(</span> <span class="n">message</span> <span class="o">=&gt;</span> <span class="s">&#39;Hi Yaakov!&#39;</span><span class="p">,</span> <span class="nb">alarm</span> <span class="o">=&gt;</span> <span class="mi">1</span> <span class="p">);</span>
</span></code></pre></td></tr></table></div></figure>


<p>The online documentation is available via <a href="http://search.cpan.org/~mikegrb/WebService-MobileMe/lib/WebService/MobileMe.pm">search.cpan.org</a>.</p>

<ul>
<li>Git Web: <a href="http://git.thegrebs.com/?p=WebService-MobileMe">http://git.thegrebs.com/?p=WebService-MobileMe</a></li>
<li>Git Clone: http://git.thegrebs.com/git/WebService-MobileMe</li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[YAPC|10]]></title>
    <link href="http://michael.thegrebs.com/2009/06/01/yapc10/"/>
    <updated>2009-06-01T12:53:44-04:00</updated>
    <id>http://michael.thegrebs.com/2009/06/01/yapc10</id>
    <content type="html"><![CDATA[<p>I will be at <a href="http://yapc10.org/yn2009/">YAPC|10</a> in Pittsburgh the end of June.  Here&#8217;s a schedule of the talks I plan to attend.  There are a few holes not because the talks at those time suck but because they rock so hard I can&#8217;t decide which I want to attend.</p>

<p>Old Google Calendar embed removed.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Playing a Tone Through an Arduino Connected Piezo]]></title>
    <link href="http://michael.thegrebs.com/2009/03/23/playing-a-tone-through-an-arduino-connected-piezo/"/>
    <updated>2009-03-23T21:27:52-04:00</updated>
    <id>http://michael.thegrebs.com/2009/03/23/playing-a-tone-through-an-arduino-connected-piezo</id>
    <content type="html"><![CDATA[<p>I&#8217;m working on a top secret project, all I&#8217;ll say is it involves the Arduino, Twitter, and the refrigerator, and needed to play a tone through a piezo connected to the Arduino.  I looked around and the closest I could find was <a href="http://www.arduino.cc/en/Tutorial/PlayMelody">a tutorial  that included code to play a melody</a>.</p>

<p>This wasn&#8217;t quite what I wanted and the playTone function expects the notes and timing to be in global variables which makes the baby jesus cry.  The premise was simple though.  Take the period and divide by two then bring the output high then low for this amount of time, repeat to make up the desired duration.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
</pre></td><td class='code'><pre><code class='c'><span class='line'><span class="kt">int</span> <span class="n">pinSpeaker</span> <span class="o">=</span> <span class="mi">10</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="kt">void</span> <span class="nf">setup</span> <span class="p">()</span> <span class="p">{</span>
</span><span class='line'>    <span class="n">pinMode</span><span class="p">(</span><span class="n">pinSpeaker</span><span class="p">,</span> <span class="n">OUTPUT</span><span class="p">);</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="kt">void</span> <span class="nf">loop</span> <span class="p">()</span> <span class="p">{</span>
</span><span class='line'>    <span class="n">playTone</span><span class="p">(</span><span class="mi">750</span><span class="p">,</span> <span class="mi">500</span><span class="p">);</span>
</span><span class='line'>    <span class="n">delay</span><span class="p">(</span><span class="mi">750</span><span class="p">);</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="c1">// duration in mSecs, frequency in hertz</span>
</span><span class='line'><span class="kt">void</span> <span class="nf">playTone</span><span class="p">(</span><span class="kt">long</span> <span class="n">duration</span><span class="p">,</span> <span class="kt">int</span> <span class="n">freq</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>    <span class="n">duration</span> <span class="o">*=</span> <span class="mi">1000</span><span class="p">;</span>
</span><span class='line'>    <span class="kt">int</span> <span class="n">period</span> <span class="o">=</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">/</span> <span class="n">freq</span><span class="p">)</span> <span class="o">*</span> <span class="mi">1000000</span><span class="p">;</span>
</span><span class='line'>    <span class="kt">long</span> <span class="n">elapsed_time</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
</span><span class='line'>    <span class="k">while</span> <span class="p">(</span><span class="n">elapsed_time</span> <span class="o">&lt;</span> <span class="n">duration</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>        <span class="n">digitalWrite</span><span class="p">(</span><span class="n">pinSpeaker</span><span class="p">,</span><span class="n">HIGH</span><span class="p">);</span>
</span><span class='line'>        <span class="n">delayMicroseconds</span><span class="p">(</span><span class="n">period</span> <span class="o">/</span> <span class="mi">2</span><span class="p">);</span>
</span><span class='line'>        <span class="n">digitalWrite</span><span class="p">(</span><span class="n">pinSpeaker</span><span class="p">,</span> <span class="n">LOW</span><span class="p">);</span>
</span><span class='line'>        <span class="n">delayMicroseconds</span><span class="p">(</span><span class="n">period</span> <span class="o">/</span> <span class="mi">2</span><span class="p">);</span>
</span><span class='line'>        <span class="n">elapsed_time</span> <span class="o">+=</span> <span class="p">(</span><span class="n">period</span><span class="p">);</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>This simple sketch plays a 500Hz tone for 750 mSec, pauses 750 mSec and repeats.  To use it in your sketch simply define <code>pinSpeaker</code> and set it for output, copy <code>playTone</code> to your sketch and call it with the duration in milliseconds and the frequency in hertz.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[I am so totally a nerd]]></title>
    <link href="http://michael.thegrebs.com/2009/03/03/i-am-so-totally-a-nerd/"/>
    <updated>2009-03-03T20:39:03-05:00</updated>
    <id>http://michael.thegrebs.com/2009/03/03/i-am-so-totally-a-nerd</id>
    <content type="html"><![CDATA[<p>Somebody came into the IRC support channel for work and their nick was &#8216;turtle&#8217;.  I made a logo joke and a co-worker corrected my short LOGO triangle.  This prompted me to waste 20 minutes in a LOGO interpreter.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>RT 30
</span><span class='line'>REPEAT 3 [REPEAT 3 [FD 100 RT 120] RT 120]
</span><span class='line'>PENUP
</span><span class='line'>FD 100
</span><span class='line'>PENDOWN
</span><span class='line'>RT 90
</span><span class='line'>REPEAT 360 [FD 1.75 RT 1]</span></code></pre></td></tr></table></div></figure>


<p>The output:</p>

<p><img src="http://michael.thegrebs.com/assets/2009/logo.png" alt="logo" title="logo" width="282" height="251"></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[pitz prepares to rock my socks]]></title>
    <link href="http://michael.thegrebs.com/2009/02/22/pitz-prepares-to-rock-my-socks/"/>
    <updated>2009-02-22T23:16:57-05:00</updated>
    <id>http://michael.thegrebs.com/2009/02/22/pitz-prepares-to-rock-my-socks</id>
    <content type="html"><![CDATA[<p><a href="http://blog.tplus1.com/">Matt Wilson</a> must be spying on my dialogs in sekrit IRC channels.  After setting up <a href="http://www.beckingham.net/task.html">Task</a> this evening I mentioned there being several project ticketing systems, like <a href="http://ditz.rubyforge.org/">Ditz</a>, that store data in the RCS.  I was lamenting the fact that there wasn&#8217;t any of these systems written in anything other than ruby that I was aware of.</p>


<p>Reading my RSS feeds before bed, I found <a href='http://blog.tplus1.com/index.php/2009/02/22/my-new-ticket-tracking-system-is-now-vaporware/'>&#8220;My new ticket tracking system is now vaporware&#8221;</a> from <a href="http://blog.tplus1.com/">Matt Wilson&#8217;s blog</a> talking about <a href="http://pitz.tplus1.com/">Pitz</a>, his soon to exist Python implementation of <a href="http://ditz.rubyforge.org/">Ditz</a>.</p>


<p>Please take a few moments to read over the feature set and example commands on the <a href="http://pitz.tplus1.com/">Pitz</a> site and let Matt know about any ideas/suggestions you may have.</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[~/.bashrc Perl Module Version Tip]]></title>
    <link href="http://michael.thegrebs.com/2009/01/09/bashrc-perl-module-version-tip/"/>
    <updated>2009-01-09T11:41:12-05:00</updated>
    <id>http://michael.thegrebs.com/2009/01/09/bashrc-perl-module-version-tip</id>
    <content type="html"><![CDATA[<p>I often need to quickly check the version of a perl module currently installed.  A while back I got tired of running:</p>

<pre><code>$ perl -MPOE::Filter -E 'say $POE::Filter::VERSION'
1.2357
</code></pre>

<p>So I added a quick function to .bashrc:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>pm-vers <span class="o">()</span> <span class="o">{</span>
</span><span class='line'>    perl -M<span class="nv">$1</span> -e <span class="s2">&quot;print \$$1::VERSION, \&quot;\n\&quot;&quot;</span>
</span><span class='line'><span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>Now I just run:</p>

<pre><code>$ pm-vers POE::Filter
1.2357
</code></pre>
]]></content>
  </entry>
  
</feed>
