Ethan's Dance Recital

June 25th, 2008

Ethan had a hip-hop, tap dance recital recently. Here’s a video of him, he’s the fourth from the left in the front row with his hat backward.

TwitterBot Gem Released

June 11th, 2008

Tonight, at one of our (in)famous hack-a-mania nights at Integrum, we released a gem for accessing Twitter through XMPP. Read the full Integrum release article and then go get hacking!

I’m excited because not only did I have a hand in the creation of the twitter_bot gem, but I also helped in the development of Props & Drops, aka. TwitterProps, a Twitter application that uses this gem. So If you want to see it in action, give someone props (or drops) via twitter:

props @username for doing something cool

OR

drops @username for being a jerk

Go try it out!

DISCLAIMER: TwitterProps and twitter_bot only work when Twitter has their track feature enabled, which recently has been scarce…

RailsConf 2008

May 26th, 2008

I’ll be heading to RailsConf 2008 this week in beautiful Portland, OR. I can’t wait to be in one of my favorite cities again. Especially because I’ll not only be enjoying the city, but also learning from and interacting with the Rails community. If you’re going to be in Portland this weekend, then feel free to contact me.

This trip is brought to me by the awesomest rails development shop, Integrum! And if you see any of the other Integremlins there, say “Hi”, you never know what could happen. That’s what I did last year and now I get to work there building amazing Rails applications every day. Oh, and we have stickers.

GoRuCo 2008 Wrap-up

April 28th, 2008

As I stated in a previous post, I attended the Gotham Ruby Conference this past weekend in NYC. It was a great time with many interesting talks. The weather was amazing as well. I don’t want to spend a lot of time rehashing the conference because you can view the GoRuCo 2008 presentations for yourself, but I did want to mention a few things I got out of it.

Bryan Helmkamp gave an interesting introduction to story driven development using rspec and story runner. This is something we’ve been talking about at Integrum, but haven’t had a chance to use in a real setting yet. Derek and I got to spend some time at the WePlay offices (where Bryan works) and they showed us some of the stuff they’re doing, including using story runner. It was awesome to hear about their experiences and hopefully we’ll get a chance to use it soon.

Next up was “Archaeopteryx: A Ruby MIDI Generator.” I was skeptical about this one, but was blown away by Giles Bowkett’s presentation. From recounting his life adventures, including a “psycho throwing rocks at his dad until he threatened him with a piece of rebar” to calling venture capitalists “weasel-brained muppet fuckers… they’re not fools, they’re liars.” He kept the crowd well entertained, but threw in some really interesting and well-delivered points about startups and life. It is well worth watching.

Another one that really stood out was Ryan Davis’ presentation about “Hurting code for fun and profit.” He had a lot of really great things to say about being a developer, so go watch it already!

These speakers helped me to become aware of a few things:

  • I don’t read enough. Ryan mentioned that the average developer reads 1 book a year. Is one book a month really so hard?
  • I don’t hurt my code enough. I don’t use flog or heckle consistently and I often don’t take the time to correct code that I know should be improved.

I definitely have some things to work on… how about you?

I was recently inspired to create some cached, dynamic JavaScript files for a project I am working on after watching Ryan Bates Railscasts episodes 88 and 89.

The basic concept is to create a JavaScript controller that dynamically renders some JavaScript file(s). This allows you to take advantage of ERB in your JavaScript files. However, this can become slow as every request for that JavaScript file must be processed by Rails. In episode 89, Ryan showed how to cache the dynamic JavaScript file to improve performance. These episodes were great, except I had one problem… The dynamic portion of the JavaScript files I was working with were translated strings.

This meant that I couldn’t just cache the JavaScript file because the translation would need to be different based on the locale setting of the user. It turns out there’s a pretty easy solution to this. If you follow the lessons from the episodes then you will have a general caching mechanism for the dynamic JavaScript files. Assuming you are using a translation mechanism like Globalize then you have access to a locale for the current session. Simply use this locale when including the JavaScript file (e.g., dynamic_states):

Your layout file
<%= javascript_include_tag "#{locale}/dynamic_states" -%>

This will try to include the dynamic_states.js file from the javascripts/locale directory where locale is something like en, es, zh, etc. The only other thing to do is define a custom route to handle this new pattern.

routes.rb
map.connect ':controller/:locale/:action.:format'

That’s it. You should now have locale-specific dynamic JavaScript files. For what I was working on, I also nested the locale directory within another directory (e.g., cache) just for ease of removal in case you need to wipe out the entire cache of dynamic JS.

Resources

GoRuCo 2008

April 15th, 2008

Next week I will be traveling to New York for the Gotham Ruby Conference courtesy of my favorite Ruby on Rails consulting company in Phoenix. I’ll be attending with Integrum’s resident Agile methodology expert. If you’re in NY or attending the conference, be sure to look us up – see my contact information.

Rails counter_cache problem

April 11th, 2008

I ran into a strange Ruby on Rails counter_cache problem today. Given the following example models:

class Poll < ActiveRecord::Base
  has_many :poll_choices
  has_many :poll_votes
