Wednesday, December 16, 2009

Handling the Twitter Stream API with Ruby

I've been doing a lot of things with the Twitter API lately. More on that another time though. I started messing around with their stream API last night. It's pretty fun to play with and I wanted to put the code up somewhere so I can use it later. Right now it works, but it clearly isn't very robust. It needs retry logic and better error handling. Right now, it's just a toy :)

You'll need the json gem installed. Once you have that you can run the script like...
./twitter_stream.rb <username> <password>

Tuesday, September 29, 2009

Spymemcached Optimizations Followup

A couple days ago, Dustin Sallings, the other of the spymemcached Java client for memcached, posted an article on some optimizations done to the library. If you are currently using hibernate-memcached you may want to try out the latest spymemcached RC release.

If you combine the latest spymemcached RC release, with memcached 1.4 and the new binary protocol you should see significant performance increases. As Dustin didn't change anything about the spymemcached API it should be a drop in upgrade for you.

spymemcached Optimizations - Dustin Sallings



Thursday, September 24, 2009

Tales of a Bottom Feeder Recruiting Agency

I'm a moron. At least according to the well formed opinion of one Kevin Higgins of H.T. Associates. He formed this opinion after I repeatedly asked for his "Executive Search" firm to stop contacting me. Now, I've checked with a few authoritative sources, like my Mom and my Wife, and it turns out; I'm not a moron (my Wife did appear to be on the fence).

