<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Tech Space</title>
	
	<link>http://tech0x20.com</link>
	<description>Experiencing Tech as a Professional Techie</description>
	<lastBuildDate>Fri, 27 Jan 2012 19:54:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/tech0x20/KpJL" /><feedburner:info uri="tech0x20/kpjl" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>Shell / awk script to generate getter / setter stubs for .java file</title>
		<link>http://feedproxy.google.com/~r/tech0x20/KpJL/~3/U8ctrCE6SE0/</link>
		<comments>http://tech0x20.com/2012/01/27/shell-awk-script-to-generate-getter-setter-stubs-for-java-file/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 19:54:41 +0000</pubDate>
		<dc:creator>Thomas Powell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tech0x20.com/?p=898</guid>
		<description><![CDATA[I realize many IDEs do this, but I felt like writing a few lines of script to spit this out instead. This will grab every line marked &#8220;private&#8221;, whether method or member variable and generates a default getter/setter. Note: it doesn&#8217;t insert the code for you or even capture to a file. Maybe next I&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<p>I realize many IDEs do this, but I felt like writing a few lines of script to spit this out instead. This will grab every line marked &#8220;private&#8221;, whether method or member variable and generates a default getter/setter.</p>
<p>Note: it doesn&#8217;t insert the code for you or even capture to a file. Maybe next I&#8217;ll do a Javascript version.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Date</span> businessDate<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> eventTypeCode<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> sourceCode<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// becomes the following</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Date</span> getBusinessDate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
		<span style="color: #000000; font-weight: bold;">return</span> businessDate<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setBusinessDate<span style="color: #009900;">&#40;</span><span style="color: #003399;">Date</span> businessDate<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">businessDate</span> <span style="color: #339933;">=</span> businessDate<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getEventTypeCode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
		<span style="color: #000000; font-weight: bold;">return</span> eventTypeCode<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setEventTypeCode<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> eventTypeCode<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">eventTypeCode</span> <span style="color: #339933;">=</span> eventTypeCode<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getSourceCode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
		<span style="color: #000000; font-weight: bold;">return</span> sourceCode<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setSourceCode<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> sourceCode<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">sourceCode</span> <span style="color: #339933;">=</span> sourceCode<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Script source:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/env sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># takes a single filename of a .java file and generates a default getter/setter stub for each private variable</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> private <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{
	varName=substr($3, 1, length($3) - 1);
	print &quot;	public &quot; $2 &quot; get&quot; toupper(substr(varName,1,1)) substr(varName, 2) &quot;(){ &quot;;
	print &quot;		return &quot; varName &quot;;&quot;;
	print &quot;	}&quot;
&nbsp;
	print &quot;	public void set&quot; toupper(substr(varName,1,1)) substr(varName, 2) &quot;(&quot; $2 &quot; &quot; varName &quot;){ &quot;;
	print &quot;		this.&quot; varName &quot; = &quot; varName &quot;;&quot;;
	print &quot;	}&quot;
}'</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/tech0x20/KpJL/~4/U8ctrCE6SE0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tech0x20.com/2012/01/27/shell-awk-script-to-generate-getter-setter-stubs-for-java-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tech0x20.com/2012/01/27/shell-awk-script-to-generate-getter-setter-stubs-for-java-file/</feedburner:origLink></item>
		<item>
		<title>Trying to Dig a Little More In-Depth With Maven</title>
		<link>http://feedproxy.google.com/~r/tech0x20/KpJL/~3/bN0qP03NO9M/</link>
		<comments>http://tech0x20.com/2012/01/16/trying-to-dig-a-little-more-in-depth-with-maven/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 02:46:31 +0000</pubDate>
		<dc:creator>Thomas Powell</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://tech0x20.com/?p=889</guid>
		<description><![CDATA[I&#8217;ve been reading Maven: The Definitive Guide (affiliate link) as a Kindle eBook and finally got to the point of trying the first example project. The book had mentioned that maven might be installed on Mac OS X already (due to usage with some versions of XCode). Magically, it&#8217;s there: So far, I like the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been reading <a href="http://amzn.to/xWe8d0">Maven: The Definitive Guide</a> (affiliate link) as a Kindle eBook and finally got to the point of trying the first example project. The book had mentioned that maven might be installed on Mac OS X already (due to usage with some versions of XCode). Magically, it&#8217;s there:</p>
<p><a href="http://tech0x20.com/wp-content/uploads/2012/01/Screen-shot-2012-01-16-at-9.36.54-PM.png"><img class="size-full wp-image-890 alignnone" title="Screen shot 2012-01-16 at 9.36.54 PM" src="http://tech0x20.com/wp-content/uploads/2012/01/Screen-shot-2012-01-16-at-9.36.54-PM.png" alt="" width="563" height="108" /></a></p>
<p>So far, I like the book&#8217;s approach to Maven.  It evangelizes maven as a tool, but puts the purpose of Maven in context, and explains, &#8220;Why Maven?&#8221; as well as explaining that &#8220;Maven or Ant?&#8221; is the wrong question.</p>
<p>If you&#8217;re looking to download the files to complete the example Maven projects, they&#8217;ve moved from the URLs in the Kindle version of the book because Maven: The Definitive Guide has been <a href="http://www.sonatype.com/people/2010/01/maven-the-definitive-guide-split-into-two-books/" target="_blank">split into two books</a>, <em>Maven by Example</em> and <em>Maven: The Complete Reference</em>.</p>
<p>All the project examples can still be downloaded from a <a href="http://www.sonatype.com/books/mvnex-book/mvnex-examples.zip" target="_blank">single zip file</a> from the <em>Maven by Example</em> book. However, the chapter numbers are not the same in the <em>Maven by Example</em> book, and the folders in the examples are named by a chap-{title} convention.</p>
<p>Within the zip file:</p>
<ul>
<li>Chapter 4&#8242;s project (Simple Weather Application) (originally at http://www.sonatype.com/book/mvn-examples-1.0.zip or http://www.sonatype.com/book/mvn-examples-1.0.tar.gz) is now available in the zip file under:</li>
<ul>
<li>ch-custom/simple-weather</li>
</ul>
<li>Chapter 5&#8242;s project (Simple Web Application)</li>
<ul>
<li>ch-simple-web/simple-webapp</li>
</ul>
</ul>
<div></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/tech0x20/KpJL/~4/bN0qP03NO9M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tech0x20.com/2012/01/16/trying-to-dig-a-little-more-in-depth-with-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tech0x20.com/2012/01/16/trying-to-dig-a-little-more-in-depth-with-maven/</feedburner:origLink></item>
		<item>
		<title>Updated…  Add Bookmarklets to Mobile Safari for iPhone / iPad</title>
		<link>http://feedproxy.google.com/~r/tech0x20/KpJL/~3/XghYLuD9MFE/</link>
		<comments>http://tech0x20.com/2011/11/21/add-bookmarklets-to-mobile-safari-for-iphone-ipad/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 15:13:15 +0000</pubDate>
		<dc:creator>Thomas Powell</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[iphone bookmarklet javascript]]></category>

		<guid isPermaLink="false">http://tech0x20.com/?p=877</guid>
		<description><![CDATA[Today&#8217;s iPhone has a nice article on adding bookmarklets to mobile Safari: TiPs &#38; Tricks: Add bookmarklets to mobile Safari However, with iOS5, I found that the steps are a little more convoluted: Add a dummy bookmark using the [-&#62;] button in the middle of Safari Copy the code for the bookmarklet Tap the Bookmark [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s iPhone has a nice article on adding bookmarklets to mobile Safari:<br />
<a href="http://www.todaysiphone.com/2010/07/tips-tricks-add-bookmarklets-to-mobile-safari/" target="_blank">TiPs &amp; Tricks: Add bookmarklets to mobile Safari</a></p>
<p>However, with iOS5, I found that the steps are a little more convoluted:</p>
<ol>
<li>Add a dummy bookmark using the [-&gt;] button in the middle of Safari</li>
<li>Copy the code for the bookmarklet</li>
<li>Tap the Bookmark button (second from the right in Safari).</li>
<li>Tap the [Edit] button</li>
<li>Tap on the dummy bookmark you created</li>
<li>(x) out the URL on the second line</li>
<li>Paste the bookmarklet code on the second line.</li>
<li>(x) out the title and name the bookmarklet appropriately</li>
<li>Tap [Done] when finished.</li>
</ol>
<p><strong>UPDATED 01/27/2012 bufferapp has</strong> <a href="http://bufferapp.com/guides/ios/bookmarklet" target="_blank">new code</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span><span style="color: #009900;">&#40;</span>location.<span style="color: #660066;">href</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'bufferapp://?u='</span><span style="color: #339933;">+</span>encodeURIComponent<span style="color: #009900;">&#40;</span>location.<span style="color: #660066;">href</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p><del datetime="2012-01-27T14:08:26+00:00">I also found that the Buffer code was missing, so I captured it and posted it below:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
var<span style="color: #339933;">%</span>20a<span style="color: #339933;">=</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'head'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
b<span style="color: #339933;">=</span>document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
b.<span style="color: #660066;">type</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'text/javascript'</span><span style="color: #339933;">;</span>
b.<span style="color: #660066;">src</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'http://bufferapp.com/js/bookmarklet.v1.js?'</span>
<span style="color: #339933;">+</span>Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #CC0000;">99999</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
a.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>void<span style="color: #339933;">%</span>200</pre></div></div>

<p></del></p>
<img src="http://feeds.feedburner.com/~r/tech0x20/KpJL/~4/XghYLuD9MFE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tech0x20.com/2011/11/21/add-bookmarklets-to-mobile-safari-for-iphone-ipad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tech0x20.com/2011/11/21/add-bookmarklets-to-mobile-safari-for-iphone-ipad/</feedburner:origLink></item>
		<item>
		<title>Getting an RSS feed of a user’s Twitter timeline</title>
		<link>http://feedproxy.google.com/~r/tech0x20/KpJL/~3/Zhu3AEnmhQI/</link>
		<comments>http://tech0x20.com/2011/11/12/getting-an-rss-feed-of-a-users-twitter-timeline/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 12:50:11 +0000</pubDate>
		<dc:creator>Thomas Powell</dc:creator>
				<category><![CDATA[twitter]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://tech0x20.com/?p=875</guid>
		<description><![CDATA[I like to keep a few Twitter feeds in my RSS reader, but can never remember how to get them from Twitter. I found &#8220;Creating an RSS feed of a users Twitter timeline&#8220;&#8230; However, I found there is a simpler method (for now)&#8211;replace USERNAME with the twitter name. This probably fails when a user changes [...]]]></description>
			<content:encoded><![CDATA[<p>I like to keep a few Twitter feeds in my RSS reader, but can never remember how to get them from Twitter.</p>
<p>I found &#8220;<a href="http://socialirl.com/socialirlblog/creating-an-rss-feed-of-a-users-twitter-timeline/" target="_blank">Creating an RSS feed of a users Twitter timeline</a>&#8220;&#8230;</p>
<p>However, I found there is a simpler method (for now)&#8211;replace USERNAME with the twitter name. This probably fails when a user changes names, but for stable usernames, this seems to work:</p>
<p>http://twitter.com/statuses/user_timeline/USERNAME.rss</p>
<img src="http://feeds.feedburner.com/~r/tech0x20/KpJL/~4/Zhu3AEnmhQI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tech0x20.com/2011/11/12/getting-an-rss-feed-of-a-users-twitter-timeline/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tech0x20.com/2011/11/12/getting-an-rss-feed-of-a-users-twitter-timeline/</feedburner:origLink></item>
		<item>
		<title>perl script to generate a list of Julian day/day of year dates, given start and end.</title>
		<link>http://feedproxy.google.com/~r/tech0x20/KpJL/~3/ZXjZ7ZX7IG8/</link>
		<comments>http://tech0x20.com/2011/09/24/perl-script-to-generate-a-list-of-julian-dayday-of-year-dates-given-start-and-end/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 23:18:07 +0000</pubDate>
		<dc:creator>Thomas Powell</dc:creator>
				<category><![CDATA[unix]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://tech0x20.com/?p=870</guid>
		<description><![CDATA[I discovered myself on a unix system with a &#8216;date&#8217; utility that only accepts the -u and + parameters, a fairly basic perl install, and lots of archives that are listed by the &#8220;Julian day&#8221; (day of year) date. I put together a perl script using the functions I had at my disposal. The script [...]]]></description>
			<content:encoded><![CDATA[<p>I discovered myself on a unix system with a <a href="http://en.wikipedia.org/wiki/Date_%28Unix%29" target="_blank">&#8216;date&#8217; utility</a> that only accepts the -u and + parameters, a fairly basic perl install, and lots of archives that are listed by the &#8220;Julian day&#8221; (day of year) date.</p>
<p>I put together a perl script using the functions I had at my disposal. The script below makes some allowance for a few different formats, but not nearly as much as <a href="http://search.cpan.org/~sbeck/Date-Manip-6.25/lib/Date/Manip.pod" target="_blank">Date::Manip</a> would have given me. Feedback appreciated.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> Time<span style="color: #339933;">::</span><span style="color: #006600;">Local</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Getopt<span style="color: #339933;">::</span><span style="color: #006600;">Long</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> getJJJFromParameter
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dateString</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span> 
	<span style="color: #b1b100;">our</span> <span style="color: #0000ff;">$mm</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">our</span> <span style="color: #0000ff;">$dd</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">our</span> <span style="color: #0000ff;">$yyyy</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$dateString</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/\d{1,2}\/\d{1,2}\/\d{2,4}/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$mm</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$dd</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$yyyy</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\//</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$dateString</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$dateString</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/\d{2,4}-\d{1,2}-\d{1,2}/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$yyyy</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$mm</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$dd</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/-/</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$dateString</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$dateString</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/\d{1,2}-\d{1,2}-\d{2,4}/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$mm</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$dd</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$yyyy</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/-/</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$dateString</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #0000ff;">$yyyy</span> <span style="color: #339933;">%=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$yyyy</span> <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@dt</span> <span style="color: #339933;">=</span> <span style="color: #000066;">localtime</span><span style="color: #009900;">&#40;</span>timelocal<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$dd</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$mm</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$yyyy</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066;">return</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$dt</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">7</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># main script</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$startDate</span><span style="color: #339933;">=</span><span style="color: #ff0000;">''</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$endDate</span><span style="color: #339933;">=</span><span style="color: #ff0000;">''</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$startJJJ</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$endJJJ</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
GetOptions<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'start=s'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">\$startDate</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'end=s'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">\$endDate</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$startDate</span> <span style="color: #339933;">==</span> <span style="color: #ff0000;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">exit</span><span style="color: #339933;">;</span>	
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #0000ff;">$startJJJ</span> <span style="color: #339933;">=</span> getJJJFromParameter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$startDate</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$endDate</span> <span style="color: #339933;">!=</span> <span style="color: #ff0000;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #0000ff;">$endJJJ</span> <span style="color: #339933;">=</span> getJJJFromParameter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$endDate</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #0000ff;">$endJJJ</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$startJJJ</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$jjj</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">printf</span> <span style="color: #ff0000;">&quot;%03d to %03d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$startJJJ</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$endJJJ</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$jjj</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$startJJJ</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$jjj</span> <span style="color: #339933;">&lt;=</span> <span style="color: #0000ff;">$endJJJ</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$jjj</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%03d &quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$jjj</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/tech0x20/KpJL/~4/ZXjZ7ZX7IG8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tech0x20.com/2011/09/24/perl-script-to-generate-a-list-of-julian-dayday-of-year-dates-given-start-and-end/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tech0x20.com/2011/09/24/perl-script-to-generate-a-list-of-julian-dayday-of-year-dates-given-start-and-end/</feedburner:origLink></item>
		<item>
		<title>This kid knew enough to be dangerous.</title>
		<link>http://feedproxy.google.com/~r/tech0x20/KpJL/~3/UknG3JrN2SQ/</link>
		<comments>http://tech0x20.com/2011/09/03/this-kid-knew-enough-to-be-dangerous/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 13:45:00 +0000</pubDate>
		<dc:creator>Thomas Powell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tech0x20.com/?p=861</guid>
		<description><![CDATA[Running this old code, which was probably not actually turned in for anything, through the gcc compiler alone showed that there was a glaring error that would have been exposed on the the first run. Beyond the initial compiler warnings, there are the ALL CAPS variables, the while loops used as pure for loops&#8230; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Running this old code, which was probably not actually turned in for anything, through the gcc compiler alone showed that there was a glaring error that would have been exposed on the the first run.</p>
<p>Beyond the initial compiler warnings, there are the ALL CAPS variables, the while loops used as pure for loops&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">&nbsp;
<span style="color: #339933;">#include &quot;stdio.h&quot;</span>
main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #993333;">int</span> rows<span style="color: #339933;">,</span>columns<span style="color: #339933;">,</span>ROW<span style="color: #339933;">,</span> COLUMN<span style="color: #339933;">;</span>
    scanf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d %d&quot;</span><span style="color: #339933;">,</span>ROW<span style="color: #339933;">,</span>COLUMN<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    rows <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    columns <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>columns<span style="color: #339933;">++</span> <span style="color: #339933;">&lt;</span> COLUMN<span style="color: #009900;">&#41;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #660099; font-weight: bold;">\xdb</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    rows <span style="color: #339933;">+=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>rows<span style="color: #339933;">++</span> <span style="color: #339933;">&lt;</span> <span style="color: #009900;">&#40;</span>ROW <span style="color: #339933;">-</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        columns <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #660099; font-weight: bold;">\xdb</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>columns<span style="color: #339933;">++</span> <span style="color: #339933;">&lt;</span> <span style="color: #009900;">&#40;</span>COLUMN <span style="color: #339933;">-</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #660099; font-weight: bold;">\xdb</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    columns <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>columns<span style="color: #339933;">++</span> <span style="color: #339933;">&lt;</span> COLUMN<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #660099; font-weight: bold;">\xdb</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/tech0x20/KpJL/~4/UknG3JrN2SQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tech0x20.com/2011/09/03/this-kid-knew-enough-to-be-dangerous/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tech0x20.com/2011/09/03/this-kid-knew-enough-to-be-dangerous/</feedburner:origLink></item>
		<item>
		<title>Searching for a String in Environmental Variables in Powershell</title>
		<link>http://feedproxy.google.com/~r/tech0x20/KpJL/~3/apyVTJJnYt4/</link>
		<comments>http://tech0x20.com/2011/06/28/searching-for-a-string-in-environmental-variables-in-powershell/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 01:25:49 +0000</pubDate>
		<dc:creator>Thomas Powell</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://tech0x20.com/?p=813</guid>
		<description><![CDATA[I&#8217;ve updated the post through feedback in the comments: Regex compare on strings for Get-Variable is Where-Object -Match. So, the closest parallel to the following bash code: set &#124; grep &#34;Users&#34; is the following Powershell: Get-Variable &#124; Where-Object &#123; $_.Value -Match &#34;Users&#34; &#125; or shortened: gv &#124; ? &#123;$_.Value -Match &#34;Users&#34;&#125; Original Post, with Updates [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve updated the post through feedback in the comments:<br />
Regex compare on strings for Get-Variable is Where-Object -Match.</p>
<p>So, the closest parallel to the following bash code:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">set</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;Users&quot;</span></pre></div></div>

<p>is the following Powershell:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-Variable</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Where-Object</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.Value <span style="color: #FF0000;">-Match</span> <span style="color: #800000;">&quot;Users&quot;</span> <span style="color: #000000;">&#125;</span></pre></div></div>

<p>or shortened:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">gv</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Value <span style="color: #FF0000;">-Match</span> <span style="color: #800000;">&quot;Users&quot;</span><span style="color: #000000;">&#125;</span></pre></div></div>

<hr />
<strong>Original Post, with Updates</strong><br />
I&#8217;m kind of dumbfounded how this:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-Variable</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select-String</span> <span style="color: #008080; font-style: italic;">-Pattern</span> <span style="color: #800000;">&quot;Users&quot;</span></pre></div></div>

<p>returns nothing.</p>
<p>Yet,</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-Variable</span> <span style="color: pink;">&gt;</span> <span style="color: #008080; font-weight: bold;">gv</span>.txt
<span style="color: #008080; font-weight: bold;">Get-Content</span> <span style="color: #008080; font-weight: bold;">gv</span>.txt <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select-String</span> <span style="color: #008080; font-style: italic;">-Pattern</span> <span style="color: #800000;">&quot;Users&quot;</span></pre></div></div>

<p>returns:</p>
<pre>$                              Users
HOME                           C:\Users\Administrator
PWD                            C:\Users\Administrator</pre>
<p>My initial thought was that maybe redirect captures standard output and standard error and the pipe doesn&#8217;t, but then, standard error should all come to the screen unfiltered if not captured by the pipe.</p>
<p><strong>Added:</strong><br />
To add insult to injury, apparently</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-Variable</span> <span style="color: #008080; font-style: italic;">-Include</span> <span style="color: #800000;">&quot;PS*&quot;</span></pre></div></div>

<p>or just</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-Variable</span> <span style="color: #800000;">&quot;PS*&quot;</span></pre></div></div>

<p>will do a wildcard search for <strong>variable names</strong>.</p>
<p><strong>Updated, per the comment from <a href="http://twitter.com/#/jburger">@jburger</a></strong></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-Variable</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Where-Object</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.Value <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$null</span> <span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Where-Object</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.Contains<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Users&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span></pre></div></div>

<p>or</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">gv</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.Value <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$null</span> <span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Value.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.Contains<span style="color: #000000;">&#40;</span>“Users”<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span></pre></div></div>

<p>Playing with the Where-Object syntax, I was able to reduce this to:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-Variable</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Where-Object</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.Value <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$null</span> <span style="color: #FF0000;">-and</span> <span style="color: #000080;">$_</span>.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.Contains<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Users&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span></pre></div></div>

<p>or</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">gv</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.Value <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$null</span>  <span style="color: #FF0000;">-and</span> <span style="color: #000080;">$_</span>.Value.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.Contains<span style="color: #000000;">&#40;</span>“Users”<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span></pre></div></div>

<p>Definitely, this does the trick. However, I&#8217;m disappointed that PowerShell doesn&#8217;t automatically cast the object output using a ToString() operation.</p>
<img src="http://feeds.feedburner.com/~r/tech0x20/KpJL/~4/apyVTJJnYt4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tech0x20.com/2011/06/28/searching-for-a-string-in-environmental-variables-in-powershell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://tech0x20.com/2011/06/28/searching-for-a-string-in-environmental-variables-in-powershell/</feedburner:origLink></item>
		<item>
		<title>Entropy of iPhone headphone cables (an excuse to experiment with WP-LaTeX)</title>
		<link>http://feedproxy.google.com/~r/tech0x20/KpJL/~3/DfktzVbn3ps/</link>
		<comments>http://tech0x20.com/2011/06/02/entropy-of-iphone-headphone-cables-an-excuse-to-experiment-with-wp-latex/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 13:56:02 +0000</pubDate>
		<dc:creator>Thomas Powell</dc:creator>
				<category><![CDATA[geek humor]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[thermodynamics]]></category>

		<guid isPermaLink="false">http://tech0x20.com/?p=799</guid>
		<description><![CDATA[Why is it that iPhone earbuds seem to tangle with so many more hopeless tangles than any other cables? Of course, this whole exercise was an excuse to play with LaTeX and the WP-LaTeX plugin. I also managed to find a nice LaTeX cheat sheet in the process.]]></description>
			<content:encoded><![CDATA[<p>Why is it that iPhone earbuds seem to tangle with so many more hopeless tangles than any other cables?<br />
<img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%20%5Cfrac%7BdS_%7BiPhoneCable%7D%7D%7Bdt%7D%20%5Cgg%20%20%5Cfrac%7BdS_%7BgenericCables%7D%7D%7Bdt%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\displaystyle \frac{dS_{iPhoneCable}}{dt} \gg  \frac{dS_{genericCables}}{dt}' title='\displaystyle \frac{dS_{iPhoneCable}}{dt} \gg  \frac{dS_{genericCables}}{dt}' class='latex' /></p>
<p>Of course, this whole exercise was an excuse to play with <a href="http://en.wikipedia.org/wiki/LaTeX" target="_blank">LaTeX</a> and the <a href="http://wordpress.org/extend/plugins/wp-latex/" target="_blank">WP-LaTeX plugin</a>.</p>
<p>I also managed to find a nice <a href="http://amath.colorado.edu/documentation/LaTeX/Symbols.pdf" target="_blank">LaTeX cheat sheet</a> in the process.</p>
<img src="http://feeds.feedburner.com/~r/tech0x20/KpJL/~4/DfktzVbn3ps" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tech0x20.com/2011/06/02/entropy-of-iphone-headphone-cables-an-excuse-to-experiment-with-wp-latex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tech0x20.com/2011/06/02/entropy-of-iphone-headphone-cables-an-excuse-to-experiment-with-wp-latex/</feedburner:origLink></item>
		<item>
		<title>Using Escape Codes and Setting Window Title on PS1 for ksh (Korn Shell)</title>
		<link>http://feedproxy.google.com/~r/tech0x20/KpJL/~3/g4gKbc4HPEU/</link>
		<comments>http://tech0x20.com/2011/05/10/using-escape-codes-and-setting-window-title-on-ps1-for-ksh-korn-shell/#comments</comments>
		<pubDate>Tue, 10 May 2011 19:51:28 +0000</pubDate>
		<dc:creator>Thomas Powell</dc:creator>
				<category><![CDATA[Rediscovering Unix]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[korn shell]]></category>
		<category><![CDATA[ksh]]></category>
		<category><![CDATA[ps1]]></category>

		<guid isPermaLink="false">http://tech0x20.com/?p=785</guid>
		<description><![CDATA[I set up the following in my ~/.profile for my ksh login: export HOST=$&#40;hostname&#41; &#160; export PS1=$&#40;perl -e 'printf &#34;\033]0;\${USER}@\${HOST}:\${PWD}\007\$&#34;'&#41; Unfortunately, ksh doesn&#8217;t understand escape codes, so perl or awk is necessary to pull this off&#8211;or you can enter them literally via your editor. I like the perl route just for ease of maintenance. This [...]]]></description>
			<content:encoded><![CDATA[<p>I set up the following in my ~/.profile for my ksh login:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HOST</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">hostname</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PS1</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'printf &quot;\033]0;\${USER}@\${HOST}:\${PWD}\007\$&quot;'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Unfortunately, ksh doesn&#8217;t understand escape codes, so perl or awk is necessary to pull this off&#8211;or you can enter them literally via your editor. I like the perl route just for ease of maintenance.</p>
<p>This was inspired by: <a href="http://groups.google.com/group/mintty-discuss/browse_thread/thread/8f6ff94bad994654?pli=1" target="_blank">Setting window title via escape sequences</a>. Of course, the bash version is *much* simpler:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PS1</span>=<span style="color: #ff0000;">&quot;\e]2;<span style="color: #007800;">${USER}</span>@<span style="color: #007800;">${HOSTNAME}</span>: <span style="color: #007800;">${PWD}</span>\a&quot;</span></pre></div></div>

<p>Other links of interest:</p>
<ul>
<li><a href="http://tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html" target="_blank">Bash Prompt Escape Sequences</a></li>
<li><a href="http://cygwin.com/ml/cygwin/2005-11/msg00660.html" target="_blank">Escape Codes in ksh</a></li>
<li><a href="http://www.cyberciti.biz/faq/unix-linux-korn-shell-variables/" target="_blank">Korn Shell Variables</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/tech0x20/KpJL/~4/g4gKbc4HPEU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tech0x20.com/2011/05/10/using-escape-codes-and-setting-window-title-on-ps1-for-ksh-korn-shell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tech0x20.com/2011/05/10/using-escape-codes-and-setting-window-title-on-ps1-for-ksh-korn-shell/</feedburner:origLink></item>
		<item>
		<title>Count Outlook Inbox Unread / Total From Ruby</title>
		<link>http://feedproxy.google.com/~r/tech0x20/KpJL/~3/j69xVIP8UhI/</link>
		<comments>http://tech0x20.com/2011/04/05/count-outlook-inbox-unread-total-from-ruby/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 14:39:38 +0000</pubDate>
		<dc:creator>Thomas Powell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tech0x20.com/?p=780</guid>
		<description><![CDATA[Well, Track your unread items/total items count in Outlook on startup, except for the pesky Outlook Macro disabled security problem. Besides, I never restarted Outlook often enough for it to track much of anything. Instead, I decided to create a Ruby script to track the count. I&#8217;ve left reference URLs and test notes in place [...]]]></description>
			<content:encoded><![CDATA[<p>Well, <a rel="bookmark" href="/2011/03/10/track-your-unread-itemstotal-items-count-in-outlook-on-startup/">Track your unread items/total items count in Outlook on startup</a>, except for the pesky Outlook Macro disabled security problem.  Besides, I never restarted Outlook often enough for it to track much of anything.</p>
<p>Instead, I decided to create a Ruby script to track the count. I&#8217;ve left reference URLs and test notes in place in this script. Yes, I had to look up how to write a file in Ruby&#8230;  It&#8217;s essentially my 4th programming language after C, Java, Perl, PHP&#8230;  okay&#8230; let&#8217;s say it&#8217;s pretty deep on the list.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'win32ole'</span>
outlook = WIN32OLE.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Outlook.Application'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#008000; font-style:italic;"># http://rubyonwindows.blogspot.com/2007/07/automating-outlook-with-ruby-tasks.html</span>
mapi = outlook.<span style="color:#9900CC;">GetNameSpace</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'MAPI'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#008000; font-style:italic;"># http://msdn.microsoft.com/en-us/library/aa220100%28office.11%29.aspx</span>
<span style="color:#008000; font-style:italic;"># olFolderCalendar</span>
<span style="color:#008000; font-style:italic;"># olFolderContacts</span>
<span style="color:#008000; font-style:italic;"># olFolderDeletedItems</span>
<span style="color:#008000; font-style:italic;"># olFolderDrafts</span>
<span style="color:#008000; font-style:italic;"># olFolderInbox</span>
<span style="color:#008000; font-style:italic;"># olFolderJournal</span>
<span style="color:#008000; font-style:italic;"># olFolderJunk</span>
<span style="color:#008000; font-style:italic;"># olFolderNotes</span>
<span style="color:#008000; font-style:italic;"># olFolderOutbox</span>
<span style="color:#008000; font-style:italic;"># olFolderSentMail</span>
<span style="color:#008000; font-style:italic;"># olFolderTasks</span>
<span style="color:#008000; font-style:italic;"># olPublicFoldersAllPublicFolders</span>
<span style="color:#008000; font-style:italic;"># olFolderConflicts</span>
<span style="color:#008000; font-style:italic;"># olFolderLocalFailures</span>
<span style="color:#008000; font-style:italic;"># olFolderServerFailures</span>
<span style="color:#008000; font-style:italic;"># olFolderSyncIssues</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># http://msdn.microsoft.com/en-us/library/aa210918%28v=office.11%29.aspx</span>
<span style="color:#008000; font-style:italic;"># OLEObject.ole_methods</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> OutlookConst
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#008000; font-style:italic;"># http://rubyonwindows.blogspot.com/search/label/outlook</span>
WIN32OLE.<span style="color:#9900CC;">const_load</span><span style="color:#006600; font-weight:bold;">&#40;</span>outlook, OutlookConst<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># p &quot;OlFolderInbox = #{OutlookConst::OlFolderInbox}&quot;</span>
&nbsp;
inbox = mapi.<span style="color:#9900CC;">GetDefaultFolder</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#6666ff; font-weight:bold;">OutlookConst::OlFolderInbox</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
new_messages = <span style="color:#006666;">0</span>
total_messages = <span style="color:#006666;">0</span>
&nbsp;
inbox.<span style="color:#9900CC;">Items</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
	<span style="color:#006600; font-weight:bold;">|</span> msg <span style="color:#006600; font-weight:bold;">|</span>
	<span style="color:#9966CC; font-weight:bold;">begin</span> 
		<span style="color:#9966CC; font-weight:bold;">if</span> msg<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'UnRead'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
			new_messages <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#006666;">1</span>
		<span style="color:#9966CC; font-weight:bold;">end</span>
		total_messages <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#006666;">1</span>
	<span style="color:#9966CC; font-weight:bold;">rescue</span>
		<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot; Unable to open&quot;</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;You have #{new_messages} new message(s)&quot;</span>
t = <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span>
&nbsp;
line=<span style="color:#996600;">&quot;#{t.strftime(&quot;</span><span style="color:#006600; font-weight:bold;">%</span>m<span style="color:#006600; font-weight:bold;">/%</span>d<span style="color:#006600; font-weight:bold;">/%</span>Y <span style="color:#006600; font-weight:bold;">%</span>I:<span style="color:#006600; font-weight:bold;">%</span>M:<span style="color:#006600; font-weight:bold;">%</span>S <span style="color:#006600; font-weight:bold;">%</span><span style="color:#CC0066; font-weight:bold;">p</span><span style="color:#996600;">&quot;)},#{new_messages},#{total_messages}&quot;</span>
&nbsp;
localname=<span style="color:#996600;">&quot;#{ENV['USERPROFILE']}<span style="color:#000099;">\\</span>My Documents<span style="color:#000099;">\\</span>outlookunread.csv&quot;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># http://snippets.dzone.com/posts/show/5051</span>
<span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>localname, <span style="color:#996600;">'a'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> f.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span>line<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/tech0x20/KpJL/~4/j69xVIP8UhI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tech0x20.com/2011/04/05/count-outlook-inbox-unread-total-from-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tech0x20.com/2011/04/05/count-outlook-inbox-unread-total-from-ruby/</feedburner:origLink></item>
	</channel>
</rss>

