<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>mike.sh</title>
 <link href="http://mike.sh/feed" rel="self"/>
 <link href="http://mike.sh/"/>
 <updated>2010-09-13T03:17:55-06:00</updated>
 <id>http://mike.sh/</id>
 <author>
   <name>Mike Colagrosso</name>
   <email>mike@colagrosso.net</email>
 </author>

 
 <entry>
   <title>The Long Road of the Advanced Beginner</title>
   <link href="http://mike.sh/2010/03/the-long-path-of-advanced-beginner"/>
   <updated>2010-03-20T00:00:00-06:00</updated>
   <id>http://mike.sh/2010/03/the-long-path-of-advanced-beginner</id>
   <content type="html">&lt;p&gt;This is the story of an Arduino electronics project I built. When you hear &amp;#8220;Arduino,&amp;#8221; you may think you know where this story is going, but you don&amp;#8217;t. There are no schematics, no breadboard layouts, no code snippets. This is the project that carried my electronics skills from Advanced Beginner to Competent in the &lt;a href=&quot;http://en.wikipedia.org/wiki/Dreyfus_model_of_skill_acquisition&quot;&gt;Dreyfus model of skill acquisition&lt;/a&gt; (with a nod to &lt;a href=&quot;http://www.kungfugrippe.com/post/185501475/drefus&quot;&gt;Merlin&lt;/a&gt;), and I&amp;#8217;m disappointed to say it took me two years to do so.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m not going to describe the finished project, the code for that is available on GitHub. What I&amp;#8217;m going to describe is the failed predecessor. It&amp;#8217;s far more interesting, and it consumed 80% of the last two years. Briefly, though, the final project&amp;#8217;s homepage is &lt;a href=&quot;http://lanternhook.com/&quot;&gt;LanternHook.com&lt;/a&gt;, and it&amp;#8217;s four Arduinos with WiShields and BlinkM multi-color LEDs that make a persistent socket connection to a Python Twisted service. Each lantern is available via a &lt;span class=&quot;caps&quot;&gt;URL&lt;/span&gt; and functions as a physical webhook. The code explains how it really works.&lt;/p&gt;
