<?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>Stan Schwertly</title>
	<atom:link href="http://www.Schwertly.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.Schwertly.com</link>
	<description>Plants and Programming</description>
	<lastBuildDate>Sun, 29 Apr 2012 18:32:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Growing Tobacco in New Jersey #2</title>
		<link>http://www.Schwertly.com/2012/04/growing-tobacco-in-new-jersey-2/</link>
		<comments>http://www.Schwertly.com/2012/04/growing-tobacco-in-new-jersey-2/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 14:08:20 +0000</pubDate>
		<dc:creator>Stan Schwertly</dc:creator>
				<category><![CDATA[Pictures]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[cigar]]></category>
		<category><![CDATA[growing]]></category>
		<category><![CDATA[nj]]></category>
		<category><![CDATA[plants]]></category>
		<category><![CDATA[tobacco]]></category>

		<guid isPermaLink="false">http://www.Schwertly.com/?p=787</guid>
		<description><![CDATA[I grew tobacco in New Jersey again this year. These are the pictures with descriptions.]]></description>
				<content:encoded><![CDATA[<blockquote><p>Read &#8220;<a title="Growing Tobacco In New Jersey" href="http://www.Schwertly.com/2011/03/growing-tobacco-in-new-jersey/" target="_blank">Growing Tobacco in New Jersey (#1)</a>&#8221; if you&#8217;re interested in reading about my first attempt at growing tobacco.</p></blockquote>
<div class="wp-caption alignnone" style="width: 510px"><a href="http://farm7.staticflickr.com/6042/7015871839_32dbea9c2b.jpg"><img title="March 30th, 2011: Baby cotton in the front, before the cat ate it." src="http://farm7.staticflickr.com/6042/7015871839_32dbea9c2b.jpg" alt="March 30th, 2011: Baby cotton in the front, before the cat ate it." width="500" height="374" /></a><p class="wp-caption-text">March 30th, 2011: Baby cotton in the front, tobacco behind.</p></div>
<p>The plants in the front of this picture are cotton and didn&#8217;t last long before being consumed by my cat. I wanted to make a cotton pouch for my tobacco.</p>
<p>The strongest plants are transferred to small pots. The strongest of these plants make it outside.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm7.staticflickr.com/6104/6869763160_aecd2f427a.jpg"><img title="May 1st, 2011: The tobacco is old enough to go outside. " src="http://farm7.staticflickr.com/6104/6869763160_aecd2f427a.jpg" alt="May 1st, 2011: The tobacco is old enough to go outside. " width="374" height="500" /></a><p class="wp-caption-text">May 1st, 2011: The tobacco is old enough to go outside.</p></div>
<p>7 weeks. The tobacco goes outside when it looks hardy, which is usually after a couple weeks. The milk jugs give them protection while they get used to being outside.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm7.staticflickr.com/6103/6869764898_a79dfe414c.jpg"><img title="June 9th, 2011: Young tobacco being chewed alive." src="http://farm7.staticflickr.com/6103/6869764898_a79dfe414c.jpg" alt="June 9th, 2011: Young tobacco being chewed alive." width="374" height="500" /></a><p class="wp-caption-text">June 9th, 2011: Young tobacco being chewed alive.</p></div>
<p>12 weeks. The soil in <a title="Wooden tobacco container" href="http://farm6.static.flickr.com/5307/5565094762_c122ca9547.jpg" target="_blank">my wooden container</a> has manure mixed in. I&#8217;m afraid of using pesticides.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm7.staticflickr.com/6110/7015875437_330cc2a6f7.jpg"><img title="June 21st, 2011: They're getting too big for the milk jugs." src="http://farm7.staticflickr.com/6110/7015875437_330cc2a6f7.jpg" alt="June 21st, 2011: They're getting too big for the milk jugs." width="374" height="500" /></a><p class="wp-caption-text">June 21st, 2011: They&#39;re getting too big for the milk jugs.</p></div>
<p>Watching the plants outgrow the milk jugs is great. They&#8217;re riding a bike for the first time.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm8.staticflickr.com/7223/6869766094_98dc892de5.jpg"><img title="July 5th, 2011: The leaves are getting larger." src="http://farm8.staticflickr.com/7223/6869766094_98dc892de5.jpg" alt="July 5th, 2011: The leaves are getting larger." width="374" height="500" /></a><p class="wp-caption-text">July 5th, 2011: The leaves are getting larger.</p></div>
<p>15 weeks. Tobacco grows quick. I fought the clovers in the background all summer.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm8.staticflickr.com/7203/7015877791_6b612244f1.jpg"><img title="July 19th, 2011: Still having bug problems, but overall doing well." src="http://farm8.staticflickr.com/7203/7015877791_6b612244f1.jpg" alt="July 19th, 2011: Still having bug problems, but overall doing well." width="374" height="500" /></a><p class="wp-caption-text">July 19th, 2011: Still having bug problems, but overall doing well.</p></div>
<p>17 weeks. I still have bug problems in July. The top of the plant looks healthy, so a few sacrificial bug leaves are fine.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm7.staticflickr.com/6097/7015878473_fd9fa6e30e.jpg"><img title="July 25th, 2011: Getting bushier." src="http://farm7.staticflickr.com/6097/7015878473_fd9fa6e30e.jpg" alt="July 25th, 2011: Getting bushier." width="374" height="500" /></a><p class="wp-caption-text">July 25th, 2011: Getting bushier.</p></div>
<p>The plant on the side is the orphan of the bunch. I reserved the back-left corner of the box for the only cotton plant that lived. The cotton plant was eaten by squirrels shortly after.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm7.staticflickr.com/6118/7015878157_cdbf10c20b.jpg"><img title="July 25th, 2011: I wanted to eat it." src="http://farm7.staticflickr.com/6118/7015878157_cdbf10c20b.jpg" alt="July 25th, 2011: I wanted to eat it." width="374" height="500" /></a><p class="wp-caption-text">July 25th, 2011: I wanted to eat it.</p></div>
<p>The rain is almost frequent enough to keep the plants fed. Stressing the plants does them good, so I wait until the leaves start to droop before giving them water. The leaves perk up after an hour.</p>
<div class="wp-caption alignnone" style="width: 510px"><a href="http://farm7.staticflickr.com/6226/6869766344_d7e82632e6.jpg"><img title="August 9th, 2011: The plants have much more heft now." src="http://farm7.staticflickr.com/6226/6869766344_d7e82632e6.jpg" alt="August 9th, 2011: The plants have much more heft now." width="500" height="374" /></a><p class="wp-caption-text">August 9th, 2011: The plants are thick.</p></div>
<p>22 weeks. The older leaves are getting their heft now. I&#8217;ve noticed that bugs tend to choose the same leaf to stick with, so I leave them around for the sake of the plant. They&#8217;ll only eat the leaf if it&#8217;s still attached. My decoy leaves never worked.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm8.staticflickr.com/7126/6869767068_46d31a89f3.jpg"><img title="August 16th, 2011: They little one on the side was a crap-shoot anyway." src="http://farm8.staticflickr.com/7126/6869767068_46d31a89f3.jpg" alt="August 16th, 2011: They little one on the side was a crap-shoot anyway." width="374" height="500" /></a><p class="wp-caption-text">August 16th, 2011: They little one on the side was a crap-shoot anyway.</p></div>
<p>Seeing the plants cast shadows against the fence is a gratifying feeling.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm7.staticflickr.com/6098/7015878813_459b062ffa.jpg"><img title="August 26th, 2011: The leaves on the bottom are sacrificial." src="http://farm7.staticflickr.com/6098/7015878813_459b062ffa.jpg" alt="August 26th, 2011: The leaves on the bottom are sacrificial." width="374" height="500" /></a><p class="wp-caption-text">August 26th, 2011: The leaves on the bottom are sacrificial.</p></div>
<p>24 weeks. This is the point in time where the plants really get their height. New leaves are cropping up every day. The new ones are at the top, pointing upward.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm8.staticflickr.com/7178/6869769026_53024266ca.jpg"><img title="August 28th, 2011: The great storm. I used paint cans to help hold the roots in." src="http://farm8.staticflickr.com/7178/6869769026_53024266ca.jpg" alt="August 28th, 2011: The great storm. I used paint cans to help hold the roots in." width="374" height="500" /></a><p class="wp-caption-text">August 28th, 2011: The great storm. I used paint cans to help hold the roots down.</p></div>
<p>I&#8217;ve always known that storms are a nightmare for farmers, but never understood like I do now. Hurricane Irene hit New Jersey on the 28th, which is when I was forced to relocate to a friend&#8217;s house. I prepared the plants by placing heavy polyurethane cans at the roots. I also pushed the dirt down around the bases. A large tobacco plant is a boat with many sails.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm7.staticflickr.com/6052/7015879441_ff915682a5.jpg"><img title="August 29th, 2011: The plants were sad for days." src="http://farm7.staticflickr.com/6052/7015879441_ff915682a5.jpg" alt="August 29th, 2011: The plants were sad for days." width="374" height="500" /></a><p class="wp-caption-text">August 29th, 2011: The plants were sad for days.</p></div>
<p>The storm passes. I push the roots back into the ground. The leaves drooped for days and the plants are now at a permanent angle.</p>
<div class="wp-caption alignnone" style="width: 250px"><a href="http://farm8.staticflickr.com/7245/6869959042_d2a5200e54.jpg"><img title="September 12th, 2011: As tall as I am." src="http://farm8.staticflickr.com/7245/6869959042_d2a5200e54.jpg" alt="September 12th, 2011: As tall as I am." width="240" height="320" /></a><p class="wp-caption-text">September 12th, 2011: As tall as I am.</p></div>
<p>26 weeks. I stand at about 5&#8217;11&#8243;. The plants are taller than me within days.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm8.staticflickr.com/7102/6869769720_fb74127d67.jpg"><img title="September 27th, 2011: I don't know when to harvest." src="http://farm8.staticflickr.com/7102/6869769720_fb74127d67.jpg" alt="September 27th, 2011: I don't know when to harvest." width="374" height="500" /></a><p class="wp-caption-text">September 27th, 2011: I don&#39;t know when to harvest.</p></div>
<p>Last year I pulled every leaf from my plants on November 3rd. This year I promised myself to let the plants live until they died, harvesting along the way. It&#8217;s an experiment.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm8.staticflickr.com/7277/7015880733_b86f85a294.jpg"><img title="October 18th, 2011: Embarrassingly proud of the flowers. " src="http://farm8.staticflickr.com/7277/7015880733_b86f85a294.jpg" alt="October 18th, 2011: Embarrassingly proud of the flowers. " width="374" height="500" /></a><p class="wp-caption-text">October 18th, 2011: Embarrassingly proud of the flowers.</p></div>
<p>31 weeks. October was a beautiful month for me. My plants flowered for the first time. I have too many photos of every flower.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm8.staticflickr.com/7128/6869771266_0f3b8e1551.jpg"><img title="October 18th, 2011: Stripped the bottom leaves to give the top ones more power." src="http://farm8.staticflickr.com/7128/6869771266_0f3b8e1551.jpg" alt="October 18th, 2011: Stripped the bottom leaves to give the top ones more power." width="374" height="500" /></a><p class="wp-caption-text">October 18th, 2011: Stripped the bottom leaves to give the top ones more power.</p></div>
<p>My sister gets her hair trimmed once a year to promote growth. I strip the bottommost leaves.</p>
<div class="wp-caption alignnone" style="width: 383px"><a href="http://farm7.staticflickr.com/6235/6869958904_e89eb85352.jpg"><img title="October 26th, 2011: The flowers!" src="http://farm7.staticflickr.com/6235/6869958904_e89eb85352.jpg" alt="October 26th, 2011: The flowers!" width="373" height="500" /></a><p class="wp-caption-text">October 26th, 2011: The flowers!</p></div>
<p>The flowers alone make tobacco worth growing.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm7.staticflickr.com/6097/6869771778_4e4ed1d598.jpg"><img title="November 6th, 2011: You can see the poly cans from the great storm." src="http://farm7.staticflickr.com/6097/6869771778_4e4ed1d598.jpg" alt="November 6th, 2011: You can see the poly cans from the great storm." width="374" height="500" /></a><p class="wp-caption-text">November 6th, 2011: You can see the poly cans from the great storm.</p></div>
<p>34 weeks. They&#8217;re at the point where I pulled them from the ground last year. The problem with growing tobacco in New Jersey is the duration and heat of summer. The leaves don&#8217;t get enough time to yellow. They end up drying badly and make terrible cigars.</p>
<div class="wp-caption alignnone" style="width: 384px"><a href="http://farm8.staticflickr.com/7110/6869772194_0d08537f25.jpg"><img title="November 13th, 2011: Worlds collide." src="http://farm8.staticflickr.com/7110/6869772194_0d08537f25.jpg" alt="November 13th, 2011: Worlds collide." width="374" height="500" /></a><p class="wp-caption-text">November 13th, 2011: Worlds collide.</p></div>
<p>The plants are intertwined. Like a mother, I had unwavering hope for the orphan plant until this picture. Everyone knew but me.</p>
<div class="wp-caption alignnone" style="width: 383px"><a href="http://farm8.staticflickr.com/7052/6869958696_c8b53f7936.jpg"><img title="December 4th, 2011: Tomorrow's plants are today's seeds." src="http://farm8.staticflickr.com/7052/6869958696_c8b53f7936.jpg" alt="December 4th, 2011: Tomorrow's plants are today's seeds." width="373" height="500" /></a><p class="wp-caption-text">December 4th, 2011: Tomorrow&#39;s plants are today&#39;s seeds.</p></div>
<p>38 weeks. I have seeds for this year that I am ready to plant! I plucked these down when they started falling from the plants. The leaves have been completely harvested and are hanging in the <a title="tobacco shed nj" href="http://farm6.static.flickr.com/5095/5564927411_eefcebb19b.jpg" target="_blank">same shed as last year</a>. I&#8217;m feeling ready to roll last year&#8217;s leaves into cigars at this point, and am beginning to plant the third harvest now.</p>
<p>You can see the full-sized photos in the gallery on Flickr at: <a title="Second year of growing tobacco in NJ" href="http://www.flickr.com/photos/38892591@N08/sets/72157629303521034/" target="_blank">Second year of growing tobacco in NJ</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.Schwertly.com/2012/04/growing-tobacco-in-new-jersey-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using Curl to Upload Images</title>
		<link>http://www.Schwertly.com/2011/11/using-curl-to-upload-images/</link>
		<comments>http://www.Schwertly.com/2011/11/using-curl-to-upload-images/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 20:51:28 +0000</pubDate>
		<dc:creator>Stan Schwertly</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.Schwertly.com/?p=711</guid>
		<description><![CDATA[You can upload images using two lines of easy-to-understand curl.]]></description>
				<content:encoded><![CDATA[<p><a title="Movuploader" href="https://github.com/brianokeefe/Movuploader" target="_blank">Movuploader</a> uses curl to upload mustache pictures to <a title="Movember" href="http://www.movember.com" target="_blank">Movember</a>. Normally this requires signing into the site, and then posting a status update with an image. We can automate these steps with two lines of <a title="curl" href="http://curl.haxx.se/" target="_blank">curl</a>. Curl was a natural choice for us since it&#8217;s installed by default on Snow Leopard and Lion.</p>
<h1>Logging In</h1>
<p>The following command is part of the <a title="upload/Movember" href="https://github.com/brianokeefe/Movuploader/blob/master/upload">upload script</a> and takes a username and password as parameters:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">curl <span style="color: #660033;">-L</span> <span style="color: #660033;">-s</span> <span style="color: #660033;">-c</span> cookie \
<span style="color: #660033;">-d</span> <span style="color: #007800;">email</span>=<span style="color: #007800;">$email</span> \
<span style="color: #660033;">-d</span> <span style="color: #007800;">password</span>=<span style="color: #007800;">$pass</span> \
<span style="color: #660033;">-d</span> <span style="color: #007800;">rememberme</span>=<span style="color: #000000;">0</span> \
<span style="color: #660033;">-d</span> <span style="color: #007800;">process</span>=<span style="color: #000000;">1</span> \
<span style="color: #660033;">-d</span> <span style="color: #007800;">submit</span>=<span style="color: #000000;">1</span> \
<span style="color: #660033;">-d</span> <span style="color: #007800;">redirect</span>=<span style="color: #000000;">0</span> \
https:<span style="color: #000000; font-weight: bold;">//</span>www.movember.com<span style="color: #000000; font-weight: bold;">/</span>us<span style="color: #000000; font-weight: bold;">/</span>auth<span style="color: #000000; font-weight: bold;">/</span>do-login</pre></td></tr></table></div>

<p>The first line passes three flags to curl: <strong>location</strong> (-L), <strong>silent</strong> (-s), and <strong>cookie</strong> (-c). <strong>Location</strong> will redirect your request if a redirect is seen. The <strong>silent</strong> flag suppresses the progress bar output, and the <strong>cookie</strong> flag lets you specify a file where cookie information is stored. The last part of the command sends the <strong>data</strong> (-d) in a POST request. The data flag lets you build a single string to pass instead, but I&#8217;ve opted to be more verbose here for clarity.</p>
<p>When someone logs in on Movember.com, they&#8217;re redirected with a &#8220;302 (Moved Temporarily)&#8221; request to their main page. We use the information on the user&#8217;s main page to figure out their ID number (Movember refers to this as the user&#8217;s &#8220;entity ID&#8221;). If we only needed the cookie file, we wouldn&#8217;t have to care about the redirect. (Note: the curl in the upload script pulls the entity ID into a variable and isn&#8217;t shown above).</p>
<p>We can see the redirect ourselves by adjusting the command above to <strong>include headers</strong>:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">curl <span style="color: #660033;">-is</span> \
<span style="color: #660033;">-d</span> <span style="color: #007800;">email</span>=<span style="color: #007800;">$email</span> \
<span style="color: #660033;">-d</span> <span style="color: #007800;">password</span>=<span style="color: #007800;">$pass</span> \
<span style="color: #660033;">-d</span> <span style="color: #007800;">rememberme</span>=<span style="color: #000000;">0</span> \
<span style="color: #660033;">-d</span> <span style="color: #007800;">process</span>=<span style="color: #000000;">1</span> \
<span style="color: #660033;">-d</span> <span style="color: #007800;">submit</span>=<span style="color: #000000;">1</span> \
<span style="color: #660033;">-d</span> <span style="color: #007800;">redirect</span>=<span style="color: #000000;">0</span> \
https:<span style="color: #000000; font-weight: bold;">//</span>www.movember.com<span style="color: #000000; font-weight: bold;">/</span>us<span style="color: #000000; font-weight: bold;">/</span>auth<span style="color: #000000; font-weight: bold;">/</span>do-login</pre></td></tr></table></div>

<p>The first line returns: <strong style="font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;">HTTP/1.1 302 Found</strong>, which is the &#8220;Temporary redirect&#8221; mentioned earlier.</p>
<p>The last part of the command sends the necessary information to movember.com&#8217;s login form through a POST request. The form names are located within the page&#8217;s source. You&#8217;ll run into problems if you don&#8217;t submit all the information the form is expecting. <a title="Tamper Data" href="https://addons.mozilla.org/en-US/firefox/addon/tamper-data/" target="_blank">Tamper Data</a> for Firefox is a great tool for figuring out what exactly gets sent &#8212; turn it on, fill out the form, and examine the request being sent to the server. You can use this information to reconstruct the request with curl.</p>
<h1>Uploading Images</h1>
<p>Now we have a cookie file that we can use to authenticate ourselves to the server with. We&#8217;ll use the silent flag again and pass the cookie file in with the <strong>-b flag</strong>:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">curl <span style="color: #660033;">-s</span> <span style="color: #660033;">-b</span> cookie \
http:<span style="color: #000000; font-weight: bold;">//</span>us.movember.com<span style="color: #000000; font-weight: bold;">/</span>mospace<span style="color: #000000; font-weight: bold;">/</span>your-donation-page<span style="color: #000000; font-weight: bold;">/</span>create-post<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #660033;">-F</span> <span style="color: #007800;">content</span>=<span style="color: #007800;">$new</span>
<span style="color: #660033;">-F</span> <span style="color: #007800;">entity_id</span>=<span style="color: #007800;">$entity</span>
<span style="color: #660033;">-F</span> <span style="color: #007800;">name</span>=image
<span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;filename=<span style="color: #007800;">$new</span>;image/jpeg;&quot;</span>
<span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;image=@<span style="color: #007800;">$new</span>&quot;</span></pre></td></tr></table></div>

<p>The rest of the request is very similar to the last request. Instead of using the <strong>data</strong> flag, we&#8217;ve switched to the <strong>form</strong> (-F) flag. You need to use the form flag if the form you&#8217;re posting to specifies that it&#8217;s multipart/form-data. It also allows you to upload binary files (in this case, a picture of a mustache). Here we&#8217;re posting a:</p>
<ul>
<li>status update &#8211; the name of the file so we can track our growth</li>
<li>our entity ID &#8211; saved from the last request.</li>
<li>the name of the content &#8211; in this case, Movember expects either &#8220;image&#8221; or &#8220;video&#8221;.</li>
<li>the filename of the image</li>
<li>the contents of the image &#8211; the &#8216;@&#8217; symbol tells curl to pull the information from a file on disk.</li>
</ul>
<p>That&#8217;s it! Are you participating in Movember? Are you running a Mac with Snow Leopard or Lion installed? Download the <a title="Movuploader" href="http://movesmye.rs/~/Movuploader.dmg" target="_blank">Movuploader DMG here</a> or go to the <a title="Stan Schwertly Movuploader" href="https://github.com/brianokeefe/Movuploader" target="_blank">Movuploader Github page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.Schwertly.com/2011/11/using-curl-to-upload-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using WWW::Mechanize to Post to a Forum from IRC</title>
		<link>http://www.Schwertly.com/2011/10/using-wwwmechanize-to-post-to-a-forum-from-irc/</link>
		<comments>http://www.Schwertly.com/2011/10/using-wwwmechanize-to-post-to-a-forum-from-irc/#comments</comments>
		<pubDate>Sat, 22 Oct 2011 21:42:06 +0000</pubDate>
		<dc:creator>Stan Schwertly</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[secret society]]></category>

		<guid isPermaLink="false">http://www.Schwertly.com/?p=637</guid>
		<description><![CDATA[It's convenient to be able to post to the forum from IRC, instead of copying text, opening a new tab, singing in, creating a new reply, and pasting. ]]></description>
				<content:encoded><![CDATA[<p>The <a title="The Dead Coder Society" href="http://www.Schwertly.com/2011/05/the-dead-coder-society/" target="_blank">DeadCoderSociety</a> IRC channel is easily our busiest electronic meeting place. The IRC channel has overshadowed the once-popular forum, turning it into a warehouse for quoted IRC conversations. The new automatic quote feature allows a person to quote a recent conversation, edit it in a quiet and convenient way, and post it to the forum. It saves time and hassle by minimizing interaction with the forum and allowing the user to stay in IRC. The workflow looks like this:</p>
<ol>
<li>Interesting/funny conversation happens in the channel.</li>
<li>Someone says !quote.</li>
<li>The bot messages the quoter with the last 13 lines of the conversation.</li>
<li>From here, the person can &#8220;keep&#8221; or &#8220;delete&#8221; specific lines, or chunks of lines.</li>
<li>Each action results in a paste of the edited conversation until the person is happy with the preview.</li>
<li>Person messages the bot with &#8220;go&#8221; and it shows up on the forum.</li>
</ol>
<p>My bot already logs the conversation, so it just runs <strong>tail</strong> <strong>-n13</strong> on the log file (prepending line numbers to the front) and sends a private message to the caller. The actual editing is a simple combination of regular expressions and array splicing. Editing continues until the user posts the message or quotes something new.</p>
<p><a title="WWW::Mechanize" href="http://search.cpan.org/dist/WWW-Mechanize/" target="_blank">WWW::Mechanize</a> makes posting the final message simple:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">sub</span> _postIt <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$message</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$mech</span> <span style="color: #339933;">=</span> WWW<span style="color: #339933;">::</span><span style="color: #006600;">Mechanize</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">new</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># go to the login page</span>
  <span style="color: #0000ff;">$mech</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span>get<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;http://forum.deadcodersociety.org/index.php?action=login&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># submit credentials</span>
  <span style="color: #0000ff;">$mech</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span>submit_form<span style="color: #009900;">&#40;</span>
    with_fields <span style="color: #339933;">=&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #ff0000;">&quot;user&quot;</span>    <span style="color: #339933;">=&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span> <span style="color: #ff0000;">&quot;stanbot&quot;</span><span style="color: #339933;">,</span>
      <span style="color: #ff0000;">&quot;passwrd&quot;</span> <span style="color: #339933;">=&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span> <span style="color: #ff0000;">&quot;password&quot;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># grab the &quot;Quotes&quot; thread</span>
  <span style="color: #0000ff;">$mech</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span>get<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;http://forum.deadcodersociety.org/index.php/topic,78.0.html&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># grab the reply link and click it</span>
  <span style="color: #0000ff;">$mech</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span>follow_link<span style="color: #009900;">&#40;</span>text_regex<span style="color: #339933;">=&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span> <span style="color: #009966; font-style: italic;">qr/REPLY/i</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># submit our new quote</span>
  <span style="color: #0000ff;">$mech</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span>submit_form<span style="color: #009900;">&#40;</span>
    with_fields <span style="color: #339933;">=&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #ff0000;">&quot;message&quot;</span> <span style="color: #339933;">=&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span> <span style="color: #ff0000;">&quot;[quote]&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">@$message</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot;[/quote]&quot;</span><span style="color: #339933;">,</span>
      <span style="color: #ff0000;">&quot;subject&quot;</span> <span style="color: #339933;">=&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span> <span style="color: #ff0000;">&quot;Re: DCS Quotes!&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>I added the calls to sleep because I was triggering the forum&#8217;s bot-detection code. The submit_form method is smart and will automatically detect the form based on the fields passed in. The channel is made aware of the post after it finishes since the bot scans for new messages posted to the forums.</p>
<p>We&#8217;ve had this for about two months now and it&#8217;s been used by everyone for nearly every quote. It encourages people to quote more conversations and ultimately strengthens the bond in the community. Pretty good for 33 lines of code!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.Schwertly.com/2011/10/using-wwwmechanize-to-post-to-a-forum-from-irc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Dead Coder Society</title>
		<link>http://www.Schwertly.com/2011/05/the-dead-coder-society/</link>
		<comments>http://www.Schwertly.com/2011/05/the-dead-coder-society/#comments</comments>
		<pubDate>Sun, 15 May 2011 04:04:49 +0000</pubDate>
		<dc:creator>Stan Schwertly</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[secret society]]></category>

		<guid isPermaLink="false">http://www.Schwertly.com/?p=623</guid>
		<description><![CDATA[My final note for the first year of the Dead Coder Society at Stockton College, NJ.]]></description>
				<content:encoded><![CDATA[<div>
<p>This is a repost from the post I made over at the actual <a title="Dead Coder Society" href="http://www.deadcodersociety.org" target="_blank">Dead Coder Society blog</a>. The Dead Coder Society (DCS) is a group I formed this past year at Stockton. It&#8217;s a selective student-run group of dedicated computer science majors, with a goal of teaching each other interesting stuff they wouldn&#8217;t learn in class. I am convinced that the existence of DCS has improved my technical ability, social skills, and has gained me a network of incredibly smart people.</p>
<h2>The First Year of the Dead Coder Society</h2>
<p>The first year of the Dead Coder Society is over. We did an amazing number of things right for a first-year group:</p>
<ul>
<li><strong>We met consistently.</strong> A consistent meeting schedule is critical for establishing trust in the group. Trust makes other members want to show up and want to present.</li>
<li><strong>We built a strong network of intelligent, enthusiastic students</strong>. Outside of learning from each other, a consistent schedule enforced us all to get to know each other better. One of the problems that most computer science majors at Stockton face is a lack of community. We tied community and learning to create strong bonds that have lead to job opportunities and more.</li>
<li><strong>We accomplished goals without a budget. </strong>We shared in any expenses that we incurred, and as a result, I think we all appreciated what we did more.</li>
<li><strong>We accomplished goals without official club status</strong>. We were free to meet where and when we wanted to, without needing to seek advisor approval or wait for funds to be processed. We weren&#8217;t forced to waste time writing a constitution or electing certain people to official positions. Our success was directly related to the work every member put in.</li>
<li><strong>We maintained a strong web-presence throughout the year.</strong> The Dead Coder Society has an up-to-date website, complete with forums and chat rooms. Every meeting has been logged and the slides are available for most speakers. Our log of activity is more up to date than most clubs at Stockton. We also experimented with advertising the Society through Google advertising and received several internship offers.</li>
<li><strong>We worked on school-wide educational projects</strong>. Outside of our schoolwork and extracurricular study, we embarked on smaller projects to directly benefit Stockton. There is an education resource project still underway internally, and there are plans for several programming competitions at Stockton.</li>
<li><strong>We kept other members up to date with video recordings of meetings and live Skype calls when available.</strong>Some members were unable to attend meetings, which typically would mean completely missing the educational and social value that comes from showing up. We recorded every meeting from the second half of the year and in some cases were able to live-cast the meeting directly to the missing member.</li>
</ul>
<p>Three of our members (including myself) graduated this spring:</p>
<ul>
<li><a title="Stan Schwertly" href="http://www.schwertly.com" target="_blank">Stan Schwertly</a></li>
<li>Aniello Anthony DiSpigna</li>
<li>Andrew Hofstetter</li>
</ul>
<p>There will be some changes to the Society coming in the future, but until then:</p>
<p>Cheers to the Dead Coder Society,</p>
<p>Stan Schwertly</p>
</div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.Schwertly.com/2011/05/the-dead-coder-society/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turning Code into a Video with Gource</title>
		<link>http://www.Schwertly.com/2011/05/turning-code-into-a-video-with-gource/</link>
		<comments>http://www.Schwertly.com/2011/05/turning-code-into-a-video-with-gource/#comments</comments>
		<pubDate>Thu, 12 May 2011 21:51:04 +0000</pubDate>
		<dc:creator>Stan Schwertly</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.Schwertly.com/?p=611</guid>
		<description><![CDATA[I turned our senior project's code repository into a video with gource, a visualization program for project code.]]></description>
				<content:encoded><![CDATA[<p>My last semester&#8217;s project was a group software engineering assignment. We used Git for version control and specifically used a private <a title="Github" href="http://www.github.com" target="_blank">Github</a> account with the intention of open sourcing the code. The only task that remains is moving the sensitive data into a central configuration file. Instead of doing that, I transformed our repository into a video using <a title="Gource" href="http://code.google.com/p/gource/" target="_blank">Gource</a>:</p>
<p><object width="425" height="344" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/GHhO4XuB0Hk?hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed width="425" height="344" type="application/x-shockwave-flash" src="http://www.youtube.com/v/GHhO4XuB0Hk?hl=en&amp;fs=1" allowFullScreen="true" allowscriptaccess="always" allowfullscreen="true" /></object></p>
<p>While I don&#8217;t share the exact level of hate of <a title="Macports" href="http://www.macports.org/" target="_blank">macports</a> as him, I ended up using part of Matt Hutchinson&#8217;s excellent guide for <a title="Gource on OSX" href="http://matthewhutchinson.net/2009/12/8/gource-on-osx-snow-leopard " target="_blank">Gource on OSX</a>. Gource has a slew of options and allows you to generate videos from git repositories, as well as Mercurial, Bazaar, and SVN. I ended up removing files from the video, since it cluttered the screen. I also highlighted directories and users and scaled users to a size of 1.6. You can adjust the speed of the video too. Be careful though: it&#8217;s a fine line between flurrying and boring. You&#8217;re even able to specify images for each specific contributor if you choose to do so. There are several scripts available online that attempt to import gravatars based on the repositories configuration information.</p>
<p>Gource is a fun way of visualizing the work put into any repository. Every project that <span style="text-decoration: underline;">can</span> be gource&#8217;d <strong>should</strong> be gource&#8217;d.</p>
<p>Another shout-out to <a title="Mike Greb" href="http://michael.thegrebs.com/" target="_blank">Mike Greb</a> for initially showing me Gource. Obviously none of this would have happened if he didn&#8217;t know about all of the cool things ahead of time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.Schwertly.com/2011/05/turning-code-into-a-video-with-gource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TextPuller: Dashboard Widget for Taskwarrior Text Files</title>
		<link>http://www.Schwertly.com/2011/05/dashboard-widget-for-taskwarrior-text-files/</link>
		<comments>http://www.Schwertly.com/2011/05/dashboard-widget-for-taskwarrior-text-files/#comments</comments>
		<pubDate>Mon, 09 May 2011 23:44:38 +0000</pubDate>
		<dc:creator>Stan Schwertly</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.Schwertly.com/?p=557</guid>
		<description><![CDATA[A dashboard widget for online text files, specifically files generated by Taskwarrior.]]></description>
				<content:encoded><![CDATA[<p><strong>Here&#8217;s why you want this:</strong></p>
<ul>
<li>You use a Mac</li>
<li>You use <a title="Taskwarrior" href="http://taskwarrior.org/projects/show/taskwarrior/" target="_blank">Taskwarrior</a></li>
<li>You have &#8220;task list&#8221; dumped to a file accessable online (preferably through cron)</li>
</ul>
<p><span style="text-decoration: underline;">Background:</span> I have a cronjob that pumps the output of &#8220;task list&#8221; to a text file every 5 minutes. The text file is under a web directory of mine, so I&#8217;m able to see my current list of tasks from any location with web-access. I wanted a dashboard widget that sucked in the text file and displayed it. I tried using &#8220;Web Clip&#8221;, but the bounding box is static &#8212; which means you&#8217;re either stuck with too big of a box, or your text gets cut off.</p>
<p><span style="text-decoration: underline;">Features:</span> Here&#8217;s a simple widget that lets you replace the URL with a text file of your own. It dynamically resizes the window to fit the text file. I don&#8217;t anticipate having a long task list and I don&#8217;t like scrollbars.</p>
<p><span style="text-decoration: underline;">File:</span> You can find the latest version of TextPuller on GitHub at: <a title="TextPuller - Stan Schwertly" href="https://github.com/Stantheman/TextPuller" target="_blank">https://github.com/Stantheman/TextPuller</a></p>
<p>Let me know if you have any suggestions!</p>
<p><strong>Update: TextPuller has been featured on Taskwarrior.org: <a title="TextPuller" href="http://taskwarrior.org/news/79" target="_blank">http://taskwarrior.org/news/79</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.Schwertly.com/2011/05/dashboard-widget-for-taskwarrior-text-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Software Development Lessons</title>
		<link>http://www.Schwertly.com/2011/05/software-development-lessons/</link>
		<comments>http://www.Schwertly.com/2011/05/software-development-lessons/#comments</comments>
		<pubDate>Sat, 07 May 2011 01:58:52 +0000</pubDate>
		<dc:creator>Stan Schwertly</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.Schwertly.com/?p=536</guid>
		<description><![CDATA[Here are some of the lessons I learned while developing SHiGS, my final software project for Stockton.]]></description>
				<content:encoded><![CDATA[<p>The Stockton Historical Geolocation Service (SHiGS) takes historical data with any number of attributes, geolocates it, and allows the user to filter the data with search criteria on a Google Map. We created SHiGS for our final project in Software &amp; Security Engineering.</p>
<p><a href="http://www.Schwertly.com/wp-content/uploads/2011/05/shigs-map.png"><img class="alignnone size-full wp-image-546" title="shigs-map" src="http://www.Schwertly.com/wp-content/uploads/2011/05/shigs-map.png" alt="shigs-map" /></a></p>
<p>I learned a lot about working on a team and the software creation process. Here are a few of the points that stand out:</p>
<ul>
<li><span style="text-decoration: underline;">Open communication early</span>. Find out exactly what the user needs and which requirements are most critical.</li>
<li><span style="text-decoration: underline;">Communicate with everyone often</span>. Stockton had a progress log that we posted updates to. Besides keeping everyone in sync, the progress log was a subtle &#8220;I should catch up&#8221; alarm. We had a leg-up over the other teams in that we all participated in an IRC channel together and otherwise we friends prior to the semester.</li>
<li><span style="text-decoration: underline;">Leverage technology to increase communication</span>. We used GitHub&#8217;s post-receive hooks to send text messages and emails to each member of the team when someone pushed. There was no excuse for being out of the loop.</li>
<li><span style="text-decoration: underline;">Most of the actual work was finished when we weren&#8217;t together</span>. Although a lot of the design was a result of our discussions, the bulk of our code was made by each individual member by themselves. We still programmed when we were together, but it became too easy to become sidetracked.</li>
<li><span style="text-decoration: underline;">Meetings in person help the design process</span>. It was easy to talk about the benefits of one type of design in person. You can talk with your hands in person and use whiteboards in person. It&#8217;s perfect for discussing ideas.</li>
<li><span style="text-decoration: underline;">Spend time choosing your team members</span>. It&#8217;s a lot better to go through one awkward rejection than to suffer through a semester of disappointment. This might not be applicable in all situations. If you can&#8217;t get rid of a slacker, try hard and fast to find something that fits their skill set. If that fails, talk to someone with more power than you.</li>
</ul>
<p>I also learned that I should keep passwords out of git if I plan to release the code as open-source. A link to a working version of SHiGS (along with the code) will be made available as soon as I move any sensitive data to a config file that isn&#8217;t tracked in version control <img src='http://www.Schwertly.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.Schwertly.com/2011/05/software-development-lessons/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Growing Tobacco In New Jersey</title>
		<link>http://www.Schwertly.com/2011/03/growing-tobacco-in-new-jersey/</link>
		<comments>http://www.Schwertly.com/2011/03/growing-tobacco-in-new-jersey/#comments</comments>
		<pubDate>Sun, 27 Mar 2011 22:24:24 +0000</pubDate>
		<dc:creator>Stan Schwertly</dc:creator>
				<category><![CDATA[Pictures]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[plants]]></category>
		<category><![CDATA[tobacco]]></category>

		<guid isPermaLink="false">http://www.Schwertly.com/?p=474</guid>
		<description><![CDATA[I grew tobacco in NJ last year and took pictures throughout the whole process. You should try it.]]></description>
				<content:encoded><![CDATA[<div class="wp-caption alignnone" style="width: 510px"><img title="baby tobacco" src="http://farm6.static.flickr.com/5026/5564227641_4e7b700622.jpg" alt="Baby Tobacco" width="500" height="375" /><p class="wp-caption-text">Baby Tobacco (April 24th, 2010)</p></div>
<p>I grew cigar tobacco for the first time last year. Planting tobacco is weird because the seeds need to lay on top of the soil, instead of being covered or buried.</p>
<div class="wp-caption alignnone" style="width: 510px"><img title="Bushy Baby Tobacco" src="http://farm6.static.flickr.com/5104/5564816056_03cae57635.jpg" alt="Bushy Baby Tobacco" width="500" height="375" /><p class="wp-caption-text">Bushy Baby Tobacco (May 20th, 2010)</p></div>
<p>I had more seedlings than I could keep, so I pulled the stragglers out with tweezers. The remaining plants continued to grow until it was time to transplant them outside.</p>
<p>I built a 4&#8242;x4&#8242; box for the plants to sit in. The plants had cut-off plastic milk jugs on top of them while their roots settled.</p>
<div class="wp-caption alignnone" style="width: 510px"><img class=" " title="gardenbox" src="http://farm6.static.flickr.com/5307/5565094762_c122ca9547.jpg" alt="garden box" width="500" height="375" /><p class="wp-caption-text">I used discount wood from Home Depot. The dirt was more expensive.</p></div>
<p>I put too many plants outside as insurance against failure. They succeeded, and the smaller plants began to take resources from the stronger ones.</p>
<div class="wp-caption alignnone" style="width: 510px"><img title="too many tobacco plants" src="http://farm6.static.flickr.com/5173/5564725741_000a40d537.jpg" alt="too many tobacco plants pushed together" width="500" height="400" /><p class="wp-caption-text">This is what tobacco plants look like when they&#39;re too close together. (June 26th, 2010)</p></div>
<p>I needed to thin out the plants to give the stronger ones room to grow. I had no space to put the smaller plants, and ended up discarding them.</p>
<div class="wp-caption alignnone" style="width: 510px"><img title="tobacco toddler" src="http://farm6.static.flickr.com/5187/5565326772_830f7f4dc6.jpg" alt="tobacco toddler" width="500" height="400" /><p class="wp-caption-text">Toddler tobacco. (July 11th, 2010)</p></div>
<p>I didn&#8217;t use any chemicals on the plants. I ran my fingers against the leaves to stop bugs in problematic areas. Squirrels and birds stayed away from the plants.</p>
<p>I had five plants total. They started growing really quickly in July.</p>
<div class="wp-caption alignnone" style="width: 510px"><img title="fast growing plant" src="http://farm6.static.flickr.com/5026/5565353332_763fc556f5.jpg" alt="fast growing plant" width="500" height="400" /><p class="wp-caption-text">This was seven days later! (July 18th, 2010)</p></div>
<p>I was torn between two plants during the thinning process, so I filled a bucket with dirt and kept both.</p>
<div class="wp-caption alignnone" style="width: 510px"><img title="bucket tobacco" src="http://farm6.static.flickr.com/5300/5565353178_67e1fb4e8c.jpg" alt="bucket tobacco" width="500" height="400" /><p class="wp-caption-text">The bucket plant actually did really well and was easy to move around. (July 21st, 2010)</p></div>
<p>The plants were still small in the beginning of August. I worried about the seasons changing.</p>
<div class="wp-caption alignnone" style="width: 510px"><img title="tobacco crop" src="http://farm6.static.flickr.com/5140/5565375400_2a32d8a3a1.jpg" alt="tobacco crop" width="500" height="400" /><p class="wp-caption-text">The leaves are more matured at this point, but are nowhere near their full potential. (August 4th, 2010)</p></div>
<p>The August heat fixed everything.</p>
<div class="wp-caption alignnone" style="width: 510px"><img title="tobacco plants" src="http://farm6.static.flickr.com/5146/5564819783_40a08db294.jpg" alt="plants" width="500" height="400" /><p class="wp-caption-text">They&#39;re not the tallest plants in the world, but they&#39;re much closer to being ready. (August 24th, 2010)</p></div>
<p>There are a few tidbits to know about growing tobacco:</p>
<ul>
<li>Little leaves will sprout off at the top of the plant. These &#8220;suckers&#8221; should be plucked off, since they won&#8217;t mature and will only remove energy from the important leaves.</li>
<li>A leaf will begin to yellow slightly when it&#8217;s ready to be picked. The leaf will snap off if it&#8217;s ready to be plucked.</li>
<li>Plucking the small lower leaves is good &#8212; the goal is let the large leaves grow as big as possible.</li>
</ul>
<p>The bucket plant began to wilt in August. It stopped wilting in September.</p>
<div class="wp-caption alignnone" style="width: 510px"><img title="wilted bucket plant" src="http://farm6.static.flickr.com/5101/5565429086_d1104e50eb.jpg" alt="wilted bucket plant" width="500" height="400" /><p class="wp-caption-text">The guesses are either root rot or overwatering. (August 28th, 2010)</p></div>
<p>I pulled off a majority of the leaves in early September. I took this picture after pulling a big group of leaves (which has since become the little image on the right-side of this blog.)</p>
<div class="wp-caption alignnone" style="width: 510px"><img title="stan and tobacco" src="http://farm6.static.flickr.com/5107/5564867053_ec48ff4352.jpg" alt="stan and tobacco" width="500" height="400" /><p class="wp-caption-text">Stan and Tobacco (September 6th, 2010)</p></div>
<p>The plants were almost completely bare at this point, but lived and continued to produce suckers. I decided to battle them out of the ground in November.</p>
<div class="wp-caption alignnone" style="width: 510px"><img title="battling tobacco" src="http://farm6.static.flickr.com/5307/5564899929_c3907bf763.jpg" alt="battling tobacco" width="500" height="375" /><p class="wp-caption-text">I won. (November 3rd, 2010)</p></div>
<p>I hung the leaves in bundles. They&#8217;re still drying now. I&#8217;ll roll them into cigars the same way <a title="Making Cigars" href="http://www.Schwertly.com/2011/01/making-cigars/">I did when I made them the first time</a>.</p>
<div class="wp-caption alignnone" style="width: 510px"><img title="Hanging tobacco leaf" src="http://farm6.static.flickr.com/5095/5564927411_eefcebb19b.jpg" alt="hanging tobacco leaf" width="500" height="375" /><p class="wp-caption-text">The leaf is drying in a shed right now.</p></div>
<p>I threw the plants in the shed too (which is known as &#8220;whole-stalk harvesting&#8221;.) I&#8217;m starting this year&#8217;s crop now in hopes of getting larger plants. I&#8217;m trying cotton this year too, and will post about that in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.Schwertly.com/2011/03/growing-tobacco-in-new-jersey/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Simple Automated Graphing with gnuplot</title>
		<link>http://www.Schwertly.com/2011/02/simple-automated-graphing-with-gnuplot/</link>
		<comments>http://www.Schwertly.com/2011/02/simple-automated-graphing-with-gnuplot/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 15:16:22 +0000</pubDate>
		<dc:creator>Stan Schwertly</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[graphs]]></category>

		<guid isPermaLink="false">http://www.Schwertly.com/?p=458</guid>
		<description><![CDATA[In the spirit of graphing with R, I tried graphing with gnuplot, a great tool for generating graphs.]]></description>
				<content:encoded><![CDATA[<p>After learning how to <a title="Using R to Automatically Generate Pie Charts" href="http://www.schwertly.com/2011/02/using-r-to-automatically-generate-pie-charts/" target="_blank">graph data with R</a> (and finding out all of the <a title="Dumping Data, Saving Passwords, and OUTFILE Syntax with MySQL" href="http://www.schwertly.com/2011/02/dumping-data-saving-passwords-and-outfile-syntax-with-mysql/" target="_blank">different MySQL tricks</a> that came along with it,) I decided to try <a title="gnplot" href="http://www.gnuplot.info/" target="_blank">gnuplot</a>. gnuplot is a portable command-line driven graphing utility for linux, OS/2, MS Windows, OSX, VMS, and many other platforms. You can see a slew of different example graphs over at the <a title="gnuplot diagrams" href="http://commons.wikimedia.org/wiki/Category:Gnuplot_diagrams" target="_blank">Wikimedia page for gnuplot diagrams.</a></p>
<p>It&#8217;s much different than R. My previous use case for R was generating graphs, which is a small subset of the capabilities R provides. For example, R needs a datafile filled with data for analysis, where gnuplot only wants data that is pertinent to graphing. As a result, I needed to change my MySQL queries to be conscious of the fact that gnuplot only wants what it absolutely needs.</p>
<p>My first goal was to make a pie chart with gnuplot, but it&#8217;s not possible <a title="Pie charts are a no-go in gnuplot" href="http://www.gnuplot.info/faq/faq.html#SECTION00065000000000000000" target="_blank">according to their FAQ</a>. So I scratched that idea and made a histogram/barchart instead using the data pulled from a set of Perl scripts I wrote a while ago:</p>
<div id="attachment_460" class="wp-caption alignnone" style="width: 310px"><a href="http://www.Schwertly.com/wp-content/uploads/2011/02/barchart-openmic.png"><img class="size-medium wp-image-460" title="barchart-openmic" src="http://www.Schwertly.com/wp-content/uploads/2011/02/barchart-openmic-300x225.png" alt="histogram of open mic activity in NJ's CL" width="300" height="225" /></a><p class="wp-caption-text">Also known as a histogram</p></div>
<p>The code for this is pretty painless and can be done through either gnuplot&#8217;s interactive shell, or through scripting. If you&#8217;re running it interactively and want to save the output, be sure to run &#8220;save &#8216;filename.plot&#8217;&#8221; before exiting:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="gnuplot" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;">#!/usr/bin/gnuplot -persist</span>
<span style="color: #b1b100;">set</span> <span style="color: #990000;">terminal</span> <span style="color: #448888;">png</span> <span style="color: #448888;">nocrop</span> <span style="color: #448888;">font</span> <span style="color: #448888;">small</span> <span style="color: #990000;">size</span> <span style="color: #cc66cc;">640</span><span style="color: #000; font-weight: bold;">,</span><span style="color: #cc66cc;">480</span>
<span style="color: #b1b100;">set</span> <span style="color: #990000;">output</span> <span style="color: #0000ff;">'barchart-openmic.png'</span>
<span style="color: #b1b100;">set</span> <span style="color: #990000;">style</span> data <span style="color: #448888;">histograms</span>
<span style="color: #b1b100;">set</span> <span style="color: #990000;">title</span> <span style="color: #0000ff;">&quot;Most Active Sections Of NJ CL for Open Mics&quot;</span>
<span style="color: #b1b100;">set</span> <span style="color: #990000;">xlabel</span> <span style="color: #0000ff;">&quot;CL Section Name&quot;</span>
<span style="color: #b1b100;">set</span> <span style="color: #990000;">ylabel</span> <span style="color: #0000ff;">&quot;Post Count&quot;</span>
<span style="color: #b1b100;">plot</span> <span style="color: #0000ff;">&quot;/tmp/bargraph.csv&quot;</span> <span style="color: #448888;">using</span> <span style="color: #cc66cc;">2</span><span style="color: #000; font-weight: bold;">:</span>xticlabels<span style="color: #000099; font-weight:bold;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #000099; font-weight:bold;">&#41;</span> <span style="color: #990000;">notitle</span></pre></td></tr></table></div>

<p>It&#8217;s also interesting to note that the &#8220;plot&#8221; function takes a <strong>lot</strong> of parameters &#8212; the above code could be much shorter. I wanted to see the increase in activity on CraigsList over time, so I made a second graph. A few slight changes to the code pumps out a basic line graph. It actually took me longer to get the SQL query right than to put the code down (both quick though!). The primary change was the &#8220;set style&#8221; line, which became &#8220;set style data linespoints&#8221;. The result was exactly what I was hoping for:</p>
<div id="attachment_463" class="wp-caption alignnone" style="width: 310px"><a href="http://www.Schwertly.com/wp-content/uploads/2011/02/linegraph-openmic.png"><img class="size-medium wp-image-463" title="linegraph-openmic" src="http://www.Schwertly.com/wp-content/uploads/2011/02/linegraph-openmic-300x225.png" alt="" width="300" height="225" /></a><p class="wp-caption-text">Profits are up!</p></div>
<p>That&#8217;s it! gnuplot is great for simple graphmaking. I&#8217;ve got a cronjob set up that points to a simple bash script that runs the SQL query, then gnuplot, and then the &#8220;rm&#8221; on the file. It&#8217;s automatic graphing:</p>
<p><strong>pull data -&gt; dump data -&gt; graph data</strong></p>
<p>I&#8217;m looking forward to creating some of the more complex charts that I saw on the Wikimedia page and eventually using them to help revitalize <a title="JerseyMic" href="http://www.jerseymic.com" target="_blank">JerseyMic</a>. More about the JerseyMic project later!</p>
<p>(Interested in getting started? <a title="Getting Started with gnuplot" href="http://math-blog.com/2008/06/08/getting-started-with-gnuplot/">Math-blog.com has a pretty great post on the topic!</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.Schwertly.com/2011/02/simple-automated-graphing-with-gnuplot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dumping Data, Saving Passwords, and OUTFILE Syntax with MySQL</title>
		<link>http://www.Schwertly.com/2011/02/dumping-data-saving-passwords-and-outfile-syntax-with-mysql/</link>
		<comments>http://www.Schwertly.com/2011/02/dumping-data-saving-passwords-and-outfile-syntax-with-mysql/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 00:49:15 +0000</pubDate>
		<dc:creator>Stan Schwertly</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.Schwertly.com/?p=450</guid>
		<description><![CDATA[This is a more in-depth discussion of the specific MySQL lessons learned while setting up automated pie chart generation with R.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.Schwertly.com/wp-content/uploads/2011/02/mysql.png"><img class="alignnone size-medium wp-image-451" title="mysql" src="http://www.Schwertly.com/wp-content/uploads/2011/02/mysql-300x155.png" alt="" width="300" height="155" /></a></p>
<p>This is a side-post cut out of &#8220;<a title="Using R to Automatically Generate Pie Charts" href="http://www.Schwertly.com/2011/02/using-r-to-automatically-generate-pie-charts/" target="_blank">Using R to Automatically Generate Pie Charts</a>&#8220;. I enjoyed talking about the architecture behind making the graphs, but the specific hurdles I hit with MySQL were overwhelming and detrimental to the overall point: simple automated graph generation. I hit three hurdles getting MySQL to work with my automated pie graphs:</p>
<p>1) Dumping a table with the column names on the top row.</p>
<p>2) Having the <strong><span style="text-decoration: underline;">root</span></strong> user perform these tasks without placing the MySQL password in the cronjob.</p>
<p>3) Dumping the data to the same location through a cronjob.</p>
<p><strong>Dumping the table with column names:</strong></p>
<p>Dumping a CSV file is easy to do, and can be accomplished using a simple MySQL query or by using the <strong>mysqldump </strong>utility. I figured I&#8217;d start with the mysqldump utility since I didn&#8217;t want to store my password in a cronjob (which was fixed later.) I wanted the column names to be on the first row in order to have R know the table information.  I had a line working with mysqldump that would dump the data to CSV, but couldn&#8217;t get the column names included in the first line. Mysqldump will not dump a CSV file with the column names in the first row.</p>
<p>I ended up using a cronned MySQL query that dumps a CSV file. There are many different examples of this syntax online, but fewer for dumping the columns as well (specifics shortened up:)</p>
<blockquote><p>mysql -u root -e &#8220;SELECT &#8216;id&#8217;,'title&#8217;,'url&#8217;,'section&#8217; UNION SELECT id,title,url,section INTO OUTFILE &#8216;/tmp/result.csv&#8217; FIELDS TERMINATED BY &#8216;,&#8217; OPTIONALLY ENCLOSED BY &#8216;\&#8221;&#8216; ESCAPED BY &#8216;\\\\&#8217; LINES TERMINATED BY &#8216;\n&#8217; FROM db.table;&#8221;</p></blockquote>
<p>The part before the &#8220;UNION SELECT&#8221; will specify the first row that gets sent to the file; these are your headers. I have a small amount of information to dump to the file, so I hard-coded the column names.</p>
<p><strong>Saving the user password to a configuration file</strong></p>
<p>Having the correct SELECT query didn&#8217;t help, because I didn&#8217;t want to put my password in the plaintext of the cronjob. StackOverflow came to the rescue, and a few minutes later I had a configuration file for the MySQL user:</p>
<p><a href="http://serverfault.com/questions/56341/mysqldump-prompting-for-password-in-shellscript/56345#56345">http://serverfault.com/questions/56341/mysqldump-prompting-for-password-in-shellscript/56345#56345</a></p>
<p>User <a title="Zoredache" href="http://serverfault.com/users/984/zoredache" target="_blank">Zoredache</a> explains the reason behind doing this perfectly by saing, &#8220;&#8230;having it in the command line [would allow] anyone who can run ps find the password for your server.&#8221; After creating this file, a simple &#8220;chmod 600&#8243; ensured that the contents of the file would remain secured.</p>
<p><strong>Dumping the data to the same location nightly and OUTFILE syntax</strong></p>
<p>I thought I&#8217;d change the path to something other than /tmp before realizing the MySQL needs permission to write to the directory. After getting the query correct, I ran it. My intentions were to have this run each night (or week, or month) and have the previous file overwritten. The OUTFILE syntax doesn&#8217;t allow for the overwriting of files though:</p>
<blockquote><p><a name="id2308901"></a>The <code>SELECT ... INTO OUTFILE '<em><code>file_name</code></em>'</code> form of <a title="12.2.8. SELECT Syntax" href="http://dev.mysql.com/doc/refman/5.0/en/select.html"><code>SELECT</code></a> writes the selected rows to a file. The file is created on the server host, so you must have the <a href="http://dev.mysql.com/doc/refman/5.0/en/privileges-provided.html#priv_file"><code>FILE</code></a> privilege to use this syntax. <em><code>file_name</code></em>cannot be an existing file, which among other things prevents files such as <code>/etc/passwd</code> and database tables from being destroyed. (<a href="http://dev.mysql.com/doc/refman/5.0/en/select.html">http://dev.mysql.com/doc/refman/5.0/en/select.html</a>)</p></blockquote>
<p>This one was simple: I added a cronjob that would “rm” the old CSV file once the R script finished.</p>
<p>Finish the rest of the post at: <a title="Using R to Automatically Generate Pie Charts" href="http://www.Schwertly.com/2011/02/using-r-to-automatically-generate-pie-charts/" target="_blank">Using R to Automatically Generate Pie Charts</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.Schwertly.com/2011/02/dumping-data-saving-passwords-and-outfile-syntax-with-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Object Caching 601/645 objects using disk: basic

Served from: www.schwertly.com @ 2013-05-24 06:00:25 -->