Last week sometime I was sitting at my desk sipping coffee (or beer I don't remember what time of day it was),and coding my way through my current iPhone project. I mention the iPhone project because it matters. I've been doing Java work my whole career, it got a bit mundane so I decided to switch things up. I'm currently doing Ruby and iPhone development at Interactive Mediums (plug! haha). I'm very happy where I'm at, and really excited about what I'm doing. Which is to say, I don't need recruiters contacting me about "Sr. Java this" and "Architect that". Most folks shoot an email, and I don't mind that, I file them away just in case.

I got just one such email from one Ryan Olson at H.T. Associates titled "Sr Architect Opportunity (Java)". I, of course, ignored it; not interested. So, as I said before, now I'm coding along happy and content when my phone rings. Most people don't have my cell number so I answer it without looking. I glance at the number as I'm raising the already accepted call to my ear and realizing I don't recognized the number think to myself "Shit, please don't be a recruiter".

Little did I know that I was going right into a high-speed-high-pressure-used-car-salesman-with-the-slick-hair trap. Ryan tells me who he is and asks me if this is a good time. You'd think this conversation would end here right? Of course not, where's the blog post in that? I tell Ryan, "No, I'm at work, now is not a good time". He simply responds that he understand and continues on like it never happened. What sort of caught me off-guard was not his high pressure pitch, or his disregard for my time; it was the immediate use of offshore fear mongering. Ryan started spewing all this stuff about how India and China were going to take my job, and how my very livelihood was in jeopardy if I didn't send him my resume. Sure, I'm exaggerating the wording here, but the intent was no less serious.

Once his initial pitch was complete he asked, again, if now was a good time to talk about all the wonderful opportunities available through H.T. Associates. I, once again, told him no, "Now is not a good time". It bounced off him like bullets off Superman. Again he declared that he understood, and again he went right into the high pressure pitch with more India and China are going to steal my Eggos stuff. Amazing. Left with no other recourse, I hung up on him.

Now, I'm brash, and I know this, but I can be a politician when I need to. I normally don't burn bridges with recruiters as you never know when you might need one. Believe it or not there are some good ones out there. I worked with one woman in the past who was absolutely awesome. I felt like a ball player with an agent. She gave up recruiting and went to go work for a Church. I'm not sure what that says about me. Anyway...

I was sort of upset after speaking with Ryan. I don't like being bothered on the phone, and I damn well don't like being forced to hang up on people. So I opened Ryan's prior email and replied...

Thanks for the call Ryan,
In the future; when someone says now isn't a good time, and they say it more than once, you should stop talking. Please remove my information from your system.


I don't know what I hoped to achieve by this really, maybe a contrite apology? This was the response I got...


I heard you once and understand. I was NOT asking you if you are willing on investigating a new position for you and your family. I did think you would be intelligent enough to at least hear about what is going on in the market at a time where the market has been crushed.

I was asking you if you would be kind enough to lead me into the right direction of those business professionals that would appreciate a call.

In the future when your job get’s offshored or outsourced and there are to many people for jobs feel free to leverage me a resource. You have a family to support and never know what may surface in the market so it’s good to know someone like myself in the event you have nay questions.

I wish you best with your career

Ryan Olson
Executive Recruiter

Baffling. You see the tone there right? You see I wasn't kidding about the call now right? But wait, there's more!

The very next day I get an email from my new fan, Kevin Higgins. The subject is "JAVA SW Engs & Architect Openings". Great another guy from the same company is now emailing me. I figure I better put the brakes on this guy before he calls my cellphone too. I replied...

I have already asked to be removed from your system once; just yesterday actually.
Please comply with my request. I am not interested inworking with your company.

(blame the iPhone for typos)

I noted that Kevin's title seemed a bit loftier than Ryan's, so I figure maybe this guy will listen. At first he seemed to be considerate of my plight. He replied with the following...


Thank you for your response although I am unhappy to hear you feel this way. As the managing partner for this 30 year Malcolm Baldrige Quality Award winning firm, I personally would like to reach out to you and understand what your concerns are. If my team has done something wrong, I would like to hear about it so I can address that and apologize to you as well. Please let me know your thoughts. Thanks Ray and best wishes to you.

Kevin Higgins
Managing Partner – Executive Search

I explained the high pressure pitch and the ridiculous offshore threats to Kevin and he again replies, somewhat sympathetically...

That is exactly the opposite of what I teach my team on how to comport themselves. I do not tolerate that type of behavior as I despise it. I think you can tell by how I have crafted my emails how serious I take treating people with respect. I sincerely apologize and I will address this issue immediately. I appreciate your thoughts and insight but again, I deeply apologize for this regrettable behavior. Thank you and please feel free to reach out to me personally if there is anything I can do. I do believe that I am good resource for you but and hope that we can overcome this situation. Thanks Ray and best wishes to you and I do look forward to hopefully engaging with you at some point.

Kevin Higgins
Managing Partner – Executive Search

I thought to myself, "Good that's all taken care of". A happy ending and these guys probably won't contact me any more. Of course, I was wrong...

Eleven days later I get an email from Rose, who appears from her signature, Kevin's assistant...

Good Afternoon Ray,

Thank you for send our company your resume. Would you be kind as to send me a copy of your resume in Word format?


Rose Ramos
Executive Assistant to Kevin Higgins

Now I'm getting a bit perturbed. Obviously there's no reason to take this out on poor Rose, so I forward it directly to Kevin cause he probably remembers me right? The entirety of my email was this...


Apparently Kevin doesn't remember me...

Ray—we need all resumes to be in a word format per our clients. Send it to me directly. Thanks Ray and I hope all is well. I may have something for you.

Kevin Higgins
Managing Partner – Executive Search

The point of my "Seriously?" comment was misinterpreted. I wasn't questioning the Word format, though I should, I was just shocked that they were still contacting me.

Now, I've already dealt with pushy, unprofessional tactics from these guys, so the nonsensical English was just fuel on the fire. I realize that English may be poor Rose's second language. But her email doesn't read that way, her email reads as if she were just rushed and not paying attention to what she was typing. If she works for Kevin, she's probably under a lot of pressure I'm betting. Anyway, here's my reply...

My point is that I am the angry engineer who didn't want to be contacted by your company. That's why I forwarded your assistants email, in all its broken English glory, along.

This is the last time I am going to say this. Remove all traces of me from your system.


Kevin's previous emails were sympathetic and worded well. He chose a different style for his final email...

Ray—you’re a moron.

Kevin Higgins
Managing Partner – Executive Search

I simply replied "Nice" and went for a walk.

Let this be a lesson to all my engineer friends out there. We all know that old phrase, "You only get one chance to make a first impression". Do you want guys like this making that first impression for you at a prospective employer?

Friday, September 18, 2009

iPhone QR Code Readers

I was playing around with some QR code readers for the iPhone. If you don't know what a QR code is you might recognize it as a crazy looking square full of smaller squares. Apparently these things are on everything in Japan, and are used to market products as well as presenting URLs.

I tried two so far this morning based on what Jeff Judge and Doug Barth at Interactive Mediums were playing with. Of the two, "Beetagg" and "QR App", QR App is the clear winner.

In order to get Beetagg to read a code it requires 4 clicks. One to launch it, two to start the scanner, 3 to snap the picture, and 4 to "Use" the picture. Lame...

QR App only takes one click. Launch it and the camera comes up automatically, point it at a tag and it recognizes it on it's own and acts. Very cool.

Sunday, September 13, 2009

Windy City Rails 2009

Yesterday I attended the Windy City Rails 2009 conference. This is the first conference I've attended in a few years. More notably it was my first Ruby related conference. I have to say, I loved the format most of all. The conference was only $99 to attend, there were no tracks and therefor no session overlap. It was a quick one day in and out affair with great speakers and really good material. There were also AM and PM tutorials that did overlap with the conference itself. The tutorials were a deep dive into one particular subject each. They were great for those that wanted to go that route, and though I'm not an expert in the respective subjects, I decided to stick to the conference itself. Also, the tutorials cost extra and I'm a huge cheap ass, so $99 it is :P. There was also a "Coding Dojo". This was an interesting gathering of folks pairing up to work on various challenges. I didn't visit, but it sounded like a neat idea.

Better Ruby through Functional Programming - Dean Wampler

This was the first session of the morning to kick things off. Functional programming is something I battle with. One part of me wants to do more with it, the other part of me gets angry when the examples always devolve into convoluted math examples *yawn*. Dean avoided that (mostly) and covered more realistic topics. Overall the talk was very good, and showed how it is possible to follow a functional style with Ruby. Although, it seemed to me, that attempting to follow functional patterns leads to somewhat noisy and obtrusive Ruby code. Having to freeze things and boilerplate immutable classes seemed to add white noise.

Super-easy PDF Generation with Prawn and Prawn-to - John McCaffrey

Honestly I figured I wouldn't find this talk very interesting, but I was wrong. John was entertaining to listen to. He kept things moving at a fast pace and talked even faster; occasionally trailing off into these mumbles that we couldn't understand. He reminded me of Jim Gaffigan, I expected him to go into a "Hot Pockets" routine. Getting an overview of the different PDF generation tools and then taking a deep dive into Prawn was what kept me listening. Seeing the effect of combining the Google Charts API with Prawn PDF generation was very cool. It turns out my company currently does that and I didn't even know it :)

"Comics" is Hard: On Domains and Databases - Ben Scofield

This was a long road to an interesting topic. Ben broke into biology off the bat and then went into comic books. At first I had no idea where he was going with this. He was entertaining to listen to though, so I kept listening. He kept breaking down the subject to show that those subjects are far more complicated than they first seem. Also this lead into his real point. That these subjects are so complex, they're hard to map to the simple relational model simple SQL databases rely on. He then started into how other persistence mechanisms may hold the key. For example, key/value store systems like Tokyo Tyrant, Voldemort, and Redis. As well as more exotic graph databases like Neo4J.


I'm making mention of lunch because it was awesome. Marinated steak, shrimp pasta, some kinda chicken rolled up in a noodle. It was all so good!

UI Fundamentals for Programmers - Ryan Singer

This talk had a bit of a buzz at the start. Ryan is, of course, a 37 Signals guy, that makes him a celebrity to the geeks (like me) in attendance. His talk did not disappoint. His initial example of a UI done by a programmer is exactly the kind of UIs I've always built for web applications. All function, no humanity. He talked about how interfaces need text, friendly text, that clues people into what it is they're doing. Fields and labels for every field on your model just doesn't cut it. He also talked a lot about how the eye and brain work together to scan a page and take in information. Providing the right levels of contrast can really make a huge difference.

How to Test Absolutely Anything - Noel Rappin

Noel had a tough job here. He got stuck following Ryan Singer. Noel covered a lot of interesting points on how to test some of the more difficult parts of a rails application. Things like views, email, and timestamps can be difficult to get some good tests around. Interesting material and it was covered well. Unfortunately his slides looked like a website from 1995. This effect was increased by his unfortunate position following Ryan as I mentioned. I think the corny background images and "comets" used for text transitions distracted a lot from the actual words on the screen. Sorry Noel :)

