My Jabber Status
You are not Free until you act Free.

RSpec matcher helper

| |

I've finally written more than one RSpec matcher. Creating a matcher essentially involves defining a class and a method that creates an instance of that class. Rather redundant, resulting in my RSpec matcher helper:

def defmatcher(name, &code)
  klass = Class.new
  klass.module_eval(&code)
  
  Object.send :define_method, name.to_s do |*args|
    klass.new(*args)
  end
end

That little method, defmatcher, creates the class and method for you. It saves some typing. An example can be found in the full source file, available here.

Update (2008/06/28): RSpec was having trouble keeping this all in one file. I created a project at GitHub to host this for the time being: http://github.com/sneakin/spec_matcher_helper/

Experiments with Erlang

| | |

Earlier today I setup an instance of HgWeb to host some old and new code bases of mine. Two of the repositories may interest those learning or looking to learn Erlang. Both repositories contain a simple project that doesn't amount to much of anything at the moment, though they could prove useful for some code reading/banging.

The two repositories are:

  • Station: This is a super basic, simple HTTP server framework. It can currently parse an HTTP request which gets dispatched to a station behavior that you can define. The station behavior contains a function that gets called on each valid request and returns a response which is sent back to the requestor. Proper query string and form handling still needs to be done along with dispatching to different modules based on the requested path.
  • mod_rest: This is an ejabberd module that adds an HTTP handler that allows HTTP clients to literally post arbitrary message stanzas to ejabberd. Those stanzas then get shoved through ejabberd's router just like any other stanza. My original use for this was to allow a Rails app to send messages through ejabberd without needing to be a full XMPP client.

You will need to install Mercurial to get the code onto your machine. It's the next best thing to git.

Dot Plots: A Coder's Towel

|

I just slapped together a dot plotter after scanning through Object-Oriented Reengineering Patterns. That book describes the use of dot plots to detect duplicated code. While it's a bit like reading tea leaves, it is a good detector as the following two plots of dotplotter.rb against itself show with the huge run down the middle:

Dot Plot of dotplotter.rb against itself in Ruby mode (-r) Dot Plot of dotplotter.rb against itself in Line mode (-r)

The first is dotplotter.rb running with the "-r" option which compares tokens to tokens thus making each row/column a token such as "def". The second, smaller one is in line mode, "-l", which compares lines with lines. That makes each row/column an actual line in the source file.

The huge diagonal line through the middle indicates a huge run of duplicated code. That's because it's the same file against itself. Now if these were separate files, then the runs would hopefully not exist since any such run indicates duplication.

The dot plot script can be found at the following site. It requires RMagick and ParseTree to work: http://nolan.eakins.net/code/dotplotter.rb

A Conservative iChat

|

I just ran into a problem with iChat that would probably leave most mystified. I found out due to some unknown reason that iChat is very picky about the XML contained in its rosters. It doesn't ignore errors. Instead it just kicks you off saying that you have lost your connection.

The little snippet that was the culprit was a roster entry with a namespaced attribute:

<item jid='***@gmail.com' name='***' gr:t='B' subscription='both'/>

I'm not sure where that "gr:t" attribute came from, but that appears to have been iChat's choker. The only reason I noticed that was with Apple's Console utility. iChat was spitting out error messages to the system.log which included a block of XML that caused parse error 27, whatever that error means.

To get iChat working I had to use another client to remove and readd that roster entry. Not good for the neophytes.

I am left with a couple of questions though. Who uses the "gr:t" attribute, and what's it for? And can iCh

Bitter

| | |

I slipped up a new site bitter.nolan.eakins.net the other day. It's my take on the don't make me think blog. I've already implemented a basic web interface and just slapped together an XMPP bot that makes Bitter much easier to use. There's a lot that I've left out, but I put a Bazaar repository up if anyone wants to play.

Self-consciousness

|

Couldn't pass up passing this along:

Looks like the Internet has reached self-consciousness.

And hey! This is my first blog in a while. Weeeeee!!!

IETF Dups Again

Lemonade was brought to my attention for the guy I'm doing work for. It's a set of IMAP extensions that make IMAP more suitable for mobile phones and devices. Some of their goals obviously overlap with the work the XMPP/Jabber community has been doing. The most obvious being the extensions to handle streaming multimedia content. Looking through their list of goals in their charter, practically every item seems to be handled one of our RFCs or XEPs already. Perhaps its time for the IETF's left hand to check up on its right hand.

eXtreme Programming Gone Wrong

|

This is what eXtreme Programming looks like when it goes wrong with way too many index cards or in this case Post-It notes:

XP Gone Wrong

Steve Buyer Is Afraid To Debate

|

In only a few weeks Hoosiers will be able to vote on who should be their representative in Washington, and the Hoosiers of the fourth district still haven't witnessed a debate between Steve Buyer, our current representative, and Dr. David Sanders, the Democratic challenger. Dr. Sanders has invited Mr. Buyer to hold a debate between the two so that the voters of the fourth district can make an informed decision this election. But Steve Buyer has not accepted Dr. Sanders' invitation for an open and honest debate.

A voter has to ask why would Mr. Buyer not be willing to debate? There could be one reason why he has refused to debate Dr. Sanders: he's afraid to face the facts and take responsibility for what he's done as chair of the Veterans' Affairs Committee.

As I've helped Dr. Sanders' campaign, I keep learning more and more about how Mr. Buyer, as chair of the Veterans' Affairs Committee, has done more harm than good to the Veterans of our great nation. Mr. Buyer has done such harm that nearly every veteran, minus Mr. Buyer himself, hates the job he's doing.

I learned quite a bit about the horrible job Mr. Buyer is doing this past Monday, September 25th, when former Senator Max Cleland spoke in support of Dr. Sanders. From what Senator Cleland stated: Mr. Buyer has continually refused to allow veterans' organizations created by Congress to testify before Congress, has failed to equip the VA with proper funding for the veterans that are returning from Iraq and Afghanistan, and has continuously supported cuts to the benefits that we have promised our veterans.

Perhaps that's why Mr. Buyer has not accepted Dr. Sanders' invitation to a debate--he's afraid the truth will be known that he genuinely does not support our troops.

Intellectual Property and oDesk

| |

I followed the link TechCrunch posted to oDesk since I need some work. I found some job posting that I found interesting and proceeded to sign up. Low and behold the first service agreement I read just wasn't palatable. From my understanding of their Professional Services Agreement, any pre-existing intellectual property that is incorporated into a project can essentially be used for whatever purposes oDesk wants.

I wouldn't have an issue if this granted a license to the company that has requested the work, but it is oDesk—the site that connects professionals with those that need work done. I have a body of code that's gradually getting larger that allows me to be more productive, and I like to set my own terms on its use. Sorry, I won't grant an unlimited license to it to a company whose unstated business is to hoarde IP.

Ad's by Google