<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>cowboyrushforth.com</title>
    <link>http://cowboyrushforth.com/entries/feed</link>
    <description>spotman's adventures</description>
    <language>en-us</language>
    <item>
      <title>consistent hash ring in node.js</title>
      <description>If you ever need to create a &lt;a href="http://martinbroadhurst.com/Consistent-Hash-Ring.html"&gt;consistent hash ring&lt;/a&gt; in &lt;a href="http://nodejs.org/"&gt;node.js&lt;/a&gt;, this may help you.  This is compatible with &lt;a href="https://github.com/ezmobius/redis-rb"&gt;redis-rb'&lt;/a&gt;s dht algorithm.  This is not well tested yet, but in preliminary tests it is working good.  Thanks to &lt;a href="http://stackoverflow.com/questions/4483952/nodejs-consistent-hash-library"&gt;this&lt;/a&gt; stackoverflow post for the crc32 algo. Future improvements may include parts of this re-done as a c module for added speed.  Currently I am not using this per inbound request, only once per server start, so speed is less of an immediate priority.  Enjoy!&lt;br/&gt;&lt;Br/&gt;
&lt;pre&gt;
this.ring = {};
this.sorted_keys = [];

this.generateRing = function(servers) {
  for(var j = 0; j &lt; servers.length; j++) {
    this.addServerToRing(servers[j]);
  }
}

this.addServerToRing = function(server) {
  for(r = 0; r &lt; 160; r++) {
      key = this.crc32("redis://"+server+"/0:"+r);
      this.ring[key] = server;
      this.sorted_keys.push(key);
  }

  this.sorted_keys.sort(function (a, b) {
    return a-b;
  });
}

this.getServer = function(key_query) {
  key = this.crc32(key_query);
  index = this.ringSearch(key);
  return this.ring[this.sorted_keys[index]];
}

this.ringSearch = function(val) {

  var upper = this.sorted_keys.length - 1;
  var begin = upper;
  var lower = 0;
  var k = 0;

  while(lower &lt;= upper) {
    k = parseInt(((lower + upper) / 2),10);
    idx = this.sorted_keys[k];

    if(idx == val) {
      return k;
    } else if ( idx &gt; val ) {
      upper = k - 1;
    } else {
      lower = k + 1;
    }
  }

  if(upper &lt; 0) {
    upper = begin;
  }
  return upper;
}


this.crc32 = (function() {
    function utf8encode(str) {
        var utf8CharCodes = [];

        for (var i = 0, len = str.length, c; i &lt; len; ++i) {
            c = str.charCodeAt(i);
            if (c &lt; 128) {
                utf8CharCodes.push(c);
            } else if (c &lt; 2048) {
                utf8CharCodes.push((c &gt;&gt; 6) | 192, (c &amp; 63) | 128);
            } else {
                utf8CharCodes.push((c &gt;&gt; 12) | 224, ((c &gt;&gt; 6) &amp; 63) | 128, (c &amp; 63) | 128);
            }
        }
        return utf8CharCodes;
    }

    var cachedCrcTable = null;

    function buildCRCTable() {
        var table = [];
        for (var i = 0, j, crc; i &lt; 256; ++i) {
            crc = i;
            j = 8;
            while (j--) {
                if ((crc &amp; 1) == 1) {
                    crc = (crc &gt;&gt;&gt; 1) ^ 0xEDB88320;
                } else {
                    crc &gt;&gt;&gt;= 1;
                }
            }
            table[i] = crc &gt;&gt;&gt; 0;
        }
        return table;
    }

    function getCrcTable() {
        if (!cachedCrcTable) {
            cachedCrcTable = buildCRCTable();
        }
        return cachedCrcTable;
    }

    return function(str) {
        var utf8CharCodes = utf8encode(str), crc = -1, crcTable = getCrcTable();
        for (var i = 0, len = utf8CharCodes.length, y; i &lt; len; ++i) {
            y = (crc ^ utf8CharCodes[i]) &amp; 0xFF;
            crc = (crc &gt;&gt;&gt; 8) ^ crcTable[y];
        }
        return (crc ^ -1) &gt;&gt;&gt; 0;
    };
})();
&lt;/pre&gt;</description>
      <category>code</category>
      <pubDate>Fri, 03 Jun 2011 11:00:00 -0700</pubDate>
      <link>http://cowboyrushforth.com/2011-06-03/consistent_hash_ring_in_node-js</link>
      <guid>http://cowboyrushforth.com/2011-06-03/consistent_hash_ring_in_node-js</guid>
    </item>
    <item>
      <title>Altly Begins</title>
      <description>Since the last update, I have quit my job, moved to the beach, and started a &lt;a href="http://www.altly.com"&gt;company&lt;/a&gt; with a small team of awesome people.   For the first time in quite some time, I am getting a lot of fresh air and sun light regularly, and it is an awesome thing. 
