giant robots smashing into other giant robots

Written by thoughtbot

jyurek

When I Enter the Office, the Imperial March Plays

A long time ago in an office far, far away… robot wars! I mean, budget surplus! We had a bit extra in the budget a while back and so we did what any responsible business owners would have done: ask the employees what they wanted us to spend it on. Here’s the list we got back:

<ul>
<li>A fully glass floor so I can watch the people below me</li>
    <li>Currency valid only on Dean Kamen’s personal island</li>
    <li>A pony</li>
    <li><span class="caps">RFID</span> door key that plays my ‘theme’ when I enter the office.</li>
    <li>10 pounds of green M&#38;Ms</li>
    <li>Portal gun from Half-life Portal so we can use the gun to create hole between tb kitchen and my kitchen &#8211; It’ll be great we can have toast.</li>
</ul>


<p>Right. Well, there was one thing on there that was actually possible (<a href="http://www.mymms.com/25colors/?sc_cid=DR_LV3">besides the M&#38;Ms</a>), and it was the <span class="caps">RFID</span> theme song system. That&#8217;s not something you buy off the shelf, and since it was a budget surplus and not a time surplus, we shelved that. Time comes for us to move into our current office and, lo and behold, there&#8217;s an <span class="caps">RFID</span> door-lock system! But, you know, no theme songs. Well, since we were still busy it took a while, but I finally contacted the <a href="http://crosspoint.nl">manufacturer of the system</a> and managed to get an <span class="caps">API</span> and documentation (since it&#8217;s not publicly available, for whatever reason&#8212;if you want to get it, email their support).</p>
<h2>Gentlemen, behold!</h2>


<p>Now, I tap my card to the reader: the door opens and my theme song plays! (Full disclosure: I lied in the title. My theme isn&#8217;t the Imperial March. It&#8217;s part of <a href="http://www.youtube.com/watch?v=BGSqvZ8QelI"><span class="caps">TMBG</span>&#8217;s Space Suit</a>. But it <em>used</em> to be the Imperial March, so I don&#8217;t feel bad putting it in the title.)</p>


<p><a href="http://github.com/jyurek/thememusic">The important part here is that the source is available on GitHub.</a></p>


<p>The original version was a bit of a spike, as it didn&#8217;t have tests. This current version is much better and has tests. We don&#8217;t feel comfortable using other people&#8217;s code if they don&#8217;t have tests; we also don&#8217;t feel right giving you code without tests.</p>


<p>It&#8217;s got a bunch of features, like reconnecting itself if you pull the cord out (theoretically) and only playing between certain hours, and, umm, working. Only playing between certain hours makes a big difference, because if you play all the time you&#8217;ll quickly get tired of it (and what&#8217;s the fun in that?). We have it set to only play between 6am and 11am, so it generally only plays when you first come in.</p>


<p>It only runs on Windows, because that&#8217;s how Crosspoint supplied the <span class="caps">API</span>. It accesses the <span class="caps">COM</span> objects via the <span class="caps">WIN32OLE</span> library, which is thankfully standard with Ruby. After a few media players I settled on Winamp 2.95 because it was the only one that actually started playing as soon as you ran the command, go figure.</p>


<p>Because not everyone at thoughtbot is in Boston, not everyone has a song yet, but here&#8217;s the current standing:</p>


<ul>
<li>Jon: Space Suit</li>
    <li>Matt: What&#8217;s My Name</li>
    <li>Chad: Audience Cheering Live Album Intro</li>
    <li>Mike: In the Air Tonight</li>
    <li>Jason: Stardust Fanfare</li>
    <li>Dan: I Don&#8217;t Feel Like Dancin&#8217;</li>
    <li>Joe: Liberty Bell March</li>
    <li>Nick: Limelight</li>
    <li>Fred: Kernkraft 400</li>
</ul>


<p>Note: If you happen to have an <span class="caps">XM3 RFID</span> door system and want to set this up, keep your music below 10 seconds or so, otherwise it gets really tedious really quickly.</p>