Step, by step. Slowly it turns…
Workling, BackgroundJob, and some config file and UTC caution.
One of the features of the software I’m building is the ability to upload images and other binary files. Like so many other Rails apps we’re using attachment_fu. So far so good. We expected the “client” could pull these assets when they needed them and store them wherever they desired. And the developers rejoiced.
A follow up story required that we move those assets over to the website via SFTP. Since we use Capistrano I wrapped Net::SFTP (a Capistrano dependency). We wired it into the Model via after_save, and after_destroy, and again the developers rejoiced.
I decided to move the “hard coded” user, pass, etc. stuff to a config file, so created a YAML file and added the aforementioned sftp stuff, and some other application specific that was crufting up the place. I created an initializer to load the file, and again the… yeah, ok, you got it. Soon after there was some stuff that was environment specific so I created the 3 basic environment sections (development, production, and test) and moved along. I figured I could test for them in just one spot (for now) and all would be good. I’ve since had a change of heart, but no matter for now.
A short while later I accidently demo’ed the new transfer code with a very large image file, and was less than impressed by the way it went. Since Rails is single threaded (still, for the moment, although about to change as I write this) the file transfer absorbed copious resources on this somewhat long lived transfer. Genius that I am, I said we should run the transfer as a background process, and since I know we have other similar requirements coming up Real Soon Now(tm), decided to implement a queue as well. After looking around the landscape I decided on Workling and BackgroundJob. It looked like they would play nicely, and keep thing clean and straightforward.
In go the plugins, get things setup and migrated, create a worker class, and fire off the MyWorker.asynch_test_method. Cool! I see stuff in the database… hmmm nothing happened. I’m going to skip through the process at this point, and just discuss what we (I was pairing with Evan during most of this) found.
One of the recent changes in Rails (we started with 2.1 and have since moved to 2.1.2 as I write this) includes control over Time Zones. We had talked and played around with this a bit and decided that for our purposes UTC was just fine, and so left the default setting. Stuff in the database gets stored as UTC and when everything works as expected is converted to a local time setting, if you set one. Here’s the first gotcha. Since this is fairly new, folks have liberally sprinkled libraries with calls to Time.now(). Which is fine for what it is, but at least with the version of Ruby we’re using (1.8.6 as I write this) returns local time… but the database is living over in UTC land. I wouldn’t notice if my time zone was Greenwich Mean, but over here on the East Coast of the US there’s a five hour difference. So we hunted down (not for the first time mind you) the use of Time.now in the BJ runnner.rb an changed it to Time.now.utc. One bug down.
The next one was bug in the bj_invoker.rb that is installed by Workling in the script folder. Stuff happens (and a patch is being submitted) but there’s a bit of meta-programming going on, and it was hard to find the places where STDOUT was being nullified, and because it’s trying to act as background or async process, exceptions are being swallowed. So no significant logging, and no exceptions. In the end we patched the runner code in BJ to display STDERR and STDOUT, and we wrapped a method call in a begin/rescue in Workling to enable some exception logging at least in this common case.
Having done that we found our error, fixed our bugs, and watched everything work. And the developers rejoiced.
The lessons so far: Developers do not pay enough attention to time zones so watch for gotchas like how time is being stored in your database vs. how you test for time stuff. Secondly, only the main path will be well worn. All others will have bumps. Workling is commonly used with Starling and so using with other, even supported libs may be a somewhat more bug laden experience than one would hope for. This wasn’t too bad, but the process was methodically annoying and to a degree, orthogonal to our goals.
So… next we have the config file caution. So there’s this nice thing known as the Rails environment. It’s a beautiful thing as it makes it easy to separate development from testing and production. You can point each environment to a unique database. Excellent! You can change key settings about caching, and reloading of classes that makes development smoother and production faster. Yay! So what’s the caution? While those three are standard folks make up others. In addition to those three we have two others which are not common. They serve they’re purpose, but they’re not conventional.
Today I had a deploy fail. Hmm, that’s odd, they’re usually so smooth. Migration failed… nothing strange in there. Hmm there’s a couple of lines about config files… so what it turned out to be were two plugins that each rely on a config file. In one case the developers did the right thing and when they could not find a config file section that matched the environment, shut themselves down and wrote about it in the log. Excellent! The second was seriously hard wired to the config file, and so tossed an unhandled exception when it couldn’t find the matching environment section. Worse, the config file isn’t necessary for the setup we used, and the docs say it can be removed. (It can’t, for the same reason). So an unnecessary config file, missing an unnecessary environment hung my deploy. Sad. But it made me realize that I was missing those sections in my own little config file, so I added them in there as well, and have a card to rewrite the loading code to ensure that we always do the right thing if the environment section is not there.
A coupe more… it’s worthwhile in your Capistrano deploy stuff to be able to run migrations with –trace turned on. You should have matching environments on your development machine as you do elsewhere… I know I do… now. Lastly, as much as possible have a match to your production environment where you can make a mess without consequence. We use VMWare to slice up a hefty machine, and it’s a great tool for the purpose. It doesn’t hurt that we use Engineyard as our host and so can use the Express vm for testing.
Just one more layer… one more layer.
So it’s looking a lot like this (an AP photo by Jim Cole) around here these days. The days are bright with autumn sunshine, the air is crisp and clean. I can’t say enough about this time of year… except when I get up to ride at 5:30am. This morning it was 32 degrees F… also known as freezing. And a bit breezy. The problem is that after a few hours it can be significantly warmer out, and you need to figure the layers and compressibility, so that you might be able to shed something later, and stick in a pocket.
This morning I guessed wrong. And I payed the price. We had a nice route going, where there is this nice steady climb. Especially this time of year, it kicks my butt. But that’s what I’m out there for, so that was fine. Sure, Gerry felt the need to inquire of my plans for succession at the top of a long climb, but fear not. I’ve been there before, just not quite under dressed for the weather like today.
The kicker is when I dress too lightly and then climb, it costs me. First, I’m cold starting the climb. I feel weak and small. Then I warm up, and start to sweat. All fine until you reach the usually joyful downhill. Now it’s just freezes that sweat to your body, and makes you feel exceptionally cold. In more serious weather it’s a great way to get hypothermic. Today, it was just annoying, but made me cut my intended ride short. I did find a balance again when we took a short break and I stood in the sun for a few minutes. The rest, the sun, and then a nice pace brought me back to comfortable enough, but the ride had been long enough and uncomfortable enough that I didn’t feel like continuing. 24 uncomfortable miles. Here’s the thing. Despite all the whining and all about my screwing up a ride, it was a glorious fall day for ride. The light is amazing, the leaves are spectacular, the neighborhoods we ride through are well kept and quaint. The folks I ride with all the time always have interesting topics and trivia to discuss, and never seem to have an agenda about well, just about anything on the rides. Just one more layer… one more layer.
(Two other mistakes I made today… thinking it would be warmer since it was “an hour later”, and “I should be wide awake” since it was “an hour later”. Not so much on either count.)
A Sunday ride
A bunch of friends got together to ride on a glorious fall day. I met Gerry early to get in some additional miles, and as always, appreciate his experience and insight. Gerry, for all the teasing he takes is a remarkable athlete who has ridden well over 100,000 miles this decade. And that doesn’t begin to include his running or anything else. Fortunately for me Gerry is an early riser, and since I almost always have to ride early in the day, I can often catch up with him somewhere, and often he’s already been riding for a while. I’m not sure how far he had gone this morning before he met with me, but I had layered up and was ready. We spun out and had a nice pre ride spin, and caught up a bit. He’s been competing in a number of events and doing rather well.
Back at Piermont, I said hello to the guys, checked up on a couple of little things and then headed out with the group. A lovely bunch of folks, including one person who has been rehabbing for a while and is finally back on their bike, and in a related way I learned that someone who I’ve known for a while (just as smartest and lovely person as you could wish to meet, Hi Rita!) lives around the corner from me. I can’t begin to count how many times I must have ridden by her house.
Anyway, today was the perfect day for a rambling ride, enjoying the beautiful fall light, the leaves, and the crisp clean air. Add a great bunch of folks… and it’s magic.
I also completely ripped up two town line sprints after getting toasted by Jenni with the excuse that (wait for it…) I didn’t know we were competing until after she blew by me.
And below… one more piece of soon to be acquired winter gear… although I intend to get the 183 version for the front.

