<?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>Eric Anderson's Blog</title>
	<atom:link href="http://ericanderson.us/feed/" rel="self" type="application/rss+xml" />
	<link>http://ericanderson.us</link>
	<description></description>
	<lastBuildDate>Sat, 05 Sep 2009 07:12:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to play Turbo Hearts</title>
		<link>http://ericanderson.us/2009/09/04/how-to-play-turbo-hearts/</link>
		<comments>http://ericanderson.us/2009/09/04/how-to-play-turbo-hearts/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 18:05:26 +0000</pubDate>
		<dc:creator>Eric Anderson</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[turbohearts]]></category>

		<guid isPermaLink="false">http://ericanderson.us/?p=54</guid>
		<description><![CDATA[The game is a slight variation on regular Hearts, with a few cards having extra meaning, the possibility for a trick to go around twice, and &#8220;special&#8221; cards being &#8220;charged&#8221; (doubling their value). In Turbo Hearts, points are bad.
In Turbo Hearts, the 10&#9827; doubles your score final score, the J&#9830; gives you -10 points (good), [...]]]></description>
			<content:encoded><![CDATA[<p>The game is a slight variation on regular Hearts, with a few cards having extra meaning, the possibility for a trick to go around twice, and &#8220;special&#8221; cards being &#8220;charged&#8221; (doubling their value). In Turbo Hearts, points are bad.</p>
<p>In Turbo Hearts, the <span style="color:green">10&clubs;</span> doubles your score final score, the <span style="color:teal">J&diams;</span> gives you -10 points (good), the Q&spades; is worth 13 points, and each heart is worth 1 point.</p>
<p>&#8220;Running&#8221; is defined as taking the Q&spades; and all of the hearts. This is equivilant to &#8220;shooting the moon&#8221; in regular hearts.</p>
<p>Nines are also special in Turbo Hearts; if they are played in suit, they make a trick go around twice.</p>
<p>Charging is a technique that happens before a hand begins that has a few effects:</p>
<ul>
<li>The charged suite is now worth double. A charged Q&spades; is now worth 26pts, a charged <span style="color:red">A&hearts;</span> makes all hearts worth 2pts, a charged <span style="color:green">10&clubs;</span> is worth 4x your final score, and a charged <span style="color:teal">J&diams;</span> is worth -20pts.</li>
<li>The charged card must be placed face up in front of the player until they play it</li>
<li>There is a caviate to charging a card however, you cannot play a charged card on the first trick in suit unless you are forced to do so. An example: You charge the <span style="color:green">10&clubs;</span> and the only other club you have is the <span style="color:green">9&clubs;</span>. On the first club trick, you cannot play the <span style="color:green">10&clubs;</span> since you have another club, so you play your 9, making the trick go around again. Now, you have to play a second time and since your <span style="color:green">10&clubs;</span> is the only card in suit, you must play that card.</li>
</ul>
<p>The game consists for 4 hands with the flow of the game as follows:</p>
<ol>
<li>Passing &#8211; in order of the 4 hands: 3 left, 3 right, 3 diagonal, no passing.</li>
<li>Charging &#8211; anyone with a chargeable card (<span style="color:green">10&clubs;</span>, Q&spades;, <span style="color:teal">J&diams;</span>, <span style="color:red">A&hearts;</span>) can now charge.</li>
<li>Play starts &#8211; the person with the <span style="color:green">2&clubs;</span> plays first.</li>
<li>Tricks &#8211; gameplay continues until all tricks have been claimed</li>
<li>Scoring &#8211; scoring is tabulated and saved for later; more details below</li>
</ol>
<p>Scoring may be the most complicated part of playing Turbo Hearts but it is really easy once you get the hang of it. Scoring is performed by totally up everyones points, multiplying if they got the <span style="color:green">10&clubs;</span>, making negative if they &#8220;ran&#8221; and totally it up with the previous tricks.</p>
<p>We keep a notebook of scores, with each hand taking a line, the hand total on the left and the cumulative sum on the right. Negatives are wrapped in parens. It looks like this:</p>
<table width="400">
<tr>
<th width="25%">RF</th>
<th width="25%">TW</th>
<th width="25%">KB</th>
<th width="25%">EA</th>
</tr>
<tr>
<td>0 &#8211; 0</td>
<td>0 &#8211; 0</td>
<td>72 &#8211; 72</td>
<td>11 &#8211; 11</td>
</tr>
<tr>
<td>16 &#8211; 16</td>
<td>32 &#8211; 32</td>
<td>(10) &#8211; 62</td>
<td>16 &#8211; 27</td>
</tr>
<tr>
<td>12 &#8211; 18</td>
<td>4 &#8211; 45</td>
<td>16 &#8211; 78</td>
<td>16 &#8211; 43</td>
</tr>
<tr>
<td>0 &#8211; 18</td>
<td>0 &#8211; 45</td>
<td>0 &#8211; 78</td>
<td>(248) &#8211; (205)</td>
</tr>
</table>
<p></p>
<p>These are your hand scores and as you can see, I did really well on the last hand (ran for 248 pts!)</p>
<p>These scores are then kept cumulatively across multiple games and multiple players. Your final game score is calculated by &#8220;paying out&#8221;. What this means, is your total number of points, you must pay to all other players (and they must pay to you). It is good to have a low hand score but the opposite is true for a game score; higher scores are better.</p>
<p>So the final games scores are: </p>
<table>
<tr>
<td width="40px">RF</td>
<td>-18*3 + 35 + 78 &#8211; 205 =</td>
<td>&nbsp;-146</td>
</tr>
<tr>
<td>TW</td>
<td>-35*3 + 18 + 78 &#8211; 205 =</td>
<td>&nbsp;-214</td>
</tr>
<tr>
<td>KB</td>
<td>-78*3 + 18 + 35 &#8211; 205=</td>
<td>&nbsp;-386</td>
</tr>
<tr>
<td>EA</td>
<td>205*3 + 18 + 45 + 78 =</td>
<td>&nbsp;756</td>
</tr>
</table>
<p></p>
<p>We keep these numbers are a long term tally. You can just sum up everyones game scores to see their standings.</p>
<p>The best way to think of these game scores is as pennies. In this game, I would be making $7.56 while the others would be paying out $1.46, $2.14, $3.86 respectively.</p>
<p>In my next post, I will lay out some basic strategy, but now you know how to play.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericanderson.us/2009/09/04/how-to-play-turbo-hearts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Terminal.app TabNamer released under GPL</title>
		<link>http://ericanderson.us/2009/08/29/terminal-app-tabnamer-released-under-gpl/</link>
		<comments>http://ericanderson.us/2009/08/29/terminal-app-tabnamer-released-under-gpl/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 17:46:31 +0000</pubDate>
		<dc:creator>Eric Anderson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ericanderson.us/?p=51</guid>
		<description><![CDATA[Short and sweet, I have no intention of maintaining this code. It seems that snow leopard completely removes the need for it and as such, I am releasing it at github.
TabNamer @ GitHub
]]></description>
			<content:encoded><![CDATA[<p>Short and sweet, I have no intention of maintaining this code. It seems that snow leopard completely removes the need for it and as such, I am releasing it at github.</p>
<p><a href="http://github.com/EricAnderson/Terminal.app-TabNamer/tree/master">TabNamer @ GitHub</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ericanderson.us/2009/08/29/terminal-app-tabnamer-released-under-gpl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Archiving a message via keyboard shortcut in Microsoft Entourage</title>
		<link>http://ericanderson.us/2009/02/27/archiving-a-message-via-keyboard-shortcut-in-microsoft-entourage/</link>
		<comments>http://ericanderson.us/2009/02/27/archiving-a-message-via-keyboard-shortcut-in-microsoft-entourage/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 22:02:02 +0000</pubDate>
		<dc:creator>Eric Anderson</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[OSX]]></category>

		<guid isPermaLink="false">http://ericanderson.us/?p=37</guid>
		<description><![CDATA[This has been driving me nuts for a long time and I finally figured out the applescript for this so I figured I should share.
The script is:

set archiveFolderName to &#34;@Archive&#34;
set exchangeAccount to &#34;My Exchange Email&#34;

tell application &#34;Microsoft Entourage&#34;
	repeat with msg in (get current messages)
		move msg to folder archiveFolderName in Exchange account exchangeAccount
	end repeat
end tell

This script [...]]]></description>
			<content:encoded><![CDATA[<p>This has been driving me nuts for a long time and I finally figured out the applescript for this so I figured I should share.</p>
<p>The script is:</p>
<pre class="brush: text">
set archiveFolderName to &quot;@Archive&quot;
set exchangeAccount to &quot;My Exchange Email&quot;

tell application &quot;Microsoft Entourage&quot;
	repeat with msg in (get current messages)
		move msg to folder archiveFolderName in Exchange account exchangeAccount
	end repeat
end tell
</pre>
<p>This script assumes you have an exchange account and a folder in that exchange account you want to use.</p>
<p>If you want to use an archive folder that is a subfolder of another folder, you&#8217;ll want to tweak the script to say something like &#8220;to folder archiveFolderName in folder parentFolderName in Exchange account exchangeAccount&#8221; and add a parentFolderName variable to the top of the script.</p>
<p>Now all you have to do is save the script in: &#8220;~/Documents/Microsoft User Data/Entourage Script Menu Items/Archive\cA&#8221;</p>
<p>This will put it in your script menu and set the keystroke ctrl+a to &#8220;Archive&#8221;.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://ericanderson.us/2009/02/27/archiving-a-message-via-keyboard-shortcut-in-microsoft-entourage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rant: Using Error Codes in User Messages</title>
		<link>http://ericanderson.us/2008/08/05/using-error-codes-in-user-messages/</link>
		<comments>http://ericanderson.us/2008/08/05/using-error-codes-in-user-messages/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 07:48:48 +0000</pubDate>
		<dc:creator>Eric Anderson</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://ericanderson.us/?p=26</guid>
		<description><![CDATA[In short: DON&#8217;T!
What in the world was Apple thinking when you try to upgrade/register/sync your iPhone/iPod and you get &#8220;Error: -19&#8243; or &#8220;Error: -20&#8243;?? What good does this do any one? How am I supposed to fix the problem if I don&#8217;t know what the problem is? Isn&#8217;t Apple the king of user-friendliness? 
When you [...]]]></description>
			<content:encoded><![CDATA[<p>In short: DON&#8217;T!</p>
<p>What in the world was Apple thinking when you try to upgrade/register/sync your iPhone/iPod and you get &#8220;Error: -19&#8243; or &#8220;Error: -20&#8243;?? What good does this do any one? How am I supposed to fix the problem if I don&#8217;t know what the problem is? Isn&#8217;t Apple the king of user-friendliness? </p>
<p>When you write software, you should use good error messages. You should use good exceptions. You should use descriptive values.</p>
<p>Granted, some things the user cannot fix. Telling the user the database connection was lost on a web application does very little good for the user. You can however tell the user that an error that was not their fault occurred. At least then I know I can come back and try again later.</p>
<p>Luckily, after rebooting my iPhone I was able to install the recent software update. This may not have been the problem, but certainly Apple could have notified me that I should attempt rebooting.</p>
<p>In any case, be nice to your damn users!</p>
]]></content:encoded>
			<wfw:commentRss>http://ericanderson.us/2008/08/05/using-error-codes-in-user-messages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using EclEmma to Write Better Unit Tests</title>
		<link>http://ericanderson.us/2008/05/08/using-eclemma-to-write-better-unit-tests/</link>
		<comments>http://ericanderson.us/2008/05/08/using-eclemma-to-write-better-unit-tests/#comments</comments>
		<pubDate>Thu, 08 May 2008 21:39:27 +0000</pubDate>
		<dc:creator>Eric Anderson</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Unit Test]]></category>

		<guid isPermaLink="false">http://ericanderson.us/?p=19</guid>
		<description><![CDATA[If you don&#8217;t already write unit tests you should be. (Hey, why aren&#8217;t you writing unit tests?) Unit testing has so many benefits and the upfront developer cost to write some unit tests can pay huge dividends later when you aren&#8217;t spending time debugging broken code nor attempting to save face due to clueless mistakes. [...]]]></description>
			<content:encoded><![CDATA[<p>If you don&#8217;t already write unit tests you should be. (Hey, why aren&#8217;t you writing unit tests?) Unit testing has so many benefits and the upfront developer cost to write some unit tests can pay huge dividends later when you aren&#8217;t spending time debugging broken code nor attempting to save face due to clueless mistakes. You can also use them as a contract to the expectations of your implementations. </p>
<p>So, assuming you have some unit tests, how useful are they if they don&#8217;t test everything? At some level you will want to have a good idea that you&#8217;re testing everything. (NOTE: I mean everything really important. Writing perfect 100% coverage like this would likely be too expensive for the entire codebase.) This is where <a href="http://emma.sourceforge.net/">Emma</a> comes in (and more importantly for us, <a href="http://www.eclemma.org/index.html">EclEmma</a>, an Eclipse plugin for Emma). Emma is a code coverage tool which lets you visual which parts of your code get executed during some execution (regular or JUnit).</p>
<p>Lets walk through using EclEmma to ensure that we have adequate testing being done. Lets test the following two classes.<br />
<span id="more-19"></span></p>
<p>GuessTheNumber.java:</p>
<pre class="brush: java">
import java.util.Random;

public class GuessTheNumber {

	private final Integer value;
	private final int min;
	private final int max;
	private int guesses = 0;
	private boolean solved = false;

	public GuessTheNumber(int min, int max, int value) {
		this.min = min;
		this.max = max;
		this.value = value;
	}

	public GuessTheNumber(int min, int max) {
		this(min, max, getRandomNumber(min, max));

	}

	public int guess(int i) {
		if (solved)
			throw new IllegalStateException();

		guesses++;

		int ret = value.compareTo(i);

		if (ret == 0)
			solved = true;

		return ret;
	}

	public void resetCount() {
		guesses = 0;
		solved = false;
	}

	public int getValue() {
		if (solved == false)
			throw new IllegalStateException();

		return value;
	}

	public int getMin() { return min; }
	public int getMax() { return max; }

	private static int getRandomNumber(int min, int max) {
		return new Random().nextInt(max - min + 1) + min;
	}
}
</pre>
<p>And SequentialStrategy.java:</p>
<pre class="brush: java">

public class SequentialStrategy {

	private final GuessTheNumber guesser;

	public SequentialStrategy(GuessTheNumber guesser) {
		this.guesser = guesser;
	}

	public int solve() {
		for (int i=guesser.getMin(); i&lt; =guesser.getMax(); i++) {
			if (guesser.guess(i) == 0)
				return i;
		}

		throw new IllegalStateException();
	}
}
</pre>
<p>Finally, we&#8217;ll write up a basic StrategyTest.java:</p>
<pre class="brush: java">
import junit.framework.TestCase;

public class StrategyTest extends TestCase {

	public void testSequentialStrategy() {
		GuessTheNumber guesser = new GuessTheNumber(5, 100);
		SequentialStrategy strategy = new SequentialStrategy(guesser);

		int value = strategy.solve();
		assertEquals(guesser.getValue(), value);
	}
}
</pre>
<p>So the question is, how good is our test? If you installed EclEmma, you can right click on your Unit Test in Eclipse, head to &#8220;Coverage As&#8221; -&gt; &#8220;JUnit Test&#8221;</p>
<p><img src="http://ericanderson.us/wp-content/uploads/2008/05/coverageas.png" alt="" width="500" height="117"/></p>
<p>This will run your unit test against your code and when complete, highlight the code green, yellow, or red for covered, partially-covered, and not-covered respectively. </p>
<p>According to EclEmma, our code coverage when running StrategyTest is:<br />
<img src="http://ericanderson.us/wp-content/uploads/2008/05/partialcoverage.png" alt="" width="218" height="40" /></p>
<p>Thats not too bad, lets take a look at the output for SequentialStrategy:<br />
<img src="http://ericanderson.us/wp-content/uploads/2008/05/highlightedcode.png" alt="" width="415" height="238"/></p>
<p>We may want to test the IllegalStateException since we currently don&#8217;t and we are expecting it to happen if we&#8217;ve guessed everything between min and max and haven&#8217;t solved the problem. This would ensure if someone else comes in behind us and changes this code, the unit test will fail if they take that out and change it to return, say, Integer.MIN_VALUE.</p>
<p>Lets also take a look at some of GuessTheNumber:<br />
<img src="http://ericanderson.us/wp-content/uploads/2008/05/guessthenumberhighlighted.png" alt="" width="319" height="335"/></p>
<p>It appears we also want the contract to include an IllegalStateException being thrown if you have already solved the guessing game. It also looks like we don&#8217;t ever call resetCount() and possibly retest after doing that. We also never check if getValue() fails prior to having a solution.</p>
<p>If we modify the test slightly to:</p>
<pre class="brush: java">
import junit.framework.TestCase;

public class StrategyTest extends TestCase {

	public void testSequentialStrategy() {
		GuessTheNumber guesser = new GuessTheNumber(5, 100);
		SequentialStrategy strategy = new SequentialStrategy(guesser);

		for (int i=0; i&amp;lt;3; i++) {
			try {
				guesser.getValue();
				fail(&quot;An exception should have been thrown&quot;);
			}
			catch (IllegalStateException ex) { /**/ }

			int value = strategy.solve();
			assertEquals(guesser.getValue(), value);

			try {
				guesser.guess(guesser.getMax() + 1);
				fail(&quot;Shouldn&#039;t reach this point&quot;);
			}
			catch (IllegalStateException ex) {/**/}

			guesser.resetCount();
		}
	}

	public void testBadGuessGame() {
		GuessTheNumber guesser = new GuessTheNumber(1, 10, 3000);
		SequentialStrategy strategy = new SequentialStrategy(guesser);

		try {
			strategy.solve();
			fail(&quot;Should not reach this point&quot;);
		}
		catch (IllegalStateException ex) { /**/ }
	}
}
</pre>
<p>And now our code coverage is:<br />
<img src="http://ericanderson.us/wp-content/uploads/2008/05/perfectcoverage.png" alt="" width="221" height="39" /></p>
<p>I know this was a very basic example that really didn&#8217;t test any complex logic or conditions, but I hope it gives you a good idea of how you can use code coverage to improve your unit tests.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericanderson.us/2008/05/08/using-eclemma-to-write-better-unit-tests/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Consistent Hashing</title>
		<link>http://ericanderson.us/2008/03/30/consistent-hashing/</link>
		<comments>http://ericanderson.us/2008/03/30/consistent-hashing/#comments</comments>
		<pubDate>Mon, 31 Mar 2008 02:17:31 +0000</pubDate>
		<dc:creator>Eric Anderson</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://ericanderson.us/2008/03/30/consistent-hashing/</guid>
		<description><![CDATA[I don&#8217;t normally post links to other sites, but this is a great article about consistent hashing that greatly simplifies the explanation.
]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t normally post links to other sites, but this is a great article about <a href="http://www.spiteful.com/2008/03/17/programmers-toolbox-part-3-consistent-hashing/">consistent hashing</a> that greatly simplifies the explanation.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericanderson.us/2008/03/30/consistent-hashing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmers and Prison</title>
		<link>http://ericanderson.us/2008/03/27/programmers-and-prison/</link>
		<comments>http://ericanderson.us/2008/03/27/programmers-and-prison/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 18:43:41 +0000</pubDate>
		<dc:creator>Eric Anderson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://ericanderson.us/2008/03/27/programmers-and-prison/</guid>
		<description><![CDATA[Prison: Dark, cold, solitary, and little time outside.
Programmer&#8217;s Office: Dark, cold, solitary, and little time outside. 
Sad coincidence?
]]></description>
			<content:encoded><![CDATA[<p>Prison: Dark, cold, solitary, and little time outside.<br />
Programmer&#8217;s Office: Dark, cold, solitary, and little time outside. </p>
<p>Sad coincidence?</p>
]]></content:encoded>
			<wfw:commentRss>http://ericanderson.us/2008/03/27/programmers-and-prison/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making Terminal.app Easier to Read</title>
		<link>http://ericanderson.us/2008/03/19/making-terminalapp-easier-to-read/</link>
		<comments>http://ericanderson.us/2008/03/19/making-terminalapp-easier-to-read/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 22:48:39 +0000</pubDate>
		<dc:creator>Eric Anderson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[Terminal.app]]></category>

		<guid isPermaLink="false">http://ericanderson.us/2008/03/19/making-terminalapp-easier-to-read/</guid>
		<description><![CDATA[I really like the &#8220;Pro&#8221; color scheme for Terminal.app but I hate how hard it is to read the bold colors. By complete accident however, I came across this Options Page in Terminal.app:

Apparently, you can just click that &#8220;Use bright colors for bold text&#8221; checkbox and all of a sudden typing things like ls is [...]]]></description>
			<content:encoded><![CDATA[<p>I really like the &#8220;Pro&#8221; color scheme for Terminal.app but I hate how hard it is to read the bold colors. By complete accident however, I came across this Options Page in Terminal.app:</p>
<p><img src='http://ericanderson.us/wp-content/uploads/2008/03/terminal_options.png' alt='terminal_options.png' style="border: 1px solid black; padding: 2px;" /></p>
<p>Apparently, you can just click that &#8220;Use bright colors for bold text&#8221; checkbox and all of a sudden typing things like ls is no longer painful. </p>
<p>Just thought I&#8217;d share the tip.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericanderson.us/2008/03/19/making-terminalapp-easier-to-read/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Terminal.app Tab Namer v0.1 Alpha</title>
		<link>http://ericanderson.us/2008/03/02/terminalapp-tab-namer-v01-alpha/</link>
		<comments>http://ericanderson.us/2008/03/02/terminalapp-tab-namer-v01-alpha/#comments</comments>
		<pubDate>Sun, 02 Mar 2008 19:09:06 +0000</pubDate>
		<dc:creator>Eric Anderson</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[Terminal.app]]></category>

		<guid isPermaLink="false">http://ericanderson.us/2008/03/02/terminalapp-tab-namer-v01-alpha/</guid>
		<description><![CDATA[This is a SIMBL plugin for Terminal.app on Leopard that lets you name your tabs. Because this is an Alpha, I am not going to write up instructions on where to get SIMBL, how to install it, or how to install the bundle. If you don&#8217;t already know how, then Alpha software is not for [...]]]></description>
			<content:encoded><![CDATA[<p>This is a SIMBL plugin for Terminal.app on Leopard that lets you name your tabs. Because this is an Alpha, I am not going to write up instructions on where to get SIMBL, how to install it, or how to install the bundle. If you don&#8217;t already know how, then Alpha software is not for you.</p>
<p>That said, after installing the plugin, press Command+Shift+T to name a tab (or use the Name Tab option under the View menu). </p>
<p><span style="color: #f22; text-weight: bold;">NOTE:</span> This has only been tested on Intel Macs with the latest version of SIMBL. If you have a PowerPC and it works for you, I&#8217;d love to hear about it in the comments.</p>
<p>Also, due to the nature of me giving this away for free, I cannot guarantee it won&#8217;t harm your computer, nor can I promise it will fix your marriage. This is for use AT YOUR OWN RISK. I wash my hands completely of responsibility.</p>
<p>Enjoy!</p>
<p><a href='http://ericanderson.us/wp-content/uploads/2008/02/tabnamerbundlev01.zip' title='tabnamerbundlev01.zip'>Terminal Tab Namer v0.1 ALPHA</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ericanderson.us/2008/03/02/terminalapp-tab-namer-v01-alpha/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>Using Pretty URLs with Spring and Annotations</title>
		<link>http://ericanderson.us/2008/02/11/using-pretty-urls-with-spring-and-annotations/</link>
		<comments>http://ericanderson.us/2008/02/11/using-pretty-urls-with-spring-and-annotations/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 02:06:51 +0000</pubDate>
		<dc:creator>Eric Anderson</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Annotations]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://ericanderson.us/2008/02/11/using-pretty-urls-with-spring-and-annotations/</guid>
		<description><![CDATA[I&#8217;m currently working on a Java Web App with Spring. If you aren&#8217;t familiar with the Spring Framework, especially with the annotation support, then you&#8217;ve never had the pleasure of developing a web app in Java (but you may have experienced the pain). In another post, I will explain why this is so amazing, but [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently working on a Java Web App with Spring. If you aren&#8217;t familiar with the <a href="http://springframework.org">Spring Framework</a>, especially with the annotation support, then you&#8217;ve never had the pleasure of developing a web app in Java (but you may have experienced the pain). In another post, I will explain why this is so amazing, but for now lets just assume you know.</p>
<p>If you notice on blogs or other sites they have something called &#8220;pretty urls&#8221;. Essentially if you had a blog, this lets you have <code>/post/welcome-to-my-site/</code> instead of <code>/post/?id=33</code>. Using the Spring Framework and the hot new annotation support in 2.5.1, you can easily achieve that.</p>
<p><span id="more-10"></span><br />
Specify your url on your method like so:</p>
<pre class="brush: java">
public static final String URL_POST = &quot;/post/*/&quot;;

@RequestMapping(URL_POST)
public String showPost(HttpServletRequest req) {
...
}
</pre>
<p>Now all we need to do is pull out the part of the URL that has whats in the star. I&#8217;ve created the following class to assist in this manner:</p>
<pre class="brush: java">
public class UrlUtils {
	public static String[] breakUri(final String uri, final String expectedUrl) {
		Pattern p = Pattern.compile(expectedUrl.replace(&quot;*&quot;, &quot;(.*?)&quot;));
		Matcher m = p.matcher(uri);
		if (m.find()) {
			String[] ret = new String[m.groupCount()];
			for (int i=0; i&amp;lt;ret.length; i++) {
				ret[i] = m.group(i+1);
			}
			return ret;
		}
		else {
			return null;
		}
	}
}
</pre>
<p>So equipped with this class, you only have to do the following:</p>
<pre class="brush: java">
String[] parts = UrlUtils.breakUri(req.getRemoteUri(), URL_POST);
if (parts == null) {
    // Do code to show an archive or whatever you want when the * part is missing
}
else {
    // parts[0] will have what you want.
}
</pre>
<p>Note: This will also (sort of) work if you have a url like: <code>"/post/*/*/"</code> (the array will have a length of 2). However, if you get &#8220;/post/welcome/&#8221; as the URL from the user, <code>breakUri()</code> will return null, in which case you might want to check for <code>"/post/*/"</code>.</p>
<p>Now, this code isn&#8217;t very complex but it does allow you to deal with pretty urls without the hassle of building the regex yourself (something you may sometimes have to do!)</p>
<p>Finally, I&#8217;ve put <a href="http://jira.springframework.org/browse/SPR-4451">a request</a> into the fine folks that develop the Spring Framework to include this type of functionality out of the box so your method could be something like:</p>
<pre class="brush: java">
@RequestMapping(POST_URL)
public String showPost(RequestParts parts) {
    if (!parts.hasParts()) {
        // show general page
    }
    else {
        // Show specific page (parts.get(0))
    }
}
</pre>
<p>Please go <a href="http://jira.springframework.org/browse/SPR-4451">Vote for that feature</a> at Spring&#8217;s issue tracking database.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericanderson.us/2008/02/11/using-pretty-urls-with-spring-and-annotations/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