&lt;p&gt;Here is the auspicious beginning of my failed LanternHook predecessor. This photo was taken on January 20, 2008:&lt;/p&gt;
&lt;p style=&quot;text-align:center;&quot;&gt;&lt;a href=&quot;http://www.flickr.com/photos/mikecolagrosso/4531972291/&quot; title=&quot;Mike's new electronics hobby equipment by Mike Colagrosso, on Flickr&quot;&gt;&lt;img src=&quot;http://farm3.static.flickr.com/2601/4531972291_c54d3041d0.jpg&quot; width=&quot;500&quot; height=&quot;333&quot; alt=&quot;Mike's new electronics hobby equipment&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Why, in this supposed Arduino project, are the most recognizable components on the desk &lt;a href=&quot;http://fon.com&quot;&gt;Foneras&lt;/a&gt;? I&amp;#8217;ll tell you in a moment. First, I was lucky with this project because the idea came to me quickly and clearly. I wanted a computer that didn&amp;#8217;t look like a computer, and&amp;mdash;like the Ambient Orb&amp;mdash;I wanted something pleasing to look at that conveyed a little information. I also wanted to build four computers to live in my parents&amp;#8217;, brother&amp;#8217;s, sister&amp;#8217;s, any my houses, and have them connected in some way. Having them interconnected meant WiFi to me, and as &lt;a href=&quot;http://www.randsinrepose.com/archives/2006/12/10/malcolm_events.html&quot;&gt;Rands&lt;/a&gt; would say that small but crucial decision early on had repercussions I was not prepared for. At the time, there were no Arduino WiFi options that were cheap and easy, but I found &lt;a href=&quot;http://echodittolabs.org/blog/2007/12/making-fon-router-speak-serial-arduino&quot;&gt;this post&lt;/a&gt; describing how easy it is to connect a Fonera to an Arduino over serial. Great, I thought, and quickly created a system that worked like this:&lt;/p&gt;
&lt;p style=&quot;text-align:center;&quot;&gt;Fonera &amp;rarr; Arduino &amp;rarr; 2 BlinkMs&lt;/p&gt;
&lt;p&gt;The Fonera runs Linux, so I setup a scratchbox in a &lt;a href=&quot;/2010/02/virtual-machines-as-mitochondria/&quot;&gt;virtual machine&lt;/a&gt; (requisite self-link) to build the packages I needed. It was snappy, too. The Fonera connected to a beanstalkd server, which meant it blocked on a socket that returned right away when there was a new command (color) for the lantern. Simple. If you&amp;#8217;re an advanced beginner, I highly recommend emulating what I did up to about this point. Tie together some pieces you understand, and keep your momentum up by building a project in iterations. Demo it to people whose opinion you value. I demoed the lanterns in the summer of 2008 (with an iPhone app), and it worked great and looked great. Then why did this project take over two years instead of six months? Just when I could have written up the project and called it done, I decided to take one more design iteration. I had a good reason: The purpose of this project was to learn about electronics, but it was so simple that I hadn&amp;#8217;t learned that much.&lt;/p&gt;
&lt;p&gt;The hardware worked, but there was too much of it. The whole thing seemed too complicated. With the Arduino, it was more than a bit crowded it the top. Looked to eliminate some parts, and it seemed like a good idea to cut out the middleman, so I cut out the Arduino. This was the smartest and dumbest thing I did. It was smart because the Arduino wasn&amp;#8217;t really doing anything except as as a serial-to-I2C converter. It was dumb because I should have asked myself &lt;em&gt;why&lt;/em&gt; the Arduino wasn&amp;#8217;t doing anything. This was an advanced beginner electronics project, where Arduinos are as common as the electrons themselves. Instead, observe how I ignored the warning signs I was plowing into a 18-month run:&lt;/p&gt;
&lt;p&gt;First clue: It&amp;#8217;s possible, but by no means easy, to get I2C working on the Fonera. You use these two &lt;span class=&quot;caps&quot;&gt;GPIO&lt;/span&gt; pins next to the Ethernet connector:&lt;/p&gt;
&lt;p style=&quot;text-align:center;&quot;&gt;&lt;img src=&quot;/img/posts/002-fonera-i2c.jpg&quot; width=&quot;640&quot; height=&quot;853&quot; alt=&quot;002 Fonera I2C&quot;&gt;&lt;/p&gt;
&lt;p&gt;Don&amp;#8217;t ask me which one is for data and which one for clock, because you shouldn&amp;#8217;t be considering doing this. I love installing and configuring Linux boxes, and even I got bored with all the work required to set up I2C. Even after I got all the software working&amp;mdash;because I&amp;#8217;m a software expert&amp;mdash;it still didn&amp;#8217;t work&amp;mdash;because I&amp;#8217;m an electronics advanced beginner. I needed 4.7k pull-up resistors to on the data and clock lines. Without them, no signal. I actually knew I needed pull-ups, but I used 10k resistors. I used the only guidance my advanced beginner skill-set contained, which was, &amp;#8220;10k is usually a good resistor to add.&amp;#8221; I know this is dumb, but it&amp;#8217;s all I had, and it&amp;#8217;s comforting to advanced beginners to have rules to cling to.&lt;/p&gt;
&lt;p&gt;Second clue, and this is a big one: I started blowing BlinkMs. Meaning, the lights would stop working. I ignored the problem at first, thinking it was &lt;span class=&quot;caps&quot;&gt;ESD&lt;/span&gt;. Then I figured out it was the BlinkM&amp;#8217;s ATtiny micro that was blowing, and I ignored the problem again. Then the problem got to the point where I couldn&amp;#8217;t ignore it:&lt;/p&gt;
&lt;p style=&quot;text-align:center;&quot;&gt;&lt;img src=&quot;/img/posts/002-blinkms.jpg.png&quot; width=&quot;640&quot; height=&quot;276&quot; alt=&quot;Failed BlinkMs&quot;&gt;&lt;/p&gt;
&lt;p&gt;That&amp;#8217;s what failure looks like. 9 blown BlinkMs.&lt;/p&gt;
&lt;p&gt;I sought advice on how to protect the lines, but the advice I got was still over my advanced beginner head. I tried crazy solution with regulators. Didn&amp;#8217;t work. In hindsight, I may have been blowing the micro via the digital lines, not the power lines. I&amp;#8217;ve sense learned the digital lines have even less protection. It didn&amp;#8217;t matter, though, because I gave up. In fact, I almost gave up on the project entirely.&lt;/p&gt;
&lt;p&gt;This is the point in the story where the advanced beginner needs a miracle. Mine came in the form of the WiShield. (By the way, the WiShield in the &lt;a href=&quot;http://www.wattvision.com/&quot;&gt;Wattvision&lt;/a&gt; box. It was kinda amusing to see when I opened the case.) The WiShield solved the problem because it meant I could give up and still move forward. It&amp;#8217;s important to do both (give up and move forward) when you&amp;#8217;re learning, but before the WiShield I couldn&amp;#8217;t move forward if I gave up on the Foneras.&lt;/p&gt;
&lt;h3&gt;Still not done.&lt;/h3&gt;
&lt;p&gt;The project works so well now, and it&amp;#8217;s wired so conventionally, that it&amp;#8217;s boring. One hiccup though, is that the socket connection can get lost. I tried to add code to reinitiate connection, but it doesn&amp;#8217;t always work. My current plan is to use a watchdog to reset the Arduino. Maybe add an external 555 timer as a watchdog, like the &lt;a href=&quot;http://www.practicalarduino.com/news/id/471&quot;&gt;Practical Arduino blog describes&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The project is still not done in the big picture, either. Why does it require a Python Twisted service running on a server? It should be replaced with something more standard, but for now a socket connection from the Arduino was the best.&lt;/p&gt;
&lt;p&gt;Here&amp;#8217;s one of the finished lanterns.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://lanternhook.com&quot;&gt;&lt;img src=&quot;/img/posts/002-laternhook.png&quot; width=&quot;698&quot; height=&quot;860&quot; alt=&quot;Laternhook&quot;&gt;&lt;/a&gt;&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Virtual Machines as Mitochondria</title>
   <link href="http://mike.sh/2010/02/virtual-machines-as-mitochondria"/>
   <updated>2010-02-15T00:00:00-07:00</updated>
   <id>http://mike.sh/2010/02/virtual-machines-as-mitochondria</id>
   <content type="html">&lt;p&gt;Here&amp;#8217;s the idea: Use Linux virtual machines (VMs) hosted on Mac OS X for all types of one-off, console- or server-related tasks. That&amp;#8217;s it. Depending on your background, that may be all you need to read. If you&amp;#8217;re looking for &lt;a href=&quot;http://www.merlinmann.com/media/2009/10/22/video-makebelieve-help-old-butchers-and-figuring-out-who-you.html&quot;&gt;tips&lt;/a&gt;, you&amp;#8217;re done.&lt;/p&gt;
&lt;p style=&quot;text-align:center;&quot;&gt;&lt;img src=&quot;/img/posts/001-cell.png&quot; width=&quot;520&quot; height=&quot;445&quot; alt=&quot;The Cell. It wasn't my intent to show Linux as cancer.&quot;&gt;&lt;/p&gt;
&lt;p&gt;And this one even comes with a metaphor: Think of the VM like a mitochondrion; not necessarily the energy-producing-powerhouse, but the specialized-cell-that-evolved-to-live-in-another-cell aspect. If you lack the technical skill to implement this idea, I&amp;#8217;m sorry but you&amp;#8217;re also done. A lone article written by me in February 2010 isn&amp;#8217;t the right venue to impart this skill. If you&amp;#8217;re still here and you&amp;#8217;d like to explore how far you can take this idea, and hear a one-sided argument for it, read on.&lt;/p&gt;
&lt;h4&gt;Let Linux be Linux&lt;/h4&gt;
&lt;p&gt;This is a setup I&amp;#8217;ve been using for a long time. I tweak it when I think of ways to improve it, which happens a lot. It stems from questions like these:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;You need to run an &lt;span class=&quot;caps&quot;&gt;NFS&lt;/span&gt; server. How would you do it?&lt;/li&gt;
	&lt;li&gt;You need to cross-compile a whole stack of code. How quickly can you gather the tools?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I use Mac OS X as my everyday machine, but I&amp;#8217;m painfully aware of how easy Linux can make these two tasks, and a slew of related ones. So I let Linux play to its strengths and just run them in a VM. I&amp;#8217;m coming way late this argument:&lt;/p&gt;
&lt;p style=&quot;text-align:center;&quot;&gt;&lt;a href=&quot;http://diveintomark.org/archives/2007/11/11/installing-mysql-on-ubuntu&quot;&gt;Installing MySQL on Ubuntu (the &lt;span class=&quot;caps&quot;&gt;NSFW&lt;/span&gt; way)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;but Mark Pilgrim&amp;#8217;s characteristically good article solidified my answer to the question, &amp;#8220;How do you setup MySQL for local webapp development?&amp;#8221; and it&amp;#8217;s not, &amp;#8220;Compile it from the source and run it on your Mac.&amp;#8221; I like to &lt;code&gt;apt-get install&lt;/code&gt; as much as anyone, but I&amp;#8217;m willing to accept lock-in &lt;a href=&quot;http://diveintomark.org/archives/2007/06/02/one-year-with-linux&quot;&gt;that Pilgirm will not&lt;/a&gt;. My setup is more in line with Alex Payne&amp;#8217;s Rules for Computing Happiness:&lt;/p&gt;
&lt;p style=&quot;text-align:center;&quot;&gt;&lt;a href=&quot;http://al3x.net/2008/09/08/al3xs-rules-for-computing-happiness.html&quot;&gt;http://al3x.net/2008/09/08/al3xs-rules-for-computing-happiness.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;i.e., &amp;#8220;Do not use anything other than a Mac at home and Linux/&lt;span class=&quot;caps&quot;&gt;BSD&lt;/span&gt; on the server.&amp;#8221; (But &lt;a href=&quot;http://al3x.net/2010/02/10/thinkpad-x301.html&quot;&gt;see here&lt;/a&gt; to read how the tide is also turning for him.) The virtual machines I run all happen to be Ubuntu server, and I think of them as if I&amp;#8217;m carrying along a few extra servers with my laptop. Because I run the server versions, I ssh into them and otherwise interact with them as if they were remote servers. They just have great ping times.&lt;/p&gt;
&lt;p&gt;One parting shot at Linux: It&amp;#8217;s come a long way since I used it as my everyday, desktop operating system. For example, I never had a Linux machine with reliably-working WiFi. So while this doesn&amp;#8217;t cause current users as much grief, now it causes me and my VM no grief. The VM thinks it got its IP address from a very friendly &lt;span class=&quot;caps&quot;&gt;DHCP&lt;/span&gt; server over eth0.&lt;/p&gt;
&lt;h4&gt;Keep the Mac clean&lt;/h4&gt;
&lt;p&gt;In a nutshell, anything that&amp;#8217;s moderately server related, I put in a VM. For example, even though my Mac is capable and eager to serve files from my ~/Sites directory, I spin up an Ubuntu 8.04 machine running Apache to do that work. Yes, the same Apache project (and much of the codebase) that my Mac would have used. And that&amp;#8217;s just for Apache, which ships with the Mac. I&amp;#8217;ve stopped using Fink and MacPorts altogether, and that&amp;#8217;s because you have to be ruthless about what you keep on your Mac. If it doesn&amp;#8217;t install by dragging into the /Applications folder, there has to be a compelling reason to install it. I&amp;#8217;ve been using Mac OS X since 10.0 in 2001. One of my favorite features is the User Migration Manager. Upgrades are painless. As Kottke observed, &lt;a href=&quot;http://kottke.org/09/09/the-apple-upgrade-problem&quot;&gt;they&amp;#8217;re painless almost to a fault&lt;/a&gt;. But with upgrade after upgrade, the footprint of software I carried with me in &lt;code&gt;/sw&lt;/code&gt; (Fink) and &lt;code&gt;/opt/local&lt;/code&gt; (MacPorts) became a burden. Worse than a burden, in fact, because system upgrades would render the software incompatible.&lt;/p&gt;
&lt;p&gt;I have no loyalty to any of the VMs. Whenever I think I need a clean slate I grab the latest version of Ubuntu. I delete VMs at whim without grabbing any data from them. If something was important, it would have already been on my Mac or in the cloud. But despite my lack of loyalty, the insular nature of the VMs ensures that they will run fine no matter the host system.&lt;/p&gt;
&lt;h4&gt;Trade-offs&lt;/h4&gt;
&lt;p&gt;This system doesn&amp;#8217;t optimize for:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;&lt;strong&gt;Cost.&lt;/strong&gt; Mac OS X and VMware Fusion cost money. Using Mac OS X allows me to run other great, expensive software.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Freedom.&lt;/strong&gt; It&amp;#8217;s important to me, but I don&amp;#8217;t optimize for it.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Disk space.&lt;/strong&gt; My biggest regret about this system is that Time Machine chews up the virtual disk images. I read that CrashPlan is better in this regard, but I haven&amp;#8217;t tried it.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Performance.&lt;/strong&gt; The Ubuntu server VMs I run require 256 MB of resident memory. If that&amp;#8217;s significant, buy a new machine.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I try to optimize for:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;&lt;strong&gt;Flow&lt;/strong&gt;. Even though &amp;#8220;it&amp;#8217;s all the same machine,&amp;#8221; I find lots of situations where there&amp;#8217;s a natural division of labor between the Mac frontend and Linux backend. The ability to focus on one or the other helps, and it helps the most when the VM is a local development mirror of a remote Linux production server. Need to edit your config file? You do it in the same place on the local VM as the real webserver.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Security&lt;/strong&gt;. The fewer services I run on my Mac, the better. The VMs are generally NAT&amp;#8217;d from the rest of the network.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Google-ability of problems&lt;/strong&gt;. Forget for a moment that &lt;em&gt;google-ability&lt;/em&gt; isn&amp;#8217;t a word, and recognize a great disparity. Searching for &amp;#8220;Ubuntu &amp;lt;name of some service or command line program or error message&amp;gt;&amp;#8221; almost always leads to the right answer. There are just so many other people in the same boat. At the time of writing, the top hit for &amp;#8220;mac os x nfs server&amp;#8221; has screenshots full of pinstripes. (It&amp;#8217;s a Tiger tutorial from 2005.)&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Tools&lt;/h4&gt;
&lt;p&gt;Here are five things I&amp;#8217;ve done to make interface between my Mac and Linux VMs even better:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;SSH&lt;/span&gt; keys. I shouldn&amp;#8217;t even need to state this. If you don&amp;#8217;t have these properly working, I&amp;#8217;ve failed you in letting you read this far. You should be reading more introductory material.&lt;/li&gt;
	&lt;li&gt;Prefer Bonjour over editing /etc/hosts. Run Avahi on the Linux VM. It&amp;#8217;s sweet, and it saves you from having to note the VMs IP address.&lt;/li&gt;
	&lt;li&gt;Matching user ids. This is a pain, and somewhat ridiculous, but just suck it up and make your &lt;span class=&quot;caps&quot;&gt;UID&lt;/span&gt; in the VM the same as the one on your Mac. It will pay off when you install the&amp;#8230;&lt;/li&gt;
	&lt;li&gt;VMWare &lt;span class=&quot;caps&quot;&gt;HGFS&lt;/span&gt; module to mount the Mac&amp;#8217;s home directory. The Linux VM can read the Mac&amp;#8217;s files directly with this module. I edit webpages in Coda on my Mac, and then have Apache in the VM serve them back to me.&lt;/li&gt;
	&lt;li&gt;Expandrive to view Linux files. It&amp;#8217;s rare that I need to grab a lot of files from the VM (I&amp;#8217;ll use scp for small jobs), but when I do Expandrive handles the job well.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Specialization and trade&lt;/h4&gt;
&lt;p&gt;If you didn&amp;#8217;t like the junior-high-biology-class metaphor from the opening, I&amp;#8217;ll close with an economic one: Specialization and trade promote higher output and prosperity. Two countries can find ways to capitalize on each other&amp;#8217;s strengths, so I challenge you to do the same with these &lt;span class=&quot;caps&quot;&gt;UNIX&lt;/span&gt; offspring.&lt;/p&gt;
&lt;h4&gt;Exercises left to the reader&lt;/h4&gt;
&lt;p&gt;I&amp;#8217;ve left out details of how to replicate my setup, partly because that information has a shelf-life of about five minutes. Also, this is an idea you should take and personalize. Maybe you&amp;#8217;ll use Dropbox, rsync, sshfs, WebDAV, or git to move files around. Maybe you&amp;#8217;ll try out the latest versions of the ejabberd or Prosody &lt;span class=&quot;caps&quot;&gt;XMPP&lt;/span&gt; servers in a VM instead of littering your Mac with files. The ideas and the metaphors are more important than my details.&lt;/p&gt;</content>
 </entry>
 
 
</feed>

