<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Coffee's Gone Already?</title>
	<atom:link href="http://coffeesgone.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://coffeesgone.wordpress.com</link>
	<description>My thoughts while waiting for another pot of coffee to brew.</description>
	<lastBuildDate>Tue, 10 Jan 2012 02:49:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='coffeesgone.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Coffee's Gone Already?</title>
		<link>http://coffeesgone.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://coffeesgone.wordpress.com/osd.xml" title="Coffee&#039;s Gone Already?" />
	<atom:link rel='hub' href='http://coffeesgone.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Playing With Assembly</title>
		<link>http://coffeesgone.wordpress.com/2012/01/09/playing-with-assembly/</link>
		<comments>http://coffeesgone.wordpress.com/2012/01/09/playing-with-assembly/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 02:47:46 +0000</pubDate>
		<dc:creator>Sam Baskinger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[assembler]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[stack pointer]]></category>
		<category><![CDATA[x86]]></category>

		<guid isPermaLink="false">http://coffeesgone.wordpress.com/?p=291</guid>
		<description><![CDATA[We were talking at my work about machine instructions available on new Intel chips, specifically the cache miss counters. Why we were talking about cache miss counters is a longer tangent, but for the purposes of this tangent, we started toying with assembly and accidentally learned a few things. First, we wrote a trivial main.c [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=291&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We were talking at my work about machine instructions available on new Intel chips, specifically the cache miss counters. Why we were talking about cache miss counters is a longer tangent, but for the purposes of this tangent, we started toying with assembly and accidentally learned a few things.</p>
<p>First, we wrote a trivial <code>main.c</code> to drive our program:</p>
<pre>#include 

// Promise C that we will link against externally defined functions (f and g)
// with these signatures.
extern int f(int i);
extern int g(int i);

// Simple main.
int main(int args, char** argv)
{
  int i = 1;

  printf("i=%d\n", i);
  printf("f=%d\n", f(i));
  printf("g=%d\n", g(i));

  return 0;
}</pre>
<p>If you hadn&#8217;t guessed, we&#8217;re now going to define <code>int f(int)</code> and <code>int g(int)</code>. Both of these functions take an integer, increment it, and return it. First, here is <code>int g(int)</code> as generated by an unoptimized gcc call we put in the file g.S:</p>
<pre>.global g

g:
push   %rbp             # Push the current base pointer on to the stack.
mov    %rsp, %rbp       # Store the stack pointer value into the base pointer.
mov    %edi,-0x4(%rbp)  # Put argument 1 into the local variable.
mov    -0x4(%rbp),%eax  # Put the local variable into the output reg
add    $0x1,%eax        # Increment the value in eax by 1.
pop    %rbp             # Restore the base pointer of the prev frame.
retq</pre>
<p>Looks a little verbose. Here is our hand-optimized version called <code>int f(int)</code> that we put in a file named f.S:</p>
<pre>
.global f

f:
  mov    %edi,%eax        # Put input value into output register.
  add    $0x1,%eax        # Increment the value in eax by 1.
  retq
</pre>
<p>They do (roughly) the same thing. Add 1 to the input and return the input.</p>
<p>So, what can we learn from this? Well, notice how we pluck the input from the <code>%edi</code> register and place it in the <code>%eax</code> register? Those calling conventions <em>might</em> differ if you are in another language, like, say, C++. This is why we use <code>extern "C" { #include  }</code>. Remember that the compiler generates the machine code from the header, not the linked machine code.</p>
<p>It&#8217;s also instructive to notice that the unoptimized gcc call pushes <code>%rbp</code> (the base pointer) to the stack and then points <code>%rbp</code> at its old value. It then accesses a local variable 4 bytes in size above the current top of the stack (it&#8217;s -0&#215;4 because execution stacks grow from the top-down).</p>
<p>If we had used a local variable and made another function call the stack pointer (<code>%rsp</code>) would have been decremented so that then ext call to <code>push %rbp</code> wouldn&#8217;t clobber our existing data. We would also see a <code>leaveq</code> which quickly pops all of our data off the stack by taking the old <code>%rbp</code> stored in the current <code>%rbp</code> and restoring the old value.</p>
<p>Nothing too earth-shattering, but revisiting the metal-level helps keep perspective and helps me keep one eye on what the stack machine is doing under the higher level language I&#8217;m usually using, such as C++.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/coffeesgone.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/coffeesgone.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/coffeesgone.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/coffeesgone.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/coffeesgone.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/coffeesgone.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/coffeesgone.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/coffeesgone.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/coffeesgone.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/coffeesgone.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/coffeesgone.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/coffeesgone.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/coffeesgone.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/coffeesgone.wordpress.com/291/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=291&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://coffeesgone.wordpress.com/2012/01/09/playing-with-assembly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/39356a03a418d3e4c53aafcfe11a7cab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">basking2</media:title>
		</media:content>
	</item>
		<item>
		<title>Filed Under Odd Manpage Statements: ld.so and glibc2</title>
		<link>http://coffeesgone.wordpress.com/2011/08/17/filed-under-odd-manpage-statements-ld-so-and-glibc2/</link>
		<comments>http://coffeesgone.wordpress.com/2011/08/17/filed-under-odd-manpage-statements-ld-so-and-glibc2/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 04:15:51 +0000</pubDate>
		<dc:creator>Sam Baskinger</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://coffeesgone.wordpress.com/?p=280</guid>
		<description><![CDATA[In hacking around this evening I found this gem in the man page for ld.so: --ignore-rpath LIST Ignore RPATH and RUNPATH information in object names in LIST. This option has been supported by glibc2 for about one hour. Then it was renamed into: --inhibit-rpath LIST &#8220;Supported for about one hour.&#8221; Love it.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=280&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In hacking around this evening I found this gem in the man page for ld.so:</p>
<pre>       --ignore-rpath LIST
              Ignore  RPATH  and  RUNPATH information in object names in LIST.
              This option has been supported by glibc2  for  about  one  hour.
              Then it was renamed into:

       --inhibit-rpath LIST</pre>
<p>&#8220;Supported for about one hour.&#8221; Love it.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/coffeesgone.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/coffeesgone.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/coffeesgone.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/coffeesgone.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/coffeesgone.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/coffeesgone.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/coffeesgone.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/coffeesgone.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/coffeesgone.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/coffeesgone.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/coffeesgone.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/coffeesgone.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/coffeesgone.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/coffeesgone.wordpress.com/280/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=280&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://coffeesgone.wordpress.com/2011/08/17/filed-under-odd-manpage-statements-ld-so-and-glibc2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/39356a03a418d3e4c53aafcfe11a7cab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">basking2</media:title>
		</media:content>
	</item>
		<item>
		<title>Rails and Tests</title>
		<link>http://coffeesgone.wordpress.com/2011/04/06/rails-and-tests/</link>
		<comments>http://coffeesgone.wordpress.com/2011/04/06/rails-and-tests/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 04:24:37 +0000</pubDate>
		<dc:creator>Sam Baskinger</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://coffeesgone.wordpress.com/?p=274</guid>
		<description><![CDATA[An interesting project I&#8217;ve had as of late is getting Rails to play nice with Oracle. One of the major problems I have had is the largely excellent activerecord-oracle_enhanced-adapter doesn&#8217;t do everything quite right yet. For example, they don&#8217;t provide the code to do structure dumps. Ok, no biggie. They don&#8217;t support RAWs yet (I&#8217;m lobbying [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=274&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>An interesting project I&#8217;ve had as of late is getting <a href="http://rubyonrails.org/">Rails</a> to play nice with <a href="http://www.oracle.com/us/index.html">Oracle</a>.</p>
<p>One of the major problems I have had is the largely excellent <a href="http://rubyforge.org/projects/oracle-enhanced/">activerecord-oracle_enhanced-adapter</a> doesn&#8217;t do everything quite right yet. For example, they don&#8217;t provide the code to do structure dumps. Ok, no biggie. They don&#8217;t support RAWs yet (I&#8217;m lobbying for a <a href="https://github.com/rsim/oracle-enhanced/pull/63">pull request</a> to mostly support RAWs) but even if RAWs were supported there is some oddness that when my primary keys are not the default primary key type, they aren&#8217;t dumped correctly to the magic Active Record Migration language.</p>
<p>So, what to do? Well, we decided to override the <a href="http://rake.rubyforge.org/classes/Rake/Task.html">Rake::Task</a> <code>db:test:prepare</code> and after <code>db:test:purge</code>&#8216;ing the database we&#8217;ll just re-run the migrations on the test database. Optimal? Not entirely, but you can&#8217;t beat the flexibility!</p>
<p>So, how do we do this?</p>
<h2>Remove the Old Task / Redefine a New One</h2>
<p>So, you can&#8217;t just re-define a task. A Task object contains actions. You must clear those actions and then define the task, which appends to the now-empty-task your defined action.</p>
<pre>namespace :db do
  namespace :test do |s|
    s[:prepare].clear

    ...
</pre>
<p>Now define the task like you would normally&#8230;</p>
<pre>task :prepare do
...
end
</pre>
<p>The rest is, in some ways details. Invoke the other Rails tasks you want. Be aware that the <code>rake test</code> call switches environments from <code>development</code> to <code>test</code> during it&#8217;s normal runtime. When you override the preparation you need to manage that. In our case we want to call <code>Rake::Task[:db:migrate]</code> in the test environment and then do our unit tests.</p>
<p>Also of note, SEQUENCE objects aren&#8217;t automagically deleted by the <code>db:purge</code> task, so if you use that method to purge your test database you&#8217;ll also want to delete your SEQUENCE objects. You can look those up in the <code>user_objects</code> table.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/coffeesgone.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/coffeesgone.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/coffeesgone.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/coffeesgone.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/coffeesgone.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/coffeesgone.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/coffeesgone.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/coffeesgone.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/coffeesgone.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/coffeesgone.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/coffeesgone.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/coffeesgone.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/coffeesgone.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/coffeesgone.wordpress.com/274/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=274&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://coffeesgone.wordpress.com/2011/04/06/rails-and-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/39356a03a418d3e4c53aafcfe11a7cab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">basking2</media:title>
		</media:content>
	</item>
		<item>
		<title>Gorilla Optimization</title>
		<link>http://coffeesgone.wordpress.com/2011/02/21/gorilla-optimization/</link>
		<comments>http://coffeesgone.wordpress.com/2011/02/21/gorilla-optimization/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 20:02:05 +0000</pubDate>
		<dc:creator>Sam Baskinger</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://coffeesgone.wordpress.com/?p=267</guid>
		<description><![CDATA[This is what tends to happen. If the first day over a cold coincides with a day off from work, I tend to get curious about things, explore, and end up blogging. I leave it to you weather that is a good or bad thing. Enough personal stuff&#8230; I&#8217;ve been trying to optimize building summary [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=267&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is what tends to happen. If the first day over a cold coincides with a day off from work, I tend to get curious about things, explore, and end up blogging. I leave it to you weather that is a good or bad thing. Enough personal stuff&#8230;</p>
<p>I&#8217;ve been trying to optimize building summary information about about 12 million very-very-very tiny records.  This is still technology under development, so please forgive my vagueness. The slowness of the query comes from a few places.</p>
<h1>Problems</h1>
<p>First, sheer record number. Twelve million of anything amplifies your decisions, and these records are very small. It all fits in memory and it&#8217;s nothing but CPU churn.</p>
<p>Second, there is a single join against a label table which, I partly blame <a href="http://www.postgresql.org/">Postgres </a>for the slowness of. The labels are assigned by the closest prefix less than the given value. It&#8217;s not a clear join and as a result Postgres always scans the table&#8217;s index. I assume that Oracle would be able to put some snazzy prefix searching or <a href="http://en.wikipedia.org/wiki/Trie">Trie</a>-type structure in place, but that has yet to be seen.</p>
<p>So, those are the two big problems. I am very  proud, though, of what I&#8217;m going to term &#8220;gorilla optimizations&#8221; that our team came up with to shrink the problem down to a size where It&#8217;s clear we can continue to fly on Postgres for a while longer.</p>
<h1>Solutions!</h1>
<p>First, we decided to pull the join lookups out into an external library which was provided by the vendor. This alternate lookup method is faster even when having our application do all the lookups in Ruby code.</p>
<p>Second, we decided to summarize the labeling. Since the reports we are looking at generating are about maximums and upper-bounds it was acceptable to reduce precision on our label lookup by reducing the range of our foreign key to the label. This was done by simply truncating foreign keys and grouping them. The result is that almost all of them still receive the same value, but a few do not. This also resulted in far fewer calls to the label library.</p>
<p>Third, we summarized by a time slice. The database could give us hours very cleanly ( <code>date_trunk('hours', ... )</code> ) but in situations where we wanted 1/2 days we had the application code examine the raw rows given back by Postgres and aggregate them into the size block desired before storing.</p>
<p>The results of all these optimizations sums up to something we can probably live with for quite a while, and why I share this is that no single optimization could have made this work. The constant picking away at bits of bloat and lag by many minds has resulted in not having to do any sort of major redesign or custom system development, and that&#8217;s a nice story worth sharing.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/coffeesgone.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/coffeesgone.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/coffeesgone.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/coffeesgone.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/coffeesgone.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/coffeesgone.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/coffeesgone.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/coffeesgone.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/coffeesgone.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/coffeesgone.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/coffeesgone.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/coffeesgone.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/coffeesgone.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/coffeesgone.wordpress.com/267/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=267&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://coffeesgone.wordpress.com/2011/02/21/gorilla-optimization/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/39356a03a418d3e4c53aafcfe11a7cab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">basking2</media:title>
		</media:content>
	</item>
		<item>
		<title>A Bit Deeper Into Rails 3.0 Error Pages</title>
		<link>http://coffeesgone.wordpress.com/2011/01/13/a-bit-deeper-into-rails-3-0-error-pages/</link>
		<comments>http://coffeesgone.wordpress.com/2011/01/13/a-bit-deeper-into-rails-3-0-error-pages/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 23:49:05 +0000</pubDate>
		<dc:creator>Sam Baskinger</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://coffeesgone.wordpress.com/?p=265</guid>
		<description><![CDATA[In the previos post I shared a bit of a hack to have our ApplicationController send errors to the static 404 and 500 pages. After road-testing that solution for a bit and getting some feed back I would like to offer a slight polishing of that previous idea where errors are redirected to an ErrorController [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=265&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the previos post I shared a bit of a hack to have our ApplicationController send errors to the static<br />
<code>404</code> and <code>500</code> pages. After road-testing that solution for a bit and getting some<br />
feed back I would like to offer a slight polishing of that previous idea where errors are redirected to<br />
an <code>ErrorController</code> and the error page is dynamically rendered. </p>
<p>First, add the handler methods to the base <code>ApplicationController</code> as in the last post. Notice that<br />
they are different! They point to a controller named <code>error</code>.</p>
<pre>
class ApplicationController  :error, :action =&gt; :server_error
  end

  def method_missing(id, *args)
    redirect_to :controller =&gt; :error, :action =&gt; :not_found
  end
end
</pre>
<p>Now, what I glossed over in the previous post, this error controller will have two actions (and views which<br />
are not shown here). Notice that we also have defined <code>rescue_with_handler</code> in <code>ErrorController</code><br />
as well as in <code>ApplicationController</code>. In the rare case that we cannot render the error pages, for<br />
example the navigation bar uses a database table and the error is that the database is down, we need a way to<br />
fail back to the static <code>/500.html</code> page. Otherwise we will recursively exhaust the call stack in the<br />
Ruby VM.</p>
<pre>
class ErrorController &lt; ApplicationController
  def not_found
  end

  def server_error
  end

  def rescue_with_handler(exception)
    redirect_to &#039;/500.html&#039;
  end
end
</pre>
<p>Finally, add a line in your <code>config/routes.rb</code> file to send anything not already captured to the<br />
<code>ErrorController</code>&#8216;s action <code>note_found</code>.</p>
<pre>
match ':action', :controller =&gt; :error, :action =&gt; :not_found
</pre>
<p>I choose to pepper this sort of thing with logging statments at least until I&#8217;m sure it&#8217;s working correctly. Enjoy!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/coffeesgone.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/coffeesgone.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/coffeesgone.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/coffeesgone.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/coffeesgone.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/coffeesgone.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/coffeesgone.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/coffeesgone.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/coffeesgone.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/coffeesgone.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/coffeesgone.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/coffeesgone.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/coffeesgone.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/coffeesgone.wordpress.com/265/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=265&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://coffeesgone.wordpress.com/2011/01/13/a-bit-deeper-into-rails-3-0-error-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/39356a03a418d3e4c53aafcfe11a7cab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">basking2</media:title>
		</media:content>
	</item>
		<item>
		<title>Those Ugly Rails 3 Error Page</title>
		<link>http://coffeesgone.wordpress.com/2011/01/13/those-ugly-rails-3-error-page/</link>
		<comments>http://coffeesgone.wordpress.com/2011/01/13/those-ugly-rails-3-error-page/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 05:03:13 +0000</pubDate>
		<dc:creator>Sam Baskinger</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[500]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://coffeesgone.wordpress.com/?p=261</guid>
		<description><![CDATA[Admittedly, I&#8217;m new to Rails 3 presentation magic. I&#8217;ve spent a lot of time working with ActiveRecord but very little wiring up the corner-cases of a Rails 3 application. That said, I&#8217;m thrilled to have a chance to look at the nuances of Rails 3. Love it so far. That said, I&#8217;ve been wracking my [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=261&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Admittedly, I&#8217;m new to <a href="http://rubyonrails.org/">Rails</a> 3 presentation magic. I&#8217;ve spent a lot of time working with <a href="http://api.rubyonrails.org/classes/ActiveRecord/Base.html">ActiveRecord</a> but very little wiring up the corner-cases of a Rails 3 application. That said, I&#8217;m thrilled to have a  chance to look at the nuances of Rails 3. Love it so far. That said, I&#8217;ve been wracking my mind about the &#8220;right&#8221; way to redirect to <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">404</a> and <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">500</a> error pages.</p>
<p>Given the extremely constrained time I&#8217;m living (happily, I might add) in I offer up to you this solution and encourage feedback!</p>
<pre>class ApplicationController &lt; ActionController::Base

  def rescue_with_handler(exception)
    redirect_to '/500.html'
  end

  def method_missing(id, *args)
    redirect_to '/404.html'
  end
end</pre>
<p>That&#8217;s the best I could dig up given my admittedly limited experience. Better solutions are welcome! It seems the Rails 2 redirect to <code>404.html</code> inside the <code>public</code> directory isn&#8217;t in play anymore. Thanks in advance! Hope this helps someone else Googling like I did!</p>
<p>So above we see two overrides. First, the obvious <code>method_missing</code> override sends any action this ActionController does not know about to the static <code>404.html</code> page that Rails ships with. Replace this with a 404 controller if you like and get a nicer error page and override <em>that</em> controller&#8217;s <code>method_missing</code> method and you have a nice robust chain to handle basic failure and really unexpected failure.</p>
<p>The second method we override is the <code>rescue_with_handler</code> method. When an exception kills an action, this is what seems to handle the drama. Naturally an exception is typically a 500 error. Naturally you can be a little more precise about your error handling and do the nice chaining I mentioned for the 404 page.</p>
<p>Finally, if you haven&#8217;t thought of this yourself, make a default route at the end of your <code>config/routes.rb</code> file to ensure that your error controller gets any request that isn&#8217;t matched otherwise.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/coffeesgone.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/coffeesgone.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/coffeesgone.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/coffeesgone.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/coffeesgone.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/coffeesgone.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/coffeesgone.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/coffeesgone.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/coffeesgone.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/coffeesgone.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/coffeesgone.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/coffeesgone.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/coffeesgone.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/coffeesgone.wordpress.com/261/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=261&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://coffeesgone.wordpress.com/2011/01/13/those-ugly-rails-3-error-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/39356a03a418d3e4c53aafcfe11a7cab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">basking2</media:title>
		</media:content>
	</item>
		<item>
		<title>NoSQL Posts that Don&#8217;t Help</title>
		<link>http://coffeesgone.wordpress.com/2010/10/28/nosql-posts-that-dont-help/</link>
		<comments>http://coffeesgone.wordpress.com/2010/10/28/nosql-posts-that-dont-help/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 13:38:20 +0000</pubDate>
		<dc:creator>Sam Baskinger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[nosql]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[solr]]></category>

		<guid isPermaLink="false">http://coffeesgone.wordpress.com/?p=255</guid>
		<description><![CDATA[I was happily minding my own business when this post, NoSQL, Lucene and Solr wandered across my twitter feeds. The first 1622 characters can be removed and the meat of the post was the last 663 characters (analytics courtesy of /usr/bin/wc). This is what frustrates me about the &#8220;NoSQL&#8221; movement, and my apolgies to Grant [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=255&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was happily minding my own business when <a href="http://www.lucidimagination.com/blog/2010/04/30/nosql-lucene-and-solr/">this post, NoSQL, Lucene and Solr</a> wandered across my twitter feeds. The first 1622 characters can be removed and the meat of the post was the last 663 characters (analytics courtesy of <code>/usr/bin/wc</code>).</p>
<p>This is what frustrates me about the &#8220;NoSQL&#8221; movement, and my apolgies to <a href="http://www.lucidimagination.com/blog/author/grant-ingersoll/">Grant Ingersoll</a> for being the prompt for this post, but as a corporate blogger, I don&#8217;t feel so bad picking on this particular post: The movement is packed with non-critical posts designed to gather attention and not  promote understanding.</p>
<p>More secifically, when I clicked on the afore mentioned blog post I expected a discussion of ways to estimate <a href="http://wiki.apache.org/solr/SolrRelevancyFAQ#How_are_documents_scored">inverse document frequency</a> or perhaps an argument that if you <a href="http://wiki.apache.org/solr/DistributedSearch#What_is_Distributed_Search.3F">shard</a> your search cores you can ignore <i>idf</i> (inverse document frequency) because it is statistically valid for scoring documents.</p>
<p>I would have been happy for a post that just mentioned the word <i>sharding</i> and talked about putting different search cores in different cores on the same servlet container on the same machine vs. distributing those search cores to other machines.<br />
I would have loved to read about memory contention and the idea of floating garbage. I would have even enjoyed a small piece that said that true horizontile scaling is hard because of global values such as idf.</p>
<p>I got none of that. I didn&#8217;t even get a link to a technical piece talking about any of the buzz words mentioned.<br />
I know, I know, my fault for clicking. The reader beware. That being the case, I don&#8217;t feel so bad that you may have taken 5 minutes to read this. <code> <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </code> And Grant got a little publicity for Lucid Imagination.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/coffeesgone.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/coffeesgone.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/coffeesgone.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/coffeesgone.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/coffeesgone.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/coffeesgone.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/coffeesgone.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/coffeesgone.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/coffeesgone.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/coffeesgone.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/coffeesgone.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/coffeesgone.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/coffeesgone.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/coffeesgone.wordpress.com/255/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=255&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://coffeesgone.wordpress.com/2010/10/28/nosql-posts-that-dont-help/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/39356a03a418d3e4c53aafcfe11a7cab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">basking2</media:title>
		</media:content>
	</item>
		<item>
		<title>Ubuntu 10.10 64bit and Cisco VPN AnyConnect</title>
		<link>http://coffeesgone.wordpress.com/2010/10/17/ubuntu-10-10-64bit-and-cisco-vpn-anyconnect/</link>
		<comments>http://coffeesgone.wordpress.com/2010/10/17/ubuntu-10-10-64bit-and-cisco-vpn-anyconnect/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 03:30:52 +0000</pubDate>
		<dc:creator>Sam Baskinger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[anyconnect]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://coffeesgone.wordpress.com/?p=250</guid>
		<description><![CDATA[There is an excellent article on getting this working from 2009 at Koroshiay Itchy but there are a couple of details that I had to go through to get the Cisco AnyConnect VPN working on my system. Quickly, go to your VPN URL and get the client software installed. it will probably fail. It does [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=250&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There is an excellent article on getting this working from 2009 at <a href="http://koroshiyaitchy.wordpress.com/2009/05/09/using-cisco-anyconnect-vpn-client-in-unbuntu-jaunty-64-bit/">Koroshiay Itchy</a> but there are a couple of details that I had to go through to get the Cisco AnyConnect VPN working on my system.</p>
<p>Quickly, go to your VPN URL and get the client software installed. it will probably fail. It does that. Then, we will roughly follow the steps at the blog site cited above plus a few bonuses:</p>
<ol>
<li>Install it in <code>/opt/cisco/vpn</code> (yeah, we did this already)</li>
<li>Download Firefox&#8217;s 32bit binary and install it at <code>/usr/local/firefox</code>.</li>
<li><code>sudo apt-get install ia32-libs lib32nss-mdns</code></li>
<li>Copy <code>/usr/local/firefox/*so</code> to <code>/opt/cisco/vpn/lib</code></li>
<li>Create the file ﻿﻿﻿﻿﻿﻿<code>/etc/ld.so.conf.d/lib32firefox.conf</code> and add the line to it <code>/usr/local/firefox</code>.</li>
<li>Run ldconfig to process the config file <code>/etc/ld.so.conf.d/lib32firefox.conf</code> and add those shared libraries to the system.</li>
<li>Remove <code>~/.mozilla</code> from the user that you want to be able to start the VPN.</li>
<li>Run firefox and point it at your vpn&#8217;s URL so it &#8220;sees&#8221; the certificate. Once you do that it appears that you can start <code>/opt/cisco/vpn/bin/vpnui</code> and connect without issue.</li>
</ol>
<p>A few hoops, but well worth it if you can stay in your preferred development environment and connect into work. May I recommend, while I&#8217;m at it, to create a user-work account on your desktop to keep a little separation between home and work life? No? Well, I can&#8217;t bring myself to do it either. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/coffeesgone.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/coffeesgone.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/coffeesgone.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/coffeesgone.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/coffeesgone.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/coffeesgone.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/coffeesgone.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/coffeesgone.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/coffeesgone.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/coffeesgone.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/coffeesgone.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/coffeesgone.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/coffeesgone.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/coffeesgone.wordpress.com/250/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=250&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://coffeesgone.wordpress.com/2010/10/17/ubuntu-10-10-64bit-and-cisco-vpn-anyconnect/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/39356a03a418d3e4c53aafcfe11a7cab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">basking2</media:title>
		</media:content>
	</item>
		<item>
		<title>Code from 2006 &#8211; TCUP</title>
		<link>http://coffeesgone.wordpress.com/2010/10/05/code-from-2006-tcup/</link>
		<comments>http://coffeesgone.wordpress.com/2010/10/05/code-from-2006-tcup/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 00:39:26 +0000</pubDate>
		<dc:creator>Sam Baskinger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[p2p]]></category>
		<category><![CDATA[tcp]]></category>

		<guid isPermaLink="false">http://coffeesgone.wordpress.com/?p=246</guid>
		<description><![CDATA[I was chatting with a friend on Buzz (would that be Buzz&#8217;n?) buzz&#8217;n with a friend on Google Buzz and had a memory of a past project from 2004 &#8211; 2006 pop into my mind, namely TCUP: http://fmp2p.sourceforge.net/protocoldocs/index.html TCUP (Trivial Callup Protocol) was to be a simple messaging protocol with the capability of establishing calls [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=246&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was chatting with a friend on Buzz (would that be Buzz&#8217;n?) buzz&#8217;n with a friend on Google Buzz and had a memory of a past project from 2004 &#8211; 2006 pop into my mind, namely TCUP: <a href="http://fmp2p.sourceforge.net/protocoldocs/index.html">http://fmp2p.sourceforge.net/protocoldocs/index.html</a></p>
<p>TCUP (Trivial Callup Protocol) was to be a simple messaging protocol with the capability of establishing calls through nodes in an <a href="http://en.wikipedia.org/wiki/Overlay_network">overlay network</a>. Sadly, life got busy and I never had the time to make the implementation solid. You&#8217;ll also probably notice that the <a href="http://www.tcpipguide.com/free/t_DataEncapsulationProtocolDataUnitsPDUsandServiceDa.htm">PDUs</a> in the protocol document nowhere specify an upper layer protocol. Lesson learned, always include that field. It is a <em>pain</em> coding multiple upper layer protocols and trying to dispatch the traffic to the correct handler.</p>
<p>Still, I love the idea of overlay networks and small independent rings of storage and computation over the internet. Neat ideas coming back from the past.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/coffeesgone.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/coffeesgone.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/coffeesgone.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/coffeesgone.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/coffeesgone.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/coffeesgone.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/coffeesgone.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/coffeesgone.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/coffeesgone.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/coffeesgone.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/coffeesgone.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/coffeesgone.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/coffeesgone.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/coffeesgone.wordpress.com/246/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=246&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://coffeesgone.wordpress.com/2010/10/05/code-from-2006-tcup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/39356a03a418d3e4c53aafcfe11a7cab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">basking2</media:title>
		</media:content>
	</item>
		<item>
		<title>Sneaky Null Pointers using Floats and Unboxing</title>
		<link>http://coffeesgone.wordpress.com/2010/08/28/sneaky-null-pointers-using-floats-and-unboxing/</link>
		<comments>http://coffeesgone.wordpress.com/2010/08/28/sneaky-null-pointers-using-floats-and-unboxing/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 20:00:47 +0000</pubDate>
		<dc:creator>Sam Baskinger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://coffeesgone.wordpress.com/?p=232</guid>
		<description><![CDATA[This is one of those posts where I&#8217;m simply excited about a bug we bumped in to in our system. This one is another instance of a NULL value being unboxed  from a Java Object to a primitive via Unboxing (or Autoboxing, however you learned this one).  The idea of Boxing is very strait forward, when [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=232&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is one of those posts where I&#8217;m simply excited about a bug we bumped in to in our system. This one is another instance of a NULL value being unboxed  from a Java Object to a <a href="http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2">primitive</a> via <a href="http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.1.8">Unboxing</a> (or Autoboxing, however you learned this one).  The idea of <em>Boxing</em> is very strait forward, when you have a primitive value in Java, box it in an Object so it can be used consistently with all the other Reflection tools you&#8217;ve written. One of the best features of having boxed primitives is being able to set up Mock Objects more easily with <a href="http://easymock.org/">Easy Mock</a>, but that&#8217;s another post.</p>
<p>We recently bumped into a very subtle null pointer exception patterned after this snipped:</p>
<pre>public class A
{
    public static void main(String[] argv)
    {
        final Float f = argv.length == 10 ? 0f : getF();
    }

    public static Float getF() { return null ; }
}</pre>
<p>No, that&#8217;s not the code, verbatim, but the pattern is the same. There was a <a href="http://en.wikipedia.org/wiki/Ternary_operation">ternary</a> operator, as above, that returned a float primitive (the <code>0f</code>) or a Float object from the method call. The output of the ternary operation down-casts both calls to a float primitive, thus if <code>getF</code> returns null as it does in our example, the statement blows up. If you wrap the <code>0f</code> in a <code>Float.valueOf(0f)</code> then no downcast is performed and you are fine.</p>
<p>Fascinating, no? What I love about this example is how subtle and &#8220;correct&#8221; the statement looks.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/coffeesgone.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/coffeesgone.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/coffeesgone.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/coffeesgone.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/coffeesgone.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/coffeesgone.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/coffeesgone.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/coffeesgone.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/coffeesgone.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/coffeesgone.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/coffeesgone.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/coffeesgone.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/coffeesgone.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/coffeesgone.wordpress.com/232/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=coffeesgone.wordpress.com&amp;blog=7216545&amp;post=232&amp;subd=coffeesgone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://coffeesgone.wordpress.com/2010/08/28/sneaky-null-pointers-using-floats-and-unboxing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/39356a03a418d3e4c53aafcfe11a7cab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">basking2</media:title>
		</media:content>
	</item>
	</channel>
</rss>