&lt;Br/&gt;&lt;Br/&gt;Reserve your username today!  More details soon :)
 &lt;a href="http://www.altly.com"&gt;&lt;img src="http://cowboyrushforth.com/altly-logo.jpg" title="Altly Logo" width="300" class="floatTR"/&gt;&lt;/a&gt;&lt;br/&gt;&lt;Br/&gt;&lt;Br/&gt;</description>
      <category>work</category>
      <pubDate>Thu, 19 May 2011 21:01:00 -0700</pubDate>
      <link>http://cowboyrushforth.com/2011-05-19/Altly_Begins</link>
      <guid>http://cowboyrushforth.com/2011-05-19/Altly_Begins</guid>
    </item>
    <item>
      <title>zeromq adventures and linkfinder</title>
      <description>&lt;img class="floatTL" src="http://cowboyrushforth.com/zeromq.gif" /&gt; I have been hearing about &lt;a href="http://www.zeromq.org/"&gt;ZeroMQ&lt;/a&gt; for a bit now, but had never really dug in until 72 hours ago.  I must say, I am impressed.  Maybe I am easily amused (likely), or maybe I have just been having a good run with technology lately, but nevertheless, I will share a bit of my experience.&lt;br/&gt;&lt;Br/&gt;

What is ZeroMQ (aka '0mq') you ask?  At first glance it comes across as a networking library, but that is just the tip of the iceberg.  Once cracked open it is a concurrency library, networking library, and socket library all wrapped into one really simple and concise api.&lt;br/&gt;&lt;br/&gt;

Sounds like it is chalk full of features and bloatware, but right on the front of their &lt;a href="http://www.zeromq.org/"&gt;site&lt;/a&gt; they have &lt;b&gt;'Less is more'&lt;/b&gt; in big bold letters.  I like this concept in engineering most of the time.  Actually I like this concept applied to life itself most of the time.  Unless I am at a vegas buffet anyways. Hah!
&lt;Br/&gt;
&lt;br/&gt;
So I figured for a quick test trial of the library I would write a service in C that returns links in a given webpage.  One or more clients will connect to the service and send a url that it would like scanned.  This url is then downloaded, parsed, and the links in it, if any, are returned in JSON format.
&lt;br/&gt;&lt;Br/&gt;
Without further ado, check it out on github: &lt;a href="https://github.com/cowboyrushforth/linkfinder"&gt;https://github.com/cowboyrushforth/linkfinder&lt;/a&gt;.  Turned out to be about 245 sloc and only took a few spare hours to write.  How it is setup is that the main thread has one big event loop that 0mq runs and accepts requests.  These requests go into a queue that one of 4 worker threads pick up.  The worker picks up a request, does all the downloading, parsing, and then sends the request back  to the mainthread which then delivers it to the client.  It could use a bit of additional error handling thought, but is incredibly simple.
&lt;br/&gt;&lt;Br/&gt;
If your feeling like a technologically inspirational read, check out the &lt;a href="http://zguide.zeromq.org/page:all"&gt;ZeroMQ&lt;/a&gt; guide.  It is very comprehensive and really shows the full potential of the library. &lt;Br&gt;&lt;br&gt;Cheers!</description>
      <category>code</category>
      <pubDate>Thu, 07 Apr 2011 20:49:00 -0700</pubDate>
      <link>http://cowboyrushforth.com/2011-04-07/zeromq_adventures_and_linkfinder</link>
      <guid>http://cowboyrushforth.com/2011-04-07/zeromq_adventures_and_linkfinder</guid>
    </item>
    <item>
      <title>on node.js, trendy technology, and the development community</title>
      <description>Ok, so I have dived into node.js, as seen on my recent &lt;A href="http://cowboyrushforth.com/2011-03-19/MineSpotter_v0-0-1"&gt;entry&lt;/A&gt; on building a realtime, web based, minesweeper clone.   I dove into this mostly to just see what all the fuss is about, but I would be lying if I said I was not pleasantly surprised.  
