Ruby <= You are Awesome!

I was just making some updates to the Ruby client I wrote for the Splunk REST API and wanted to point out one of the most wonderful facets of the language: The ability to dynamically generate methods to support a more natural interface.

Take this standard XML response from Splunk’s REST interface for search results:

Normally, using Nokogiri or another XML parsing library, you would need to do this to access the list of hosts (and any other Splunk field):

@doc = Nokogiri.parse(xmlResponse)
@doc.results.result.each do |result|
puts result.field("[@k=\"host\"]").value.text

Yuck! Especially when the response format is standard and predictable. Enter Ruby’s awesome overrides and the method_missing method. Using the method_missing method, we can intercept what would normally be an exception and dynamically respond to method calls for Splunk fields without actually having to write those methods.

Now I can access those XML fields with a simple method call, in this case .host:

job.parsedResults.each do |result|
puts #Or any other field!

Cool, huh? Can’t do that in Java. Check-out the library on Github.

Posted in code | Leave a comment

Ruby REST Client for Splunk

Splunk has decent documentation regarding their REST API, however the Ruby example uses Hipricot, which like many of the XML parsers in existence has a learning curve.

After a few more hours of Googling, I wasn’t able to find any decent examples using Ruby and the Splunk API. The Hipricot example didn’t look very straightforward and I decided to re-write it using Nokogiri and the wonderful Slop feature.

v0.1 code and documentation located on GitHub:


Posted in code | Tagged , , , , | Leave a comment

Review: Rework

Rework by Jason Fried
My rating: 4 of 5 stars

Pick this up if you are thinking of starting your own company, or department. Provides a number of little vignettes regarding how to treat your employees, customers and culture. Throw out the mentality that bigger is better. Faster, simpler and honesty is better.

View all my reviews

Posted in general | Leave a comment

Review: Atlas Shrugged

Atlas ShruggedAtlas Shrugged by Ayn Rand
My rating: 3 of 5 stars

One of the most intellectually challenging books I have ever read. Funny how I finished this on July 4th! Her thoughts are especially relevant in the modern age.

I like a lot of Ayn’s philosophy, but why use 1100 pages when you can use 400? I do fault the book for being a bit too wordy during the impassioned speeches. There was a lot of redundancy and overlap and the story (which was excellent) could have progressed a bit more (especially in the early parts of the book) if characters did not feel the need to give 54 page monologs.

Perhaps all of our leaders have not read what she has to say, given the length of her work. She does have another book, "For the New Intellectual" which takes the salient points of her philosophy and the character monologs and breaks them down into little quotable chunks. You can use those at your next rally.

View all my reviews

Posted in general | Leave a comment

burgers. delicoius.

I NEED to be taken around the country to try all of these delicious styles:

On a more realistic note, I hear Shake Shack is coming to Philly. Finally! Although they seem to be late for the burger Renaissance here. Not sure if they will unseat my much loved P.Y.T,  Cavanaugh’s Rittenhouse or Square Burger.

Posted in food | Leave a comment

2011 til date

Major updates:

  • Jan – March: I did P90X and then stopped.
  • In March I went to Barcelona, Granada and Madrid Spain. I enjoyed copious amounts of food and took many pictures. Even now I am craving some chorizo, queso and eggs. (I miss you Taller Tapas…)
  • In April my job moved from the suburbs into Center City, which makes me immensely happy and shortened by commute by a collective hour and a half each day. Sadly, I have managed to fill that time with more working.
  • Phone was stolen, so I got an htc thunderbolt. <3.
  • In May I went to India for two weeks. It was hot and I got sick.
  • I bought a Groupon for ‘The Economist’ so I could keep tabs on all of the things wrong with the modern world.
  • I have developed a serious addiction to Seltzer water. (It’s tingly!)
  • The world didn’t end on May 21st.

In the next few weeks I’m planning trips to Denver and Chicago.

In the very immediate term I am considering making a ‘No Bake’ cheesecake and eating the whole thing for lunch (just because I can…)

Posted in europe, food, general, life, philly, vacation, work | Leave a comment


So, yeah… Utter failure when you consider the fact that I haven’t touched this thing since December.

Work has gotten progressively busier and every week crazier than the previous. Honestly as each milestone has approached I (naively) thought that things would calm down, however it really just means we are on the road to the next milestone and we have to be even more insane than before!

I know, I know… no excuse.  Sitting at home with not much to do today… perhaps I’ll find a new theme for this bad boy.

Posted in work | Leave a comment