<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.3" -->
<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/"
	>

<channel>
	<title>Complete Ramblings</title>
	<link>http://ramblingsof.justinwinkler.com</link>
	<description>My thoughts (facts) on everything</description>
	<pubDate>Sun, 07 Sep 2008 21:26:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.3</generator>
	<language>en</language>
			<item>
		<title>Washer Drain Fun!</title>
		<link>http://ramblingsof.justinwinkler.com/washer-drain-fun</link>
		<comments>http://ramblingsof.justinwinkler.com/washer-drain-fun#comments</comments>
		<pubDate>Sun, 07 Sep 2008 21:19:21 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
		
		<category><![CDATA[Home Repair]]></category>

		<guid isPermaLink="false">http://ramblingsof.justinwinkler.com/washer-drain-fun</guid>
		<description><![CDATA[Oh the joys of owning a house! $18 more dollars I wouldn&#8217;t have had to spend had I lived in an apartment!
Anyway, the washer was draining too fast, and thus overflowing the drain pipe. I found a good solution at FixItNow.com, which includes draining directly into one fork of a y-pipe, and extending the other [...]]]></description>
			<content:encoded><![CDATA[<p>Oh the joys of owning a house! $18 more dollars I wouldn&#8217;t have had to spend had I lived in an apartment!</p>
<p>Anyway, the washer was draining too fast, and thus overflowing the drain pipe. I found a good solution at <a href="http://fixitnow.com/2005/03/washing-machine-drain-pipe-backin-up.htm" target="_new">FixItNow.com</a>, which includes draining directly into one fork of a y-pipe, and extending the other fork much higher in the air as a &#8220;surge&#8221; pipe. Tried it out; works like a charm. I made the surge pipe higher than it needed to be (by about 1 foot), but it helps as the water being drained tends to come out at fairly high pressure, and since it&#8217;s now entering at an angle it tends to splash a bit.</p>
<p>I also ended up needing more parts than were necessary due to the hardware store not having everything. The y-pipe is 2ʺ at both vertical ends, and the fork is 1-1/2ʺ. The hardware store didn&#8217;t have a 1-1/2ʺ to 1ʺ threaded reducer (the washer drain hose is 1ʺ), only a 1-1/2ʺ to 1-1/4ʺ threaded, so I also had to buy a 1-1/4ʺ threaded to 1ʺ threaded to screw the hose adapter in.</p>
<p>Poor pictures taken with my cell phone below:</p>
<p><a href="http://www.justinwinkler.com/images/washer_drain_1.jpg"><img src="http://www.justinwinkler.com/images/washer_drain_1.jpg" title="Picture from a distance" alt="From a distance" width="400" /></a></p>
<p><a href="http://www.justinwinkler.com/images/washer_drain_2.jpg"><img src="http://www.justinwinkler.com/images/washer_drain_2.jpg" title="Picture a bit closer" alt="From a distance" width="400" /></a></p>
<p><a href="http://www.justinwinkler.com/images/washer_drain_3.jpg"><img src="http://www.justinwinkler.com/images/washer_drain_3.jpg" title="Picture up close" alt="From a distance" width="400" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://ramblingsof.justinwinkler.com/washer-drain-fun/feed</wfw:commentRss>
		</item>
		<item>
		<title>Gem Server Init Script</title>
		<link>http://ramblingsof.justinwinkler.com/gem-server-init-script</link>
		<comments>http://ramblingsof.justinwinkler.com/gem-server-init-script#comments</comments>
		<pubDate>Tue, 29 Jul 2008 15:40:23 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://ramblingsof.justinwinkler.com/gem-server-init-script</guid>
		<description><![CDATA[We recently upgraded from rubygems 0.9.x to 1.2.0. Unfortunately, there doesn&#8217;t appear to be a working service init script for this new version, so I had to hand-craft a basic one to start/stop the service. You&#8217;ll find it below in all its glory (and probably under/incorrectly-implemented as I am in no way a linux guru, [...]]]></description>
			<content:encoded><![CDATA[<p>We recently upgraded from rubygems 0.9.x to 1.2.0. Unfortunately, there doesn&#8217;t appear to be a working service init script for this new version, so I had to hand-craft a basic one to start/stop the service. You&#8217;ll find it below in all its glory (and probably under/incorrectly-implemented as I am in no way a linux guru, nor do I intend to be). It works for my use however, maybe it&#8217;ll help you.</p>
<blockquote><p>#!/bin/bash<br />
# chkconfig: 2345 20 80<br />
# description: gem server<br />
# processname: gem_server<br />
# pidfile: /var/lock/subsys/gem_server</p>
<p>source /etc/rc.d/init.d/functions<br />
prog=&#8221;/usr/local/bin/gem server &#8211;daemon&#8221;</p>
<p>start() {<br />
pid=$(ps ax -o pid,command | grep &#8220;gem server&#8221; | grep daemon | awk &#8216;{print $1}&#8217;)<br />
if test -n &#8220;$pid&#8221;<br />
then<br />
echo &#8220;gem server already running : PID $pid&#8221;<br />
else<br />
$prog<br />
fi<br />
}</p>
<p>stop() {<br />
pid=$(ps ax -o pid,command | grep &#8220;gem server&#8221; | grep daemon | awk &#8216;{print $1}&#8217;)<br />
if test -n &#8220;$pid&#8221;<br />
then<br />
echo &#8220;stopping gem server&#8221;<br />
kill $pid<br />
else<br />
echo &#8220;gem server not running&#8221;<br />
fi<br />
}</p>
<p>case &#8220;$1&#8243; in<br />
start)<br />
start<br />
;;<br />
stop)<br />
stop<br />
;;<br />
restart)<br />
stop<br />
start<br />
;;<br />
*)<br />
echo $&#8221;Usage: $0 {start|stop|restart}&#8221;<br />
exit 1<br />
esac</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ramblingsof.justinwinkler.com/gem-server-init-script/feed</wfw:commentRss>
		</item>
		<item>
		<title>Forwarding a dynamic argument &#8220;&#8230;(rest)&#8221; array in Flex</title>
		<link>http://ramblingsof.justinwinkler.com/forwarding-a-dynamic-argument-rest-array-in-flex</link>
		<comments>http://ramblingsof.justinwinkler.com/forwarding-a-dynamic-argument-rest-array-in-flex#comments</comments>
		<pubDate>Tue, 09 Oct 2007 19:57:56 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
		
		<category><![CDATA[Flex]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://ramblingsof.justinwinkler.com/forwarding-a-dynamic-argument-rest-array-in-flex</guid>
		<description><![CDATA[If you&#8217;ve done much in flex, you may have used the &#8220;&#8230;&#8221; notation in a method signature to indicate that the function takes a dynamic number of arguments, such as:

private function doIt( ...args ):void

&#8230; then called the method:

doIt( 1 )
doIt( 1, 2 )
doIt( "some", "other", "stuff" )

The question is this: from within that method, how [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve done much in flex, you may have used the &#8220;&#8230;&#8221; notation in a method signature to indicate that the function takes a dynamic number of arguments, such as:</p>
<blockquote>
<pre>private function doIt( ...args ):void</pre>
</blockquote>
<p>&#8230; then called the method:</p>
<blockquote>
<pre>doIt( 1 )
doIt( 1, 2 )
doIt( "some", "other", "stuff" )</pre>
</blockquote>
<p>The question is this: from within that method, how do you send those same arguments on to another method that accepts a dynamic argument array? You can&#8217;t just pass the &#8220;args&#8221; array, as the method called will only see 1 argument; the array you passed it. Instead, you need to &#8220;explode&#8221; the array into its&#8217; original parts. Here&#8217;s the most simple way I&#8217;ve found to forward that array on to the next method:</p>
<blockquote>
<pre>public function doIt( ...args ):void
{
   var someObject:SomeType = new SomeType()
   someObject.someMethod.apply( someObject, args );
}</pre>
</blockquote>
<p>The &#8220;apply&#8221; method of Function does exactly what we need. Now &#8220;someMethod&#8221; will have it&#8217;s own argument array, and be able to access them the same way you were able to from within &#8220;doIt&#8221;.</p>
<p>This all came about when we began writing a wrapper of sorts for WebServices. We created our own RPC class, with a &#8220;call&#8221; method that accepts the parameters, and we needed to forward them on to Operation&#8217;s &#8220;send&#8221; method. Below is a much simplified example:</p>
<blockquote>
<pre>import mx.rpc.soap.Operation;
public class RPC
{
  public static function call( operation, ...params ):void
  {
    //...code to initialize WebService "svc"
    var op:Operation = Operation( svc.getOperation(operation) );
    //...more code (unimportant)
    var token:AsyncToken = op.send.apply( op, params  );
    //...code to hook up handlers
  }
}</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ramblingsof.justinwinkler.com/forwarding-a-dynamic-argument-rest-array-in-flex/feed</wfw:commentRss>
		</item>
		<item>
		<title>When crap just doesn&#8217;t add up&#8230;</title>
		<link>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up</link>
		<comments>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comments</comments>
		<pubDate>Sat, 29 Sep 2007 02:07:32 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up</guid>
		<description><![CDATA[Math in programming just generally sucks. I come from a mainly Java background, and recently I&#8217;ve been using Ruby. But in both cases, the statement holds true. I know this isn&#8217;t really a new problem, but for god&#8217;s sake, it&#8217;s 2007; why is it still a problem?
Using Ruby, let&#8217;s suppose we have a simple math problem&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>Math in programming just generally sucks. I come from a mainly Java background, and recently I&#8217;ve been using Ruby. But in both cases, the statement holds true. I know this isn&#8217;t really a new problem, but for god&#8217;s sake, it&#8217;s 2007; why is it <strong>still</strong> a problem?</p>
<p>Using Ruby, let&#8217;s suppose we have a simple math problem&#8230; and we want to check equality:</p>
<blockquote>
<pre>1.2 + 1.0 == 2.2 (returns true)</pre>
</blockquote>
<p>Yay, it&#8217;s correct! But that&#8217;s not really much to ask of a language is it now. Let&#8217;s switch it up just a little bit:</p>
<blockquote>
<pre>1.2 - 1.0 == 0.2 (returns false)</pre>
</blockquote>
<p>Uhh&#8230; Ruby? You OK? I really don&#8217;t understand how this is acceptable. I know the argument that we generally work and think in a base10 system, while computers generally store numbers in binary, and there&#8217;s no <strong>exact</strong> way to store many numbers. But shouldn&#8217;t that be fixed (and by fixed, I mean an easy way provided for us to perform exact base10 math), assuming once again, we <strong>generally</strong> work in base10? i.e. when I subtract 1 from 1.2, shouldn&#8217;t I get <strong>exactly</strong> 0.2?<br />
Anyway, if you do a little research, you&#8217;ll find that BigDecimal is supposedly much more accurate when performing calculations, so let&#8217;s try that:</p>
<blockquote>
<pre>require 'bigdecimal'
BigDecimal.new('1.2') - BigDecimal.new('1') ==
   BigDecimal.new('0.2') (returns true)</pre>
</blockquote>
<p>Yay, it worked! &#8230;but who wants to type &#8216;BigDecimal.new&#8217; a thousand times? Dig a little further and you&#8217;ll find a BigDecimal utility, which adds functionality to other Ruby Numeric classes to convert them to BigDecimals:</p>
<blockquote>
<pre>require 'bigdecimal'
require 'bigdecimal/util'
1.2.to_d - 1.0.to_d == 0.2.to_d (returns true)</pre>
</blockquote>
<p>Still works, and it&#8217;s definitely cleaner, but remembering to append &#8216;.to_d&#8217; may be somewhat of a pain (and unnecessarily ugly.) The innaccuracy of Float can still bite you, however; check this out:</p>
<blockquote>
<pre>require 'bigdecimal'
require 'bigdecimal/util'
x = 1.2000000000000000001.to_d
puts x.to_s('F') (prints 1.2)</pre>
</blockquote>
<p>Yep, our 1 in the 1/1000000000000000000th place at the end is lost. This is probably because BigDecimal is aware of the innaccuracy of Float, and since that was of such small value, it assumed it was just a precision issue and is dropped. Frustrating!</p>
<p>Another issue for us might be that using BigDecimal in place of Float probably has more overhead; I don&#8217;t personally have any benchmarks to compare the two. But, then again, I don&#8217;t really need them. For me, being precise far outweighs it being fast (to a point of course). If I was performing some super-intensive process, that did crazy math, and as a result I only needed an answer that was pretty close but not exact, I&#8217;d probably give Float a chance. But until then, it&#8217;s BigDecimal for me, despite it not being the easist/cleanest/prettiest solution.</p>
<p>At any rate, I can live (for now) with implementing BigDecimal in this way (or &#8216;new&#8217;ing them up when appropriate.) But if you happen to use ActionWebService in Rails, you have another problem. Currently (as of version 1.2.3), when you define your API, and use the :float datatype, you&#8217;ll find this does in fact use Float to convey numbers. Dig a little, and you&#8217;ll find that in their SVN repository they may be working on changing this to use BigDecimal instead. One can only hope!</p>
<p>A <a target="_blank" href="http://deepthoughts.orsomethinglikethat.com" title="Deep Thoughts">coworker</a> and I attempted to dig in and try to convert it ourselves for use in a current project, but that attempt was fairly short-lived, and we instead use the &#8220;.to_d&#8221; method above to convert them to BigDecimals once inside the service method. This works for us, since we&#8217;re generally dealing with dollar amounts that aren&#8217;t terribly huge, so we&#8217;re only concerned with accuracy to the penny.</p>
<p>I fully intend, at some point, to revisit this issue and perhaps instead of replacing :float to use BigDecimal, using :decimal or :bigdecimal, thus leaving the ability to use Float if so desired. Hopefully by the time I get to it, they&#8217;ll release a new version with it already implemented. I can dream can&#8217;t I?</p>
]]></content:encoded>
			<wfw:commentRss>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