end

class PollChoice < ActiveRecord::Base
  belongs_to :poll
  has_many :poll_votes
end

class PollVote < ActiveRecord::Base
  belongs_to :poll, :counter_cache => :votes_count
  belongs_to :poll_choice, :counter_cache => :votes_count
end

We want to ensure that the Poll maintains the total vote count. We also want the PollChoice to maintain the votes for that specific choice. In our controller we might be tempted to add a PollVote through either the Poll or PollChoice association with PollVote, but that’s where the problem appears.

It turns out that both of the following approaches will only update the votes_count for one or the other instance, but not both.

@poll.poll_votes.create(:poll_choice_id => @poll_choice.id)

OR

@poll_choice.poll_votes.create(:poll_id => @poll.id)

Instead, if we create the PollVote directly we will get the desired result of both the Poll and PollChoice having their votes_count updated appropriately.

PollVote.create(:poll_id => @poll.id, :poll_choice_id => @poll_choice.id)

Strange behavior or expected result?

Update: Another solution is to not assign using the ID, but instead assign using the object itself.

@poll.poll_votes.create(:poll_choice => @poll_choice)

OR

@poll_choice.poll_votes.create(:poll => @poll)

A quick test showed this worked as well. (Thanks Arya A)

This weekend my Dad and I took my four year old, Ethan, on his first fishing trip. He had a blast and even caught two fish!

Ethan’s First Fishing Trip Photos

Creating a Backyard

March 23rd, 2008

My latest project around the house is to turn our dirt-pit of a backyard into a nice space for Kelly and I to relax and for the kids to play. We started last weekend and should be finished by late April. We’re doing it all ourselves with the help of my Dad and whoever else wants to help. I’ve created a Flickr set to follow the progress of the backyard over time.

Backyard Progress on Flickr

Let me know what you think!

Integrum Trip - SxSW day 1

March 8th, 2008

The first real day of the conference. I’m not gonna lie to you, the first day seemed pretty light. Registration was from 10:00am until 2:30pm with no panels, sessions, etc. scheduled during that time.

We got to the convention center in Austin at about 11:00am, registered with ease and proceeded to B. D. Riley’s Irish Pub for an Austin Refresh meetup. Not wanting to partake in the suds before noon, Gist and I headed for Starbucks for some early afternoon pick-me-up.

After the Refresh meeting we headed back to the convention center to prepare for the first panel of the day. Then a strange thing happened… While we were shooting the shit, Gist comes up with a great idea for a simple application for Twitter. We laugh about it, throw some ideas around and viola we have the beginnings of a new project. After taking a poll amongst the others, we decided to devote a triple to working on a first release – me, Jade, and Gist.

While Gist drew some sketches, Jade and I borrowed a laptop from Heidmo to begin development. Just a few short hours later we have our first version of an app we are calling “Props and Drops”. It is a way for people to give props (or drops) via Twitter. It’s pretty easy to get started, just visit http://props.integrumtech.com and click ‘About’ to get started. It also has a nifty iPhone interface, so if you’re lucky enough to have an iPhone check it out!

It was really awesome to see an idea progress so quickly. Here is a brief timeline of the day (totally estimated):

  • 1:00pm – Mother jokes
  • 1:07pm – Gist mentions way to vote people up or down via Twitter
  • 1:08pm – Someone says props
  • 1:12pm – More mother jokes
  • 1:17pm – The idea turns serious and Jade, Gist and I volunteer to build it in the few hours before the 5:00pm panel
  • 1:21pm – Another mom joke…
  • 1:35pm – Gist sketches interface
  • 1:30pm to 3:30pm – Jade controls laptop while I pair and we write the app in under 2 hours
  • 3:30pm to 4:52pm – Deployment takes about another hour, including minor tweaks discovered on deployment
  • 5:00pm – People begin to use ‘Props and Drops’ during the 5:00pm panel
  • 5:45pm – Strebel gains a substantial props lead over all others
  • 6:10pm – High fives are exchanged amongst Integremlins
  • 6:11pm – Mother jokes resume
  • 6:40pm to 2:00am – Alcohol is consumed

What a completely awesome day. Thanks to Jade and Gist for kicking ass to get this app out there and ready for use. Thanks to everyone already partaking of the Twitter Props and Drops goodness. Send us feature requests!!

Props and Drops

Integrum trip - SxSW Day 0

March 6th, 2008

What a long day! We traveled by RV from Phoenix, AZ to Austin, TX in just about 19 hours. Not record time by any means, but we had a blast. Josh provided the RV and both he and Derek drove.

Highlights of the trip include stopping to discover the mysteries of ‘The Thing’, talking politics and religion with Jade and Erica, Curtis hacking on a new side project and me hacking on a side project (details soon).

It was really nice to spend some quality time with some of my co-workers outside of work and the pressures and demands of customers. Looking forward to participating in SxSW!

Wireless Amber Alerts

February 11th, 2008

Sign up to receive Amber Alerts in your area via text message. It’s easy and (if you have unlimited text messages) free. The site asks for your cell phone number and up to five zip codes in which you would like to receive alerts.