&lt;br/&gt;&lt;Br/&gt;
This seems to be a topic that one must tread lightly about as node is getting &lt;a href="http://www.eflorenzano.com/blog/post/why-node-disappoints-me/"&gt;quite&lt;/a&gt; a &lt;a href="http://journal.paul.querna.org/articles/2010/06/12/node-js/"&gt;bit&lt;/a&gt; of &lt;a href="http://ncannasse.fr/blog/is_nodejs_wrong"&gt;flack&lt;/a&gt; as well as quite a &lt;a href="http://journal.paul.querna.org/articles/2010/06/12/node-js/"&gt;few&lt;/a&gt;
&lt;a href="http://debuggable.com/posts/understanding-node-js:4bd98440-45e4-4a9a-8ef7-0f7ecbdd56cb"&gt;praises&lt;/a&gt; and success 
&lt;a href="http://bostinnovation.com/2011/01/15/who-is-using-node-js-and-why-yammer-bocoup-proxlet-and-yahoo/"&gt;stories&lt;/a&gt;.  Seems like a love/hate relationship with no counselor!  Why the great divide?
&lt;br/&gt;&lt;Br/&gt;
My goal in writing this is to just outline both sides of the story and hopefully give a fairly neutral opinion on the matter but shining some light on all angles.  So here goes: (continued after break)</description>
      <category>code</category>
      <pubDate>Sat, 19 Mar 2011 16:30:00 -0700</pubDate>
      <link>http://cowboyrushforth.com/2011-03-19/on_node-js:_trendy_technology:_and_the_development_community</link>
      <guid>http://cowboyrushforth.com/2011-03-19/on_node-js:_trendy_technology:_and_the_development_community</guid>
    </item>
    <item>
      <title>MineSpotter v0.0.1</title>
      <description>So with all the excitement in the &lt;a href="http://nodejs.org"&gt;node.js&lt;/a&gt; community, I thought I would see what all the fuss is about, so I went to work on my first node.js application, MineSpotter.
&lt;br/&gt;&lt;Br/&gt;
MineSpotter is essentially a minesweeper clone, but heavily inspired by a website called &lt;a href="http://wordsquared.com"&gt;WordSquared&lt;/a&gt;.  MineSpotter is to MineSweeper as WordSquared is to Scrabble.  Ultimately the game is designed to have an infinitely expanding board, and can be played in realtime, with multiple players.&lt;br/&gt;&lt;br/&gt;
MineSpotter was built using node.js, along with a node library called &lt;a href="https://github.com/substack/dnode"&gt;DNode&lt;/a&gt; on top of the geospatial features of &lt;a href="http://mongodb.org"&gt;MongoDB&lt;/a&gt;.&lt;Br/&gt;&lt;Br/&gt;
Still have a lot of things to finish, such as a leader board, facebook connect, and more work on flagging and explosions, but the core gameplay is pretty much completed.&lt;br/&gt;&lt;Br/&gt;
Source is up at github &lt;a href="http://github.com/cowboyrushforth/minespotter"&gt;here&lt;/a&gt; for your reading and hacking pleasure, and thanks to &lt;a href="http://duostack.com"&gt;DuoStack&lt;/a&gt; I have been able to get some free hosting for it.  &lt;Br/&gt;&lt;Br/&gt;
Check it out at &lt;a href="http://play.minespotter.com"&gt;http://play.minespotter.com&lt;/a&gt;!</description>
      <category>code</category>
      <pubDate>Sat, 19 Mar 2011 09:57:00 -0700</pubDate>
      <link>http://cowboyrushforth.com/2011-03-19/MineSpotter_v0-0-1</link>
      <guid>http://cowboyrushforth.com/2011-03-19/MineSpotter_v0-0-1</guid>
    </item>
    <item>
      <title>new adventures</title>
      <description>In Seattle for my new gig for a couple weeks, and looks like I will be coming up here regularly for a few more weeks.  Definitely living life in the fast lane, but trying to balance it between the moist northwest,  the dry high desert, and the busy metropolis of LA turns out to be pretty fun.   Here is a few snaps from some recent adventures:
&lt;Br/&gt;&lt;BR/&gt;
Crazy wall covered in gum at Pike Place, Seattle.  Very awesome and very nasty:&lt;br/&gt;
&lt;img src="/images/oct10/pikeplacegumwall.jpg" class="floatCenter" alt="Pike place gum wall" title="pike place gum wall" /&gt;&lt;br/&gt;