Optimizing Perceived Performance - David Eisinger

One word, hysterical. David's delivery reminded me of Steven Wright. His talk was focused changing the way your interface behaves to give the user the appearance of improved performance. He showed off the power of JQuery to give this effect. He demonstrated several techniques and even uploaded it all to Github. Great talk, I really enjoyed it.

Dojo Retrospectives - Jake Scruggs & Dave Hoover

Like I said at the start, I didn't visit the dojo at all. If I had, I might have gotten more out of this. It seems the organizers knew this would be tough to make it interesting for those that never stuck their head in and kept it to 10 minutes.

Rails 3 Update - Yehuda Katz

This really seemed to be less of a Rails 3 update and more of a Rails retrospective with a bit of a rally cry built in. Yehuda got into Rails 3 at the end of his talk, but by then he was rushing due to time constraints. Don't get me wrong though, what he had to say about Ruby and Rails and the community was incredibly interesting.

Awesomeness Achieved

The Wisdom Group and Chicago Ruby folks really did a great job putting this together. It was well organized, simple, and had a great price. I will definitely attend next year. Oh, and I won a free copy of "The Ruby Way", so I got to get some free exercise lugging home a big ass book :P

Monday, August 10, 2009

Hibernate-memcached 1.2.1 Released

I released 1.2.1 this morning to fix an NPE that was brought up in the group this morning. The NPE only comes up under an error condition so it really shouldn't be affecting too many people. Either way, it was crappy code and it needed to get fixed.

You can download the 1.2.1 from the site, or just update your maven pom.


Friday, July 17, 2009

Hibernate-memcached 1.2 Released

