<?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"
	>

<channel>
	<title>Trevor Berg: The Blog</title>
	<atom:link href="http://blog.trevorberg.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.trevorberg.com</link>
	<description></description>
	<pubDate>Thu, 14 Aug 2008 02:35:24 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Standard Deviation and Correlation Coefficient in ruby</title>
		<link>http://blog.trevorberg.com/2008/08/13/standard-deviation-and-correlation-coefficient-in-ruby/</link>
		<comments>http://blog.trevorberg.com/2008/08/13/standard-deviation-and-correlation-coefficient-in-ruby/#comments</comments>
		<pubDate>Thu, 14 Aug 2008 02:30:44 +0000</pubDate>
		<dc:creator>Trevor</dc:creator>
		
		<category><![CDATA[Rails]]></category>

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

		<guid isPermaLink="false">http://blog.trevorberg.com/?p=18</guid>
		<description><![CDATA[I recently had to write a few math functions for some Filtered Averaging stuff.  I thought somebody else out there might find them useful

def std_dev(list)

  # Calculate neccesary values
  list_squared = list.map {&#124;item&#124; item*item }
  n = list.size

  #Calculate the std deviation
  right = (Float (sum(list)**2))/n

  ((Float (sum(list_squared)) [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to write a few math functions for some Filtered Averaging stuff.  I thought somebody else out there might find them useful</p>
<pre name="code" class="ruby">
def std_dev(list)

  # Calculate neccesary values
  list_squared = list.map {|item| item*item }
  n = list.size

  #Calculate the std deviation
  right = (Float (sum(list)**2))/n

  ((Float (sum(list_squared)) - right) / (n-1)) ** 0.5

end

def correlation(x, y)

  # Calculate the necessary values
  n = x.size

  sum_x = sum(x)
  sum_y = sum(y)

  x_squared = x.map {|item| item*item }
  y_squared = y.map {|item| item*item }

  sum_x_squared = sum(x_squared)
  sum_y_squared = sum(y_squared)

  xy = []
  x.each_with_index do |value, key|
    xy << value * y[key]
  end

  sum_xy = sum(xy)

  # Calculate the correlation value
  left = n * sum_xy - sum_x * sum_y
  right = ((n * sum_x_squared - sum_x**2) * (n * sum_y_squared - sum_y**2)) ** 0.5

  left / right
end

def sum(list)
  list.inject( nil ) { |sum,x| sum ? sum+x : x };
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.trevorberg.com/2008/08/13/standard-deviation-and-correlation-coefficient-in-ruby/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Dropbox Redux</title>
		<link>http://blog.trevorberg.com/2008/08/11/dropbox-redux/</link>
		<comments>http://blog.trevorberg.com/2008/08/11/dropbox-redux/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 17:38:11 +0000</pubDate>
		<dc:creator>Trevor</dc:creator>
		
		<category><![CDATA[Design]]></category>

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

		<guid isPermaLink="false">http://blog.trevorberg.com/?p=16</guid>
		<description><![CDATA[As I posted  a few days ago, I flew out to San Francisco a week or two ago to checkout the dropbox guys.  I did some design stuff for them, and since I&#8217;ve got back I haven&#8217;t been able to get them out of my head.  I wanted to keep thing simple, [...]]]></description>
			<content:encoded><![CDATA[<p>As I posted  a few days ago, I flew out to San Francisco a week or two ago to checkout the dropbox guys.  I did some design stuff for them, and since I&#8217;ve got back I haven&#8217;t been able to get them out of my head.  I wanted to keep thing simple, but add some color and some contrast.  I&#8217;m pretty happy with this very unpolished version I&#8217;ve come up with. Anyways, here&#8217;s the results of my efforts:</p>
<table border="0">
<tbody>
<tr>
<td>Original</td>
<td>My Version</td>
</tr>
<tr>
<td><a href="http://www.trevorberg.com/images/dropbox_original.gif"><img src="http://www.trevorberg.com/images/dropbox_original_thumb.gif" alt="" /></a></td>
<td><a href="http://www.trevorberg.com/images/dropbox.gif"><img src="http://www.trevorberg.com/images/dropbox_thumb.gif" alt="" /></a></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.trevorberg.com/2008/08/11/dropbox-redux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>RTFRFC</title>
		<link>http://blog.trevorberg.com/2008/08/10/rtfrfc/</link>
		<comments>http://blog.trevorberg.com/2008/08/10/rtfrfc/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 20:18:53 +0000</pubDate>
		<dc:creator>Trevor</dc:creator>
		
		<category><![CDATA[NNTP]]></category>

		<guid isPermaLink="false">http://blog.trevorberg.com/?p=14</guid>
		<description><![CDATA[I&#8217;ve been writing a yDecoder for swagr the last couple of days (I&#8217;ll release the source once I optimize it a bit) and I ran into a bit of a wall.  Every article I decoded was 99.9% correct, but each had a couple of extra bytes.  I spent several hours working on it and found [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been writing a yDecoder for swagr the last couple of days (I&#8217;ll release the source once I optimize it a bit) and I ran into a bit of a wall.  Every article I decoded was 99.9% correct, but each had a couple of extra bytes.  I spent several hours working on it and found that it only occurred at the beginning of a couple lines.</p>
<p>After going through a bunch of other yDecoder implementations, I still couldn&#8217;t figure out what I was doing wrong.  Then I happened across a bright red message on the yEnc site :</p>
<blockquote>
<h2><span style="color: #ff0000;">Frequent programming problem (28.03.2003)</span></h2>
<p><span style="color: #ff0000;">I was contacted more than a dozen time by developers who are having problems with the decoding or encoding. They all had the same problem: They did not realize that the NNTP-protocol requires to double a dot in the first colum when a line is sent - and to detect a double dot (and remove one of them) when receiving a line.<br />
So if you are directly posting to or reading from a socket (internet conenction socket), then dont forget this, please</span></p></blockquote>
<p>The NNTP protocol repeats the . character if it occurs at the beginning of the line because  the . is used as a terminating character. So the moral of the story is always read your RFC&#8217;s.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trevorberg.com/2008/08/10/rtfrfc/feed/</wfw:commentRss>
		</item>
		<item>
		<title>getLine for NSString</title>
		<link>http://blog.trevorberg.com/2008/08/07/getline-for-nsstring/</link>
		<comments>http://blog.trevorberg.com/2008/08/07/getline-for-nsstring/#comments</comments>
		<pubDate>Fri, 08 Aug 2008 02:52:36 +0000</pubDate>
		<dc:creator>Trevor</dc:creator>
		
		<category><![CDATA[COCOA]]></category>

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

		<guid isPermaLink="false">http://blog.trevorberg.com/?p=13</guid>
		<description><![CDATA[UPDATE2: I&#8217;ve added a hack to use psuedo instance variables, it works for now but I&#8217;ll refactor to a better solution soon.
UPDATE: After some more research and trouble shooting I&#8217;ve found that you can&#8217;t add instance variables through categories,  it looks as though I&#8217;d be better off writing a subclass of NSString for this.
I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATE2: I&#8217;ve added a hack to use psuedo instance variables, it works for now but I&#8217;ll refactor to a better solution soon.</p>
<p>UPDATE: After some more research and trouble shooting I&#8217;ve found that you can&#8217;t add instance variables through categories,  it looks as though I&#8217;d be better off writing a subclass of NSString for this.</p>
<p>I&#8217;m currently writing the decoder for yDec and decided I wanted to read files a line at a time.  Unfortunately, I wasn&#8217;t able to find a simple way of doing this in objective-c so I wrote a category for the NSString class that allows you to read from a NSString a line at a time.</p>
<p>Header:</p>
<pre name="code" class="cpp">
//
//  getLine.h
//  swagr
//
//  Created by Trevor Berg on 8/7/08.
//  Copyright 2008 Trevor Berg. All rights reserved.
//

#import &lt;Cocoa/Cocoa.h&gt;

@interface NSString (getLine)
- (void)setFilePointer:(int)index;
- (int)getFilePointer;
- (NSString*) getLine;
- (void)resetLine;
@end
</pre>
<p>Implementation:</p>
<pre name="code" class="cpp">
//
//  getLine.m
//  swagr
//
//  Created by Trevor Berg on 8/7/08.
//  Copyright 2008 Trevor Berg. All rights reserved.
//

#import "getLine.h"

@implementation NSString (getLine)

static NSMutableDictionary *ivarHolder = nil;

- (NSString*) getLine{

	// chop off the first part of the string so that
	// you actually get the next line instead of the first line
	NSString* mySelf = [self substringFromIndex:[self getFilePointer]];

	// find the index of the end of the line
	int first = [mySelf rangeOfString:@"\n"].location;

	// make sure it found a line
	if (first != NSNotFound) {
		NSString* line = [mySelf substringToIndex:(first-1)];

		// move the index to the start of the next line
		[self setFilePointer:(first + 1 + [self getFilePointer])];

		// return the line
		return line;
	}
	else {
		// Didn&#8217;t find another line so return nil
		return nil;
	}
}

- (void) resetLine {

	// reset the index to the beginning of the file
	[self setFilePointer:0];
}

- (void)setFilePointer:(int)index {
	if ( ivarHolder == nil )
        ivarHolder = [[NSMutableDictionary alloc] init];

	[ivarHolder setObject:[NSNumber numberWithInt:index] forKey:self];
}

- (int)getFilePointer {
	if(ivarHolder == nil) {
		return 0;
	}
	else {
		NSNumber* index = [ivarHolder objectForKey:self];
		return [index intValue];
	}
}
@end
</pre>
<p>Obviously, this isn&#8217;t the most polished solution so feel free to email me any changes to trevorb(at)gmail.com .</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trevorberg.com/2008/08/07/getline-for-nsstring/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Back from San Francisco</title>
		<link>http://blog.trevorberg.com/2008/08/07/back-from-san-francisco/</link>
		<comments>http://blog.trevorberg.com/2008/08/07/back-from-san-francisco/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 21:34:32 +0000</pubDate>
		<dc:creator>Trevor</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.trevorberg.com/?p=12</guid>
		<description><![CDATA[
I just got back from my first trip to San Francisco, and I have to say I really liked the place.  I flew down to check out Dropbox. If you don&#8217;t know about Dropbox, they provide data synchronization, backup, version control, and web sharing free of charge ( up to 2 gb).  I have a [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" src="http://farm4.static.flickr.com/3191/2718348992_ab6f240465.jpg?v=0" alt="Bay Bridge" /></p>
<p>I just got back from my first trip to San Francisco, and I have to say I really liked the place.  I flew down to check out <a href="http://www.dropbox.com" target="_blank">Dropbox.</a> If you don&#8217;t know about Dropbox, they provide data synchronization, backup, version control, and web sharing free of charge ( up to 2 gb).  I have a few invites if anyone needs some. It&#8217;s clear they have a very good thing going.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trevorberg.com/2008/08/07/back-from-san-francisco/feed/</wfw:commentRss>
		</item>
		<item>
		<title>swagr: a cocoa open source nntp reader</title>
		<link>http://blog.trevorberg.com/2008/07/19/swagr-a-cocoa-open-source-nntp-reader/</link>
		<comments>http://blog.trevorberg.com/2008/07/19/swagr-a-cocoa-open-source-nntp-reader/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 19:29:48 +0000</pubDate>
		<dc:creator>Trevor</dc:creator>
		
		<category><![CDATA[COCOA]]></category>

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

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

		<guid isPermaLink="false">http://blog.trevorberg.com/?p=11</guid>
		<description><![CDATA[I&#8217;ve started working on a new project I&#8217;m calling swagr. swagr will be an open source Cocoa usenet newsreader.  The project is in the very early stages, but I have created a git repository for the code: 
https://github.com/dlfnation/swagr/tree

I&#8217;ve also purchased Aaron Hillegass&#8217; Cocoa Programming for Mac OS X (Third Edition) to help guide me [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started working on a new project I&#8217;m calling swagr. swagr will be an open source Cocoa usenet newsreader.  The project is in the very early stages, but I have created a git repository for the code: </p>
<p>https://github.com/dlfnation/swagr/tree</p>
<p><img src='http://tbn0.google.com/images?q=tbn:ySP5Od2yXJGwOM:http://images.barnesandnoble.com/images/26770000/26778178.JPG' alt='Cocoa Book' class='alignnone' /></p>
<p>I&#8217;ve also purchased Aaron Hillegass&#8217; Cocoa Programming for Mac OS X (Third Edition) to help guide me through the process.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trevorberg.com/2008/07/19/swagr-a-cocoa-open-source-nntp-reader/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BinaryURL Launches!</title>
		<link>http://blog.trevorberg.com/2008/07/07/binaryurl-launches/</link>
		<comments>http://blog.trevorberg.com/2008/07/07/binaryurl-launches/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 04:53:56 +0000</pubDate>
		<dc:creator>Trevor</dc:creator>
		
		<category><![CDATA[Rails]]></category>

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

		<guid isPermaLink="false">http://blog.trevorberg.com/?p=10</guid>
		<description><![CDATA[I always forget I have a blog where I&#8217;m supposed to announce everything that I do.  
I spent a few hours the last couple of days working on a fun little small project called BinaryURL.  It does pretty much the opposite of tinyurl, converts a url to a binary string.  
check it [...]]]></description>
			<content:encoded><![CDATA[<p>I always forget I have a blog where I&#8217;m supposed to announce everything that I do.  </p>
<p>I spent a few hours the last couple of days working on a fun little small project called BinaryURL.  It does pretty much the opposite of tinyurl, converts a url to a binary string.  </p>
<p><a href="http://binaryurl.com">check it out</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trevorberg.com/2008/07/07/binaryurl-launches/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Great List of Computer Science Resources</title>
		<link>http://blog.trevorberg.com/2008/06/22/a-great-list-of-computer-science-resources/</link>
		<comments>http://blog.trevorberg.com/2008/06/22/a-great-list-of-computer-science-resources/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 03:34:43 +0000</pubDate>
		<dc:creator>Trevor</dc:creator>
		
		<category><![CDATA[Computer Science]]></category>

		<guid isPermaLink="false">http://blog.trevorberg.com/?p=9</guid>
		<description><![CDATA[Geeknews.net has posted a great list of Computer Science resources in case there&#8217;s something you need to brush up on.
I was looking up a computer science term on Wikipedia the other week and as is wont to happen, one thing led to another and I was about 5 or 6 articles deep on a trail [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.geeknews.net">Geeknews.net</a> has posted a great list of Computer Science resources in case there&#8217;s something you need to brush up on.</p>
<blockquote><p>I was looking up a computer science term on Wikipedia the other week and as is wont to happen, one thing led to another and I was about 5 or 6 articles deep on a trail of discovery and research to build up my knowledge.</p>
<p>As I realized I was randomizing myself and getting way off the original track, I decided to start assembling the links in one location for my own reference if not some other geek without the funds for their own degree.</p>
<p>Yes, there’s much more that I don’t have below, I wound up throttling back quite a bit after a while to leave it as is…for now.</p></blockquote>
<p><a href="http://www.geeknews.net/2008/06/21/who-needs-a-computer-science-degree-when-theres-wikipedia">&raquo; View the list</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trevorberg.com/2008/06/22/a-great-list-of-computer-science-resources/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Answer the following</title>
		<link>http://blog.trevorberg.com/2008/06/21/answer-the-following/</link>
		<comments>http://blog.trevorberg.com/2008/06/21/answer-the-following/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 03:55:58 +0000</pubDate>
		<dc:creator>Trevor</dc:creator>
		
		<category><![CDATA[Puzzle]]></category>

		<guid isPermaLink="false">http://blog.trevorberg.com/?p=8</guid>
		<description><![CDATA[I saw this on a job application, and I thought it was clever. You CS people shouldn&#8217;t have too hard of a time answering it. 
Answer the following:
147 50 61 65 51 75 77 73 147 50 156 51 75 147 50 156 55 61 51 136 62 55 61 56 71 73 147 50 60 [...]]]></description>
			<content:encoded><![CDATA[<p>I saw this on a job application, and I thought it was clever. You CS people shouldn&#8217;t have too hard of a time answering it. </p>
<p>Answer the following:</p>
<p>147 50 61 65 51 75 77 73 147 50 156 51 75 147 50 156 55 61 51 136 62 55 61 56 71 73 147 50 60 51 75 60</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trevorberg.com/2008/06/21/answer-the-following/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BDD with Shoulda</title>
		<link>http://blog.trevorberg.com/2008/06/13/bdd-with-shoulda/</link>
		<comments>http://blog.trevorberg.com/2008/06/13/bdd-with-shoulda/#comments</comments>
		<pubDate>Fri, 13 Jun 2008 23:41:11 +0000</pubDate>
		<dc:creator>Trevor</dc:creator>
		
		<category><![CDATA[BDD]]></category>

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

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

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

		<guid isPermaLink="false">http://blog.trevorberg.com/?p=7</guid>
		<description><![CDATA[Over the past few days I&#8217;ve been looking at some of the plugins/frameworks that can be used with rails to improve testing. I came across this video of Tammer Saleh giving a presentation titled &#8220;BDD with Shoulda&#8221; at MountainWest RubyConf 2008.  He did a good job giving a brief intro to Shoulda, fixtures, and good testing practices.  For [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past few days I&#8217;ve been looking at some of the plugins/frameworks that can be used with rails to improve testing. I came across this video of <span class="caption">Tammer Saleh</span> giving a presentation titled &#8220;BDD with Shoulda&#8221; at <a href="http://mwrc2008.confreaks.com">MountainWest RubyConf 2008</a>.  He did a good job giving a brief intro to <a href="http://www.thoughtbot.com/projects/shoulda">Shoulda</a>, fixtures, and good testing practices.  For anyone who doesn&#8217;t know about <a href="http://www.thoughtbot.com/projects/shoulda">Shoulda</a>:</p>
<blockquote><address>The Shoulda Rails plugin makes it easy to write elegant, understandable, and maintainable tests. Shoulda consists of test macros, assertions, and helpers added on to the Test::Unit framework. It’s fully compatible with your existing tests, and requires no retooling to use.   </p>
<p><strong>Helpers</strong> – context and should give you rSpec like test blocks. In addition, you get nested contexts and a much more readable syntax.</p>
<p><strong>Macros</strong> – Generate hundreds of lines of Controller and ActiveRecord tests with these powerful macros. They get you started quickly, and can help you ensure that your application is conforming to best practices.</p>
<p><strong>Assertions</strong> – Many common rails testing idioms have been distilled into a set of useful assertions.</p>
</address>
</blockquote>
<p>The presentation is a little over an hour long, but I think it&#8217;s definitely worth a watch.</p>
<p><a href="http://mwrc2008.confreaks.com/videos/12saleh_640x240.mp4">BDD with Shoulda</a> - Tammer Saleh at <a href="http://mwrc2008.confreaks.com">MountainWest RubyConf 2008</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trevorberg.com/2008/06/13/bdd-with-shoulda/feed/</wfw:commentRss>
<enclosure url="http://mwrc2008.confreaks.com/videos/12saleh_640x240.mp4" length="95853539" type="video/mp4" />
		</item>
	</channel>
</rss>