high desert Lightning storm:&lt;br/&gt;
&lt;img src="/images/oct10/desertlightning.jpg" class="floatCenter"  alt="high desert lightning" title="high desert lightning storm" /&gt;&lt;br/&gt;

red vortex sunrise:&lt;Br/&gt;
&lt;img src="/images/oct10/vortexsky.jpg" class="floatCenter" alt="red vortext sunrise" title="Red vortext sunrise" /&gt;
&lt;br/&gt;


</description>
      <category>life</category>
      <pubDate>Sat, 23 Oct 2010 15:22:00 -0700</pubDate>
      <link>http://cowboyrushforth.com/2010-10-23/new_adventures</link>
      <guid>http://cowboyrushforth.com/2010-10-23/new_adventures</guid>
    </item>
    <item>
      <title>phenomenal</title>
      <description>Burning Man was epic once again.  &lt;img src="/bm2010.jpg" class='floatTL' title="double rainbow" /&gt;  What can I say.  From the insane flaming bar that our camp built, to being able to play to hundreds of people during one of the most epic sunsets of my life, words really just do not do it justice.  Coming back into the real world was once again very intense in many different ways from logistically to emotionally.  But alas I have finally returned, and while there is pieces of my mind and soul that are still far from home, overall I have re-assimilated into society as much as I am probably going to, and onward ho!&lt;Br/&gt;&lt;br/&gt;
&lt;img src="/bm2010barrel.jpg" class="floatTR"  title="bat burn barrel in action" /&gt;&lt;br style="clear: right;"/&gt;
On on that note, shortly after my return this year I was given the exciting opportunity to come on board &lt;a href="http://www.myspace.com"&gt;MySpace.com&lt;/a&gt; as a full time senior engineer, so life will be shifting around a bit for me here very shortly.  I have been primarily working from home for the past 4+ years, so going back to working with people and not being such a caveman I am looking forward too, as well as working on some really big projects.&lt;br/&gt;</description>
      <category>life</category>
      <pubDate>Wed, 06 Oct 2010 22:43:00 -0700</pubDate>
      <link>http://cowboyrushforth.com/2010-10-06/phenomenal</link>
      <guid>http://cowboyrushforth.com/2010-10-06/phenomenal</guid>
    </item>
    <item>
      <title>mid summer stretch</title>
      <description>Sometimes, well a lot of the times, life is weirdly pleasant.  Just as I had started to dig in with my spare time and find other ways to up my game and find interesting things to do, I have gotten hit with quite a freight train of work you could say.&lt;br/&gt;&lt;br/&gt;
So lately I have been laying low, trying to get all my ducks in a row, and coincidentally, I have not been learning how to sew.  I did manage to however have enough free time to make this mix last weekend, and finally it is on sound cloud for your downloading pleasure.  &lt;br/&gt;&lt;br/&gt;
&lt;object height="81" width="100%"&gt; &lt;param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fspotman%2F724-1"&gt;&lt;/param&gt; &lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt; &lt;embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fspotman%2F724-1" type="application/x-shockwave-flash" width="100%"&gt;&lt;/embed&gt; &lt;/object&gt;  &lt;span&gt;&lt;a href="http://soundcloud.com/spotman/724-1"&gt;724&lt;/a&gt; by &lt;a href="http://soundcloud.com/spotman"&gt;spotman&lt;/a&gt;&lt;/span&gt; 
&lt;br/&gt;&lt;br/&gt;
Other than that, I am not sure how long this flood of work will last, but I am going to milk it up while I can.  Only 30 days or so until I leave for burning man which is insane and awesome at the same time.  This year I will definitely be gone a whole week, but not sure how much more than that I will have time for.  Very excited about the &lt;a href="http://www.visitbatcountry.com"&gt;camp&lt;/a&gt; this year though :)&lt;br/&gt;&lt;Br/&gt;Thats all I got for now.  Enjoy!</description>
      <category>life</category>
      <pubDate>Thu, 29 Jul 2010 18:46:00 -0700</pubDate>
      <link>http://cowboyrushforth.com/2010-07-29/mid_summer_stretch</link>
      <guid>http://cowboyrushforth.com/2010-07-29/mid_summer_stretch</guid>
    </item>
    <item>
      <title>oil spills suck but math does not</title>
      <description>Life has been weird lately to say the least.  The &lt;a href="http://en.wikipedia.org/wiki/Deepwater_Horizon_oil_spill"&gt;oil spill&lt;/a&gt; really is very sad and unfortunate, and it seems like  there has been &lt;a href="http://en.wikipedia.org/wiki/2010_Haiti_earthquake"&gt;quite&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/2010_Chile_earthquake"&gt;a&lt;/a&gt;&lt;a href="http://www.washingtonpost.com/wp-dyn/content/video/2010/06/01/VI2010060101229.html"&gt;bit&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/2010_eruptions_of_Eyjafjallaj&#246;kull"&gt;of&lt;/a&gt; &lt;a href="http://www.nytimes.com/2010/05/29/world/americas/29volcano.html"&gt;natural disasters&lt;/a&gt; recently too which is a bummer.  On top of that, I have for better or for worse, come to the realization that (imo) the economy is probably never going to go back to the good ol' days.  I hypothesize it will probably make a very slow recovery as some of the other glooming problems in our country are slowly resolved.  When people are all employed and things start picking up, I suspect people will be spending their money in different ways. 