Wireless Amber Alerts

It’s a very interesting use of SMS text messages. I wonder what impact this will have on nabbing child abductors; I hope someone is studying that :)

Integrum and me

February 9th, 2008

In August 2006, I left my employer to embark on a journey to change my skill set and mind set. My previous employer was a very large defense contractor who offered a decent workplace, average salary, excellent benefits, and, of course, job stability. I announced to my friends and family that I would be leaving this employer, returning to Arizona and leaving the ranks of the employed for an undetermined amount of time. It seemed ludicrous to most people at the time, myself included. I was sure of only one thing at that time: I intended to refocus my career goals in an entirely different direction.

Unemployment

I had attempted to take my career in a different direction while still working, but I found that after 60-80 hour work weeks, a Master’s program in Computer Science and a wife and two young children, I didn’t have the energy. Voluntary unemployment was a calculated risk that I could learn what I needed to enter my newly chosen career path before I was forced to declare bankruptcy.

Unemployment is not really as bad as I thought it would be. I was able to spend time learning the things I was truly interested in, including Ruby on Rails. I spent a lot of time with my family and generally enjoyed myself. I found that I could actually work longer with more focus that I ever did at a previous employer without feeling tired or burnt out.

Eventually, our finances drained to the point of alarm and I began to look for a professional position working with Ruby on Rails.

Contracting

Since early 2007, I have been contracting my Ruby on Rails services to various employers. While this was lucrative it was also very frustrating. During that time I learned a little about myself and the environment in which I work best. I invest myself in what I do and as a contractor I found it hard to not get involved beyond what was required of me.

My first contract position was a fixed bid contract that was referred to me by my brother. It allowed me to choose the technology and create a simple student tracking system for a wellness center. It was deployed internally in January of 2007 and as far as I know it is still being used. My first real, deployed and used application! With that experience under my belt, I placed my resume on various websites advertising my interest in Ruby on Rails development positions. In a few short days I was contacted.

My second contracting position was an 18 month contract to create an EMR system for a local, privately held behavioral health organization. This was the big test for me to gauge if my calculated risk would pay off. Unlike the previous contract I was interviewed about my knowledge of Ruby on Rails, databases and Agile development. Two weeks after advertising my resume, I was hired to work professionally with Ruby on Rails. I learned a lot during my time contracting for that company, including how much I didn’t know, and met a great Phoenix Ruby on Rails developer, Josh Huckabee. I also attended my first RailsConf in Portland, OR in May with Josh and a few of the full-time employees.

Attending RailsConf was a real turning point for me, in many ways. Part of what I was missing as a lone wolf developer was the sense of community and interaction with other Rubyists – I met some great people at RailsConf! Upon returning, I began attending the Ruby User’s Group in Phoenix, Phoenix Rails Group and Refresh Phoenix to connect at a local level with other enthusiastic Rubyists, developers and designers.

This was the beginning of the end of my time at my current contract. As I discovered more about agile Ruby on Rails projects I realized that it would be highly improbable to influence the current direction of my contract employer. For three more months Josh and I attempted to influence the direction of our project and rescue it from impending failure. In August, we made our exit and, because of RailsConf and local networking, we began contracting for a Phoenix Ruby on Rails consulting company, Integrum Technologies.

Integrum and Me

In January 2008, Josh and I became full-time Integrum code monkeys. Integrum is an amazing place to work and completely unlike any company I’ve worked for. There is a level of openness and transparency that I have only read and dreamed about. Of course, Integrum is not perfect, but we are working hard to constantly improve ourselves while still having a blast. My wife constantly reminds me that Integrum is fueled by fun :) I believe that this year will be an important one for our company. You can keep up on what’s going on with us by reading, or subscribing to, the Integrum blog.

A year and a half has passed since I resigned my comfortable, full-time position in California. In that time I have accomplished more that I could have hoped for and am happier than I’ve been in some time – my calculated risk paid off.

Minor TextMate Annoyance

November 13th, 2007

A recent update to Textmate added a variable to the do snippet. So when you type ‘do’ followed by a tab, you get

do |variable|

end

Most of the time I don’t need a variable, so I want the default ‘do’ snippet to not have a variable.

Open TextMate and use the keyboard shortcut to open the Snippet editor (Ctrl+Alt+⌘) Click Ruby in the Snippets area, click the plus sign (+) in the bottom left corner and click ‘New Snippet’.

Creating a New Snippet

Name the snippet ‘Insert do … end’, assign Activation (Tab Trigger) the value ‘do’ and Scope Selector the value ‘source.ruby’. The snippet text should be

do
  $0
end

The new Snippet

Finally, change the existing Snippet named ‘Insert do |variable| ... end’ Activation (Tab Trigger) the value ‘dov’. Now when you type ‘do[tab]’ you will get the ‘do … end’ block without a variable. When you type ‘dov[tab]’ you will get the ‘do |variable| ... end’ block.

Donate to Creative Commons

November 9th, 2007

It’s that time of year again. Show your support for Creative Commons by donating to the cause!