Caged kings, King cages
Delicious autumn! My very soul is wedded to it, and if I were a bird I would fly about the earth seeking the successive autumns.
~George Eliot
I continue to prepare for the winter biking season. It can be very hard to get out 5:30am on a Sunday morning this time of year. It’s dark, it’s cold, and generally not pleasant. Worse, you know it’s going to be much warmer and brighter later… when I can’t usually ride because of other obligations. That leaves me with a mostly mental battle — like my ride yesterday started out at 36 degrees F. Still some actual preparation takes place… I changed wheels on my road bike to a stronger wheel with rubber that has a bit more tread to it on the corners. The strength comes in handy hopping over fallen branches etc. The next step is over to the truly fat road tires (which requires a change of bike — heh). Clothing got sorted and cleaned. Gloves have gone from fingerless, to light, to medium. We’ve quickly blown through arm and leg warmers in the early morning, that season has passed already for me. But all in all, it’s mostly getting ready for the freezing cold starts, and often colder feeling finishes. It’s also remembering to bring something to blow one’s nose with, and taking a moment now and again to do so. That makes cold weather riding far more comfortable for me.
Below, a new set of King cages, featherweight titanium bottle cages made from “left over” titanium tubing from the airline industry. Light, strong, and they don’t markup one’s bottles, and further, match the “weapon of choice::winter division” very nicely. Coming soonish now… one hopes.
Bittersweet October. The mellow, messy, leaf-kicking, perfect pause between the opposing miseries of summer and winter.
~Carol Bishop Hipps
Autumn