&lt;br&gt;&lt;br&gt;
Taking that all into consideration, I was sort of feeling bummed for a bit.  Business has been slow and tedious as we as a small company try to pick up new clientele. It seems as though everyone is trying to cut corners and just try to stay afloat right now.  In previous years, our company has thrived from the constant desire of any business to turn their ideas into a reality.  We specialize in providing custom software and we will turn anyone's idea into a good program.  These days, people do not want to innovate as much, and the ones that do, have a large pool of people like us to pick from currently.  It is a hard game out there. &lt;br&gt;&lt;br&gt;
Recently though, I have decided to not just going to sit around and pout about it.  As things evolve around me, I must evolve too.  So I have decided to arm myself with a significant amount more math.  Math is one thing that when you are a kid you just have no clue how this will apply to your life later.  You also probably don't (or maybe you do) think sitting around all day writing code is fun, but turns out it can be extremely rewarding at times.  I feel like math is one area that I did not take seriously enough as a kid, and now in my career choice I am finally starting to pay for it as I want to expand my programming into different realms.&lt;Br&gt;&lt;br&gt;
I am not going back to school or anything extreme like that, but believe it or not I have hired a personal tutor, and plan to be really hone my skills in linear algebra, trigonometry and calculus into hopefully a sharp toolset that will help me take my coding to new places. &lt;br&gt;&lt;br&gt;
Besides all that jibber jabber of work/career/etc, I am also still trying to have some fun.  I will be going to &lt;a href="http://www.element11.org/"&gt;element11&lt;/a&gt; here in just another week where Bat Country will be representin' and I will get another chance to DJ, which is very exciting for me.  Hopefully I will remember to record my set this time!&lt;br&gt;&lt;br&gt;
That's all for now!
</description>
      <category>life</category>
      <pubDate>Wed, 02 Jun 2010 18:22:00 -0700</pubDate>
      <link>http://cowboyrushforth.com/2010-06-02/oil_spills_suck_but_math_does_not</link>
      <guid>http://cowboyrushforth.com/2010-06-02/oil_spills_suck_but_math_does_not</guid>
    </item>
    <item>
      <title>time flies fast</title>
      <description>Wow I can't believe we are almost 1/2 way through the year!  Life has been so busy it has been hard to keep up lately!  Lucky for me it's a pretty even split between work and play so I can't complain much!&lt;br/&gt;&lt;br/&gt;

Work wise we just launched our new &lt;A href="http://0x7a69.net"&gt;website&lt;/A&gt; to give us a bit fresher of a look, and we also just attended a tradeshow in hopes of drumming up some more business.  Other than that we have had an ebb and flow of business lately, but we have built some &lt;A href="http://0x7a69.net/experience"&gt;really cool things&lt;/A&gt; this year!
&lt;br/&gt;&lt;Br/&gt;

In other news, &lt;a href="http://www.visitbatcountry.com"&gt;Bat Country's&lt;/a&gt; &lt;A href="http://www.visitbatcountry.com/plan"&gt;final plan&lt;/A&gt; was submitted to Burning Man a couple weeks ago!  I am very excited about this year, and we have a ton of momentum so far.&lt;br/&gt;&lt;Br/&gt;
Thats it for now! &lt;br/&gt;
-s</description>
      <category>life</category>
      <pubDate>Tue, 04 May 2010 11:37:00 -0700</pubDate>
      <link>http://cowboyrushforth.com/2010-05-04/time_flies_fast</link>
      <guid>http://cowboyrushforth.com/2010-05-04/time_flies_fast</guid>
    </item>
  </channel>
</rss>