Earlier this week I released hibernate-memcached 1.2. Hibernate-memcached is a simple library that enables the use of Memcached as a second-level cache in Hibernate.

The 1.2 release updates the Maven dependencies to spymemcached 2.3.1, which includes some bug fixes and reduces the dependencies by one jar (spy.jar is gone). The main purpose of the hibernate-memcached release is to add support for the new binary protocol released with memcached 1.4. Previous versions of memcached only supported the ascii protocol. This has always performed well in it's own right; but the binary protocol reduces CPU compute time and can decrease response time as well.

The hibernate-memcached release also includes a minor tweak to use getMulti in Memcached when DogpilePrevention is enabled. Not a big deal, but someone pointed out an opportunity for it; so I added it.

You can download hibernate-memcached here. Or you can setup your maven project by following these instructions. As always, the source is available via github.

-Ray Krueger

Sunday, May 17, 2009

Rails Authentication: restful_authentication vs. authlogic

I've been spending a bit of time comparing Rails authentication mechanisms. The two main frameworks out there are the "restful-authentication" and "authlogic" libraries. The two provide the same general purpose functionality; users, sessions, cookies and emails.

The Restful authentication library is the current popular choice. I believe this is due to it being one of the first real options, as well as coverage in books like "Advanced Rails Recipes". The library is incredibly complex and opaque though. It relies heavily on generators and hidden code to produce its functionality. The install instructions are an exercise in command line arguments rather than code.

Authlogic has proven to be far simpler to digest. No real magic involved. One of the stated goals of the library is to be able to treat sessions as you would an active record model. You create a session, save a session and destroy a session like you would any other model. There are no generators you write the code yourself, and there is very little of it. The basic set of columns you need for a "User" show you that the library is well thought out with regards to security and usefulness. There are a number of columns though and this leads to a heavy initial copy & paste though. I felt a bit dirty having to do that, but I'll get over it. The rest of the code I have to write is transparent and understandable, a big plus. Oh, and do not assume that because "restful" isn't in the title that it lacks there. It doesn't, follow the tutorial and you'll produce a very restful solution.

You can probably tell from the above two paragraphs that I'm favoring Authlogic at this point. I definitely like the transparency and simplicity of it. To learn more about Authlogic you can follow along with the README in the main repository as well as the fantastic tutorial app. There are also a few extra tutorials on Ben Johnson's blog around password resets and openId.

Thursday, April 16, 2009

Follow up to the AbstractHibernateDao

In my writing about the AbstractHibernateDao here I mention that you no longer need to extend HibernateDaoSupport class. You do lose one thing though. Your new AbstractHibernateDao based DAO will now throw HibernateExceptions, not Spring DataAccessExceptions. Now, to me, this isn't the end of the world. In a Hibernate 3.2+ world Hibernate does have a clear exception hierarchy. Not like the old days where there was just "HibernateException". That sucked.

If you do want your DAOs to throw Spring DataAccessExceptions there are two simple things to do.
  1. Add the @Repository annotation to your DAO impl.
  2. Add a PersistenceExceptionTranslationPostProcessor bean to your Spring setup.

What this does is tell Spring to wrap an interceptor around your DAO bean that handles the exception translation.

Looking at the UserDaoImpl from the past article...

public class UserDaoImpl extends AbstractHibernateDao<User> implements UserDao {

public UserDaoImpl(SessionFactory sessionFactory) {
super(User.class, sessionFactory);

Then in your Spring application context.xml you simply add one line...

Now, this pattern I present is somewhat old school. There is all this fancy component scanning stuff you can do with the Spring 2.5 XML namespaces. Honestly the amount of voodoo that goes on there freaks me out a bit. You can study that on your own if you'd like. A good place to start is here.

Thursday, April 02, 2009

Amazon Elastic MapReduce

Amazon announced an Elastic MapReduce service in the AWS environment. This service combines S3, EC2 and the Hadoop MapReduce framework to provide a powerful distributed processing engine. This is pretty awesome stuff. Too bad I have no use for it right now, maybe I should make one up :P

Amazon Elastic MapReduce

Thursday, March 12, 2009

Announcing Tiny VH

My Buddy Sean got angry about going down the other day, so he wrote his own URL shortening service. I'm gonna use it for everything, and you should too :P

Announcing Tiny VH

Friday, January 30, 2009

Announcing Fidgetr | >140 Characters

Announcing Fidgetr | >140 Characters

My friend Paul Kehrer over at the "> 140 Characters" blog has released his new WordPress plugin called Fidgetr. From his blog...

Fidgetr is a WordPress widget that displays the latest photos from your Flickr photostream in an attractive manner. It features support for its own themes along with very simple setup and good compatibility with various WordPress themes.

If you use WordPress and Flickr you should check it out.