We have few “we-started-them” family traditions. Family traditions abound on both sides, but there are few we feel are our own. Apple/Pumpkin picking is one. Even that is fairly hazy in that everyone else has done it as well, but we try and do it every year which apparently counts for something somewhere, in some ledger of family tradition, or so I’m told, and leave me alone already etc.
Fruit off a tree is magical. It’s not from a bin in a store. It’s not handled by others. It’s not processed, folded, spindled, or mutilated as the post office is want to say. One second it’s part of tree and the next second it’s a snack, or a pie, or the promise of one. Magic I tell you.


Noah agrees.
External git merge on OS X
The default merging behavior of git is pretty good – until it blows chunks and litters your merged file with dozens of >>>> markers. I had this happen to me again this weekend, and was finally motivated to do something about it.
[snip]
sudo port install xxdiff
git config –global merge.tool xxdiff
Now files needing a merge will open in the xxdiff user interface – which is an ugly XWindows thing, but it’s powerful. I’d love to see git hook up to something like Araxis Merge or Changes (when their 2.0 version with 3-way merge comes out), but I’m not nearly motivated enough to hack around in the git source yet.
[I’m not happy with ports. Each attempt leaves me with a mess I have to clean up myself. Any other solutions?]
Source: A Fresh Cup – Home
Railing away…
So say what you will about the value of your web framework of choice, but I and someone I work with (who never used this particular framework) built a useable section of an app and deployed to production in two weeks. Now we had some advantages. We had worked together before for about 8 months. My partner is really smart. I have some experience with the framework. Things that were working against us. We had very little time to produce the first useable bit of functionality. We don’t have our dev environment set up. We don’t have the proper test and QA structure in place yet and we were using a significantly advanced version of the framework since the last bit of development I had done with it.
Still, Ruby on Rails and it’s community is powerful stuff. A couple of plugins, a bit of spelunking via Google, and our own understanding of web frameworks made it possible to crank out some great stuff. Even now, as we start week 4, the code is getting tighter and more Ruby like. I can’t wait to see where we’re at in six months and beyond.
It’s been amazing.
Some common stuff we’re enjoying:
acts-as-taggable-on
newrelic_rpm
restful_authentication
rspec
rspec_on_rails
will_paginate
Thanks to the community for solving so many problems in advance.
Allez!
We’re looking forward to getting some of our solutions and ideas written up and coded for more general use. We have a public repository, and as soon as we can, we hope to start giving back.
Today’s ride…
6:13am this morning I was already in Piermont, and starting my ride. Nasty for a weekend, but that’s the price I pay for having a full life. No real complaints… except it is seriously cold these days in the morning. And dark. Like, no going anywhere without lights dark. Fortunately traffic is light at that hour on Sunday. However, you can’t really relax, because the folks who are up at that hour seem generally annoyed that they have to be up at that hour on Sunday. Maybe surly would be a better description.
On a similar ride last week, I was feeling terrible. That is, I kept looking down at the speedo and seeing really low numbers. 9mph, 12mph and I felt I was working really hard. At first I chalked it up to the early hour. Then I got worried my ride partner would get annoyed at the pace and pick it up, and really I felt like I couldn’t really go a whole lot faster for very long. Strange I thought, that I have so little this day, but it happens sometimes (usually a mental thing) and since my ride partner was not complaining about the pace… who cares?
We get to the bottom of our loop and after a small climb we hit a gradual but long downhill section… one where we almost always enjoy gravity and push for whatever we’ve got. So off we go and I’m feeling like it should when we’re cruising at 24mph or so… except I look down at the speedo and 16.5, 17… Huh? not possible. There’s a permanent radar installation near a school we were just about to pass. I look up and sure enough 24 or so. Aha! Hey, Jenni! What does your speedo say? 23 or so Why? Tell ya later…
So here’s the payoff. After the last ride I commented to Jenni how slow the avg. speed had been on the ride. So she had tried hard to pay attention to the pace and keep things moving. (I, of course, thought I was going to collapse moving at what I thought was only 12mph.) Naturally, the speedo was set wrong for the previous ride also (the wheel size was set wrong). So she pushed because she wanted me to have a good ride, and I pushed the pace because I thought I was moving at a snails pace with the end result being one of the fastest rides of the year. Silly. And it leads me to this.
I often ride without any “data” like a speedo. I don’t have one on every bike. And there is something to be said for that. You trust your feelings entirely with no other gauge available. Now I enjoy seeing the numbers and having the data. Measurement is one of the few ways to ensure progress. But times like this make me want to ditch the thing entirely. All of us had a good chuckle about it though.
Busy, busy
Let’s see, where were we? I forget… it’s been too long. So here’s the brief: Noah started his new school, things have been really crazy at work, the holidays are coming, the morning weather has been freezing (from a bike riding perspective 45F is cold) but all in all, things are good. How’s by you? Technical stuff later…