<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>philihp.com &#187; How To</title>
	<atom:link href="http://www.philihp.com/blog/category/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.philihp.com/blog</link>
	<description>I do things, and then I tell the internet about them.</description>
	<lastBuildDate>Mon, 06 Feb 2012 05:40:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to Create an Empty SAS Dataset</title>
		<link>http://www.philihp.com/blog/2012/how-to-create-an-empty-sas-dataset/</link>
		<comments>http://www.philihp.com/blog/2012/how-to-create-an-empty-sas-dataset/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 07:24:50 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[data step]]></category>
		<category><![CDATA[SAS]]></category>

		<guid isPermaLink="false">http://linode.philihp.com/blog/?p=913</guid>
		<description><![CDATA[If you were to do this in SAS to create an empty SAS dataset: data mytable; run; It would actually create a dataset with one row. The data step cycles through once, hits the end (run), outputs a row, then comes back and finds it has no more rows to process so it stops. To [...]]]></description>
			<content:encoded><![CDATA[<p>If you were to do this in SAS to create an empty SAS dataset:</p>

<div class="wp_syntax"><div class="code"><pre class="sas" style="font-family:monospace;"><span style="color: #000080; font-weight: bold;">data</span> mytable;
<span style="color: #000080; font-weight: bold;">run</span>;</pre></div></div>

<p>It would actually create a dataset with one row. The data step cycles through once, hits the end (run), outputs a row, then comes back and finds it has no more rows to process so it stops. To stop this one row from being output, try this instead:</p>

<div class="wp_syntax"><div class="code"><pre class="sas" style="font-family:monospace;"><span style="color: #000080; font-weight: bold;">data</span> mytable;
  <span style="color: #0000ff;">stop</span>;
<span style="color: #000080; font-weight: bold;">run</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2012/how-to-create-an-empty-sas-dataset/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DIY LED Hula Hoop</title>
		<link>http://www.philihp.com/blog/2011/diy-led-hula-hoop/</link>
		<comments>http://www.philihp.com/blog/2011/diy-led-hula-hoop/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 04:00:15 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[adafruit]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[hula hoop]]></category>
		<category><![CDATA[led]]></category>
		<category><![CDATA[lithium battery]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=754</guid>
		<description><![CDATA[UPDATE: I&#8217;ll be making a lot more of these, but I don&#8217;t want to horde the know-how of how to do it. Anyone with a soldering iron can make one, so I&#8217;m sharing what I know. Bill of materials 1 Arduino Pro Mini 328 &#8211; 5V/16MHz 3 meters of Adafruit Digitally Addressable LEDs 1 Tenergy [...]]]></description>
			<content:encoded><![CDATA[<p><b>UPDATE: I&#8217;ll be making a lot more of these, but I don&#8217;t want to horde the know-how of how to do it. Anyone with a soldering iron can make one, so I&#8217;m sharing what I know.</b></p>

<a href='http://www.philihp.com/blog/2011/diy-led-hula-hoop/375356_10100422254570369_11803542_49579939_1731537871_n/' title='Radar inside the hoop'><img width="150" height="150" src="http://www.philihp.com/blog/wp-content/uploads/2011/12/375356_10100422254570369_11803542_49579939_1731537871_n2-150x150.jpg" class="attachment-thumbnail" alt="Radar inside the hoop" title="Radar inside the hoop" /></a>
<a href='http://www.philihp.com/blog/2011/diy-led-hula-hoop/388216_10100424719859909_11803542_49595547_265897678_n/' title='Strobing RGB makes it appear white when still'><img width="150" height="150" src="http://www.philihp.com/blog/wp-content/uploads/2011/12/388216_10100424719859909_11803542_49595547_265897678_n2-150x150.jpg" class="attachment-thumbnail" alt="Strobing RGB makes it appear white when still" title="Strobing RGB makes it appear white when still" /></a>
<a href='http://www.philihp.com/blog/2011/diy-led-hula-hoop/409691_10100424719026579_11803542_49595543_211464412_n/' title='Each LED can be its own color'><img width="150" height="150" src="http://www.philihp.com/blog/wp-content/uploads/2011/12/409691_10100424719026579_11803542_49595543_211464412_n2-150x150.jpg" class="attachment-thumbnail" alt="Each LED can be its own color" title="Each LED can be its own color" /></a>
<a href='http://www.philihp.com/blog/2011/diy-led-hula-hoop/408847_10100424711791079_11803542_49595530_958466730_n/' title='Persistence-of-vision allows the hoop to display messages when moving'><img width="150" height="150" src="http://www.philihp.com/blog/wp-content/uploads/2011/12/408847_10100424711791079_11803542_49595530_958466730_n1-150x150.jpg" class="attachment-thumbnail" alt="Persistence-of-vision allows the hoop to display messages when moving" title="Persistence-of-vision allows the hoop to display messages when moving" /></a>

<h3>Bill of materials</h3>
<ul>
<li>1 <a href="http://www.amazon.com/Arduino-Pro-Mini-328-16MHz/dp/B004G53J5I/">Arduino Pro Mini 328 &#8211; 5V/16MHz</a></li>
<li>3 meters of <a href="http://www.adafruit.com/products/306">Adafruit Digitally Addressable LEDs</a></li>
<li>1 <a href="http://www.batteryjunction.com/prcimopcbfor.html">Tenergy 32003 Protection Circuit Module</a></li>
<li>4 <a href="http://www.batteriesinaflash.com/assembly-cells/li-ion/li-ion-14500-aa-cylindrical-rechargeable-battery-w-tabs-800mah">14500 900mAh Lithium batteries</a> with tabs</li>
<li>3-4 meters of <a href="http://www.mcmaster.com/#50375k55/=fjv23z">1&#8243; HDPE (High-Density Polyethylene) tubing</a></li>
<li>3 <a href="http://www.sparkfun.com/products/97">push-button switches</a></li>
<li>3 resistors (doesn&#8217;t really matter which, any will do)</li>
<li>a bunch of wire.</li>
<li>1 <a href="http://www.radioshack.com/product/index.jsp?productId=2102491">Radio Shack Size M jack receptacle</a></li>
<li>1 <a href="http://www.radioshack.com/product/index.jsp?productId=2102490">Radio Shack Size M power plug</a></a>
<li>1 <a href="http://www.amazon.com/gp/product/B004LHFU62">4.2v power source for a charger</a>
<li>Bubble wrap</li>
</ul>
<p>So I made an LED hula hoop. It has 96 LEDs, 105 different modes, and lasts about 3.5 hours at full brightness. It&#8217;s also the only hoop I&#8217;ve seen that displays a message using <a href="http://www.makershed.com/product_p/mkad1.htm">persistence of vision</a>.</p>
<h3>Batteries</h3>
<p>The batteries are wired in parallel so they basically just add up the mAh capacity. If they were wired up in series, the voltage would add instead. The hoop would work with just one, but then the mass wouldn&#8217;t be evenly distributed and the hoop balance would be a little off. And it would also go dead in half an hour. They start out sending 4.2 volts, but slowly drop until it hits 3.3 volts (the actual <a href="http://www.panasonic.com/industrial/includes/pdf/Panasonic_LiIon_CGR18650CG.pdf">discharge characteristics</a> depend on the temperature). They are the same size and shape as AA batteries, but keep in mind, AA batteries are 1.5v, and these are not.</p>
<p>The batteries are wired up behind a Tenergy 32003 to protect them from overdraining and overcharging. When in use, the hoop will actually cut off before the voltage goes too low to prevent damage to the batteries. The circuit protects from overcharging too, but so does the charger. The 32003 didn&#8217;t want any more than 4.2 volts, so finding a wall-wart charger was a little difficult. I ended up wiring a charger directly into <a href="http://www.amazon.com/gp/product/B004LHFU62">an extra charger for 18650s</a>. It only charges at 600 mA, so I&#8217;m sure there&#8217;s a more appropriate charger out there.</p>
<h3>LEDs</h3>
<p>The LEDs operate on a daisy chained controller, and come printed on a pretty flexible strip. <a href="http://www.superbrightleds.com/moreinfo/component-leds/rgb-5050-smd-led-120-degree-viewing-angle/322/">5050 RGB LEDs</a> are mounted about every 2.5 inches. The LEDs are rated at 5 volts, but will dim when given lower voltage. I was actually able to overcharge them and get them brighter, but was <a href="http://forums.adafruit.com/viewtopic.php?f=47&#038;t=24682&#038;p=127981#p127981">warned</a> this would burn the drivers if I kept at it so I stopped. My original plan was actually to run on 7.4 volts to keep them this bright.</p>
<h3>Arduino</h3>
<p>At <a href="http://www.bonnaroo.com">Bonnaroo 2010</a>, I met <a href="https://www.facebook.com/schimke">this guy</a> who had built his girlfriend a hoop, and was a huge help in this one. He pointed out that the Pro Mini can run off of anywhere from 3 volts to 5 volts. The difference is really just the crystal operating at 8 or 16 mHz (for stability concerns). So that made things a lot simpler.</p>
<p>The LED strip has two inputs for power, and two wires going to the Arduino for data and clock. The <a href="https://github.com/adafruit/LPD8806">library</a> that Adafruit provides for it lets us use any two pins on the Arduino to control it via bit-banged software SPI. However, if you happen to have pins 11 and 13 free (which we do), then you can use hardware SPI and get <a href="http://forums.adafruit.com/viewtopic.php?f=47&#038;t=25050&#038;p=129265#p129265">roughly 3-4 times the speed</a> which makes POV at high speeds (i.e. while hooping) possible. If you edit the source of the LPD8806 library, you can change the SPI clock divider to go even faster, but you&#8217;ll have to worry about interference.</p>
<p>I used pins 2, 3, and 4 for pushbutton switches. 4 can be moved around, but 2 and 3 were pretty important because I send the arduino its <a href="http://donalmorrissey.blogspot.com/2010/04/putting-arduino-diecimila-to-sleep.html">sleep mode</a> to save power. External interrupts pull it out and wake it up, but only pins 2 and 3 can do this.</p>
<p>So basically there&#8217;s an &#8220;off&#8221; button, a &#8220;mode&#8221; button, and a &#8220;color&#8221; button. The modes cycle through various modes of &#8220;Solid&#8221;, &#8220;Dragonfly&#8221;, &#8220;Strobe&#8221;, &#8220;Chasers&#8221;, &#8220;Chasers with statics&#8221;, &#8220;Rainbow&#8221;, and POV. The colors cycle through various colors, except for the chasers, where you can cycle through all the colors, and keep cycling through adding another chaser every time, up to 5. The POV mode displays the logo of <a href="http://carrotcreative.com/">Carrot Creative</a>. Space is pretty cramped on the chip, so it&#8217;s just stored as an on/off bitmask, 32 pixels high (so each column is 1 32-bit int). The first few columns are green, so I just did that bit manually.</p>
<h3>Assembly</h3>
<p>Probably the most frustrating part of this project is the assembly. It&#8217;s important for everything to be snug inside of the hoop so it doesn&#8217;t rattle, and wrapping it in bubble wrap greatly helps this, but the bubble wrap grips the sides of the tube. Taping three unraveled coat hangers together, and using them to pull the strip through helped a lot. Another thing to watch out for is that the contacts need to be insulated and wrapped in electrical tape so you don&#8217;t get shorts inside the tube which are nearly impossible to find and fix without a complete disassembly.</p>
<p><a href="https://github.com/philihp/Jubilee">Source Code &#038; EAGLE Wiring Diagrams</a></p>
<p><img src="https://github.com/philihp/Jubilee/raw/master/wiring.png" style="width:50%" /></p>
<p><iframe width="480" height="360" src="http://www.youtube.com/embed/s0otcdW-98w" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2011/diy-led-hula-hoop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internal PC Speaker Beep on Startup and Shutdown</title>
		<link>http://www.philihp.com/blog/2009/internal-pc-speaker-beep-when-done-booting/</link>
		<comments>http://www.philihp.com/blog/2009/internal-pc-speaker-beep-when-done-booting/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 10:58:10 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Beep]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=325</guid>
		<description><![CDATA[Pretty neat trick by Craig Perry at http://ubuntuforums.org/showthread.php?t=462960. The following is pretty much word-for-word reposted. Since I have an old 400mhz Pentium 2 under my desk that I use as a Tomcat development box. I also find it useful to use it as a development platform that gives immediate feedback of suboptimal code, and it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Pretty neat trick by Craig Perry at <a href="http://ubuntuforums.org/showthread.php?t=462960">http://ubuntuforums.org/showthread.php?t=462960</a>. The following is pretty much word-for-word reposted. Since I have an old 400mhz Pentium 2 under my desk that I use as a Tomcat development box. I also find it useful to use it as a development platform that gives immediate feedback of suboptimal code, and it&#8217;s always a nice surprise to find scripts and pages that take 10-20 seconds to run on it take less than a half-second on any other machine.</p>
<p>Install <a href="http://www.johnath.com/beep/"><code>beep</code></a></p>
<pre>sudo apt-get install beep</pre>
<p>Create the following at <code>/etc/init.d/beep</code></p>
<pre>#!/bin/bash
#
# beep
# Notify when the system is up, or going down
# Craig Perry, 4th Jun 2007

BEEP=/usr/bin/beep
. /lib/lsb/init-functions

case "$1" in
  start)
    log_begin_msg "Audible notification - System Now Up..."
    for i in `seq 750 50 1500`; do
      $BEEP -l 50 -f $i
    done
    log_end_msg 0
    ;;
  stop)
    log_begin_msg "Audible notification - System Going Down..."
    for i in `seq 1500 -50 750`; do
      $BEEP -l 50 -f $i
    done
    log_end_msg 0
    ;;
  *)
    log_success_msg "Usage: $0 {start|stop}"
    exit 1
    ;;
esac
exit 0</pre>
<p>Then make it executable:</p>
<pre>chmod +x /etc/init.d/beep</pre>
<p>Finally, tell the system to add hooks to run it last (99) on startup and first (01) on shutdown:</p>
<pre>sudo update-rc.d beep defaults 99 01</pre>
<p>This gives you an ascending tone when the system comes up, and a descending tone as it&#8217;s starting to shutdown (i.e. confirms you&#8217;ve pressed the power button correctly).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2009/internal-pc-speaker-beep-when-done-booting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to retrieve the ID after a MySQL Insert in Python</title>
		<link>http://www.philihp.com/blog/2009/how-to-retrieve-the-id-after-a-mysql-insert-in-python/</link>
		<comments>http://www.philihp.com/blog/2009/how-to-retrieve-the-id-after-a-mysql-insert-in-python/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 10:02:40 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQLdb]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=303</guid>
		<description><![CDATA[The MySQLdb <a href="http://mysql-python.sourceforge.net/MySQLdb.html">documentation</a> mentions conn.insert_id(), however this appears to have been deprecated, maybe? This really should be on the cursor object anyway. And behold! There <i>is</i> a <code>lastrowid</code> on it! It's just a little bit undocumented]]></description>
			<content:encoded><![CDATA[<p>When you have an <a href="http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html">auto_increment</a> field on a table, and you&#8217;re doing a batch import of new data, you often want to insert a row, then insert more rows that have a foreign key referencing the first row. For example, you want to insert a COMPANY entity, then insert a few dozen PERSON entities under that company. Assuming you have no unique and not-null fields on the COMPANY entity (if company_name were unique and not-null, then you could just issue a select immediately after inserting to get its ID), and assuming you want a thread-safe solution (you could just select for the highest ID in the table immediately after inserting, but since MySQL is by default not transaction-safe, another thread could come in and insert another company right after you insert and before your select), you simply <i>need</i> to have <code>mysql_insert_id()</code>.</p>
<p>The MySQLdb <a href="http://mysql-python.sourceforge.net/MySQLdb.html">documentation</a> mentions conn.insert_id(), however this appears to have been deprecated, maybe? This really should be on the cursor object anyway. And behold! There <i>is</i> a <code>lastrowid</code> on it! It&#8217;s just a little bit undocumented:</p>
<pre name="code" class="python:nocontrols">&gt;&gt;&gt; import MySQLdb
&gt;&gt;&gt; connection = MySQLdb.connect(<i>...</i>)
&gt;&gt;&gt; cursor = connection.cursor()
&gt;&gt;&gt; cursor.execute("INSERT INTO PERSON (name) VALUES ('Philihp')")
1L
&gt;&gt;&gt; print cursor.lastrowid
42</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2009/how-to-retrieve-the-id-after-a-mysql-insert-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to remove iGoogle</title>
		<link>http://www.philihp.com/blog/2009/how-to-remove-igoogle/</link>
		<comments>http://www.philihp.com/blog/2009/how-to-remove-igoogle/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 08:00:10 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=296</guid>
		<description><![CDATA[To remove iGoogle and revert to the classic vanilla google homepage, click &#8220;Classic Home&#8221; in the upper right corner of the screen.]]></description>
			<content:encoded><![CDATA[<p>To remove iGoogle and revert to the classic vanilla google homepage, click &#8220;Classic Home&#8221; in the upper right corner of the screen.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2009/how-to-remove-igoogle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Enable mod_userdir for Apache2 on Ubuntu 8.10</title>
		<link>http://www.philihp.com/blog/2009/enable-mod_userdir-for-apache2-on-ubuntu-810/</link>
		<comments>http://www.philihp.com/blog/2009/enable-mod_userdir-for-apache2-on-ubuntu-810/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 06:42:59 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[mod_userdir]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=281</guid>
		<description><![CDATA[To enable mod_userdir, so your server&#8217;s Apache httpd server will respond to requests like &#8220;http://www.yourserver.com/~someuser&#8221;, use the a2enmod command, then restart Apache to pickup the change: sudo a2enmod userdir sudo /etc/init.d/apache2 restart]]></description>
			<content:encoded><![CDATA[<p>To enable mod_userdir, so your server&#8217;s Apache httpd server will respond to requests like &#8220;http://www.yourserver.com/~someuser&#8221;, use the a2enmod command, then restart Apache to pickup the change:</p>
<p><code>sudo a2enmod userdir<br />
sudo /etc/init.d/apache2 restart</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2009/enable-mod_userdir-for-apache2-on-ubuntu-810/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing SAS 9.1.3 on Ubuntu Linux 8.10</title>
		<link>http://www.philihp.com/blog/2009/installing-sas-913-on-ubuntu-linux-810/</link>
		<comments>http://www.philihp.com/blog/2009/installing-sas-913-on-ubuntu-linux-810/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 00:42:43 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SAS]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/2009/01/installing-sas-913-on-ubuntu-linux-810/</guid>
		<description><![CDATA[It works. Just follow the instructions.]]></description>
			<content:encoded><![CDATA[<p>It works. Just follow the instructions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2009/installing-sas-913-on-ubuntu-linux-810/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

