Andrew Reid

Coffee, code and emergency medicine

Wranging With Heroku

This “bug” (for want of a better word) was a pest. A draining and annoying pest. My Rails app utilizes the really excellent twitter-bootstrap-rails gem and, because of some customizations, I’m using less-rails to compile the stylesheets.

Now, on my laptop where I do my development, I just edit my Gemfile accordingly and it Just Works™. However, when I went to push the updated app up to Heroku, it caused all manner of pain.

And so I dug. And I dug. Two issues in particular yielded the most help: lock in an old version of therubyracer Here’s the summary:

  • Heroku tell you not to use therubyracer in your app because it’s a memory pig
  • less-rails explicitly requires therubyracer which requires libv8
  • The latest version of therubyracer doesn’t play ball on Heroku because of a libv8 issue
  • therubyracer version 0.10.2 Just Works™

The relevant lines in my Gemfile are as follows:

1
gem 'therubyracer', '0.10.2', :platforms => :ruby,

It seems the good folk on the less-rails team are aware of the issue and are working toward a fix, there are some complex issues involved, so it’s not as cut-and-dried as you might think.

Launch: Mörk Specialty Hot Chocolate

My good buddy Kiril and his lovely partner Josefin have launched the website for their amazing new venture, Mörk Specialty Hot Chocolate. I’m super excited to have played a small part in putting the website together.

Check out their website and make sure you try some - it’s bloody amazing hot chocolate. Congratulations, guys.

Ultegra Di2: On-the-fly Rear Derailleur Adjustment

After an unfortunate coming together with a car a couple of months back, I upgraded my bike to a 2012 Scott Foil 15 which features the incredibly unneccessary (for me) yet totally fantastic Ultegra Di2. I’ve had this thing a month or so now and I’m totally hooked.

Selling point

The chief selling point for electric derailleur systems is the precise, reliable and effortless shifting you get at the touch of a button. Changing gear is much like clicking a button on a computer mouse. More impressive is that you get those qualities no matter how hard you’re hammering away on the pedals. The shifting is flawless, whether comfortably riding along the flats or busting your ass half-way up a hill.

Today, opting for Ultegra Di2 on your next bike seems to add about $1,000 to total, though that’s sure to change with the incredibly competitive options hitting the market from Azuri and Giant. For me, it was a cost I was prepared to wear. I was taking a significant step up from a very entry level bike and really wanted something that was going to serve me for many years to come. Given Shimano have now well and truly proven Di2 out in the wild, spending the extra money to get be at the forefront of technology today seemed like a good way of protecting my investment into the future.

Mobile mechanic

I’m not quite sure what prompted the issue, but the chain started to make a bit of noise as I changed into the lower gears while I was riding up Norton Summit Road. It sounded a lot like the derailleur wasn’t quite aligned right – the chain was rubbing between the two sprockets. Probably time to take it to the bike shop for a service, or at the very least, the shed for some adjustments, right?

Enter Di2. While I was riding along up the hill, I reached forward and pressed the button on the front junction box (it usually hangs at the stem between the two shifters) for about half a second, putting the rear derailleur into adjustment mode. In adjustment mode, the function of the shifting switches for the rear changes. Instead of moving the chain between sprockets, the derailleur changes its alignment – moving in 0.3mm increments – until you’re happy things. Then just press the button on the junction box for half a second again to switch it back into shifting (normal) mode.

So, there I am, adjusting the alignment of the rear derailleur, whilst riding up a hill, without stopping or pulling out a single tool. Brilliant.

Reference

If you’re looking to have a play with your groupset, there’s a bunch of great material on the web, but I strongly suggest the Shimano Dealer’s Manual as a place to start.

The Efficiency Hit Squad

Today more than ever, businesses need to squeeze more out of every dollar they spend. Efficiency is key to everything, but we’re often too busy engaging with our processes to see how inefficient they are.

The background

Why write about this, you ask? Well, the SA Health Minister John Hill tweeted about the report on efficiencies that SA Health released today and my mate, Nick, replied:

Fair question, right? Paper pay slips in 2012? Yeah. It’s happening. Is that someone’s fault? Maybe. But I don’t think it’s for any other reason than we all get so busy working away inside whatever our process is that we don’t see that, just perhaps, we could be doing things better.

The obvious answer to this particular issue is to e-mail people their pay slips as a PDF. That’d be 1000+ envelopes saved per week. Not to mention savings on transporting that paper across the state, or the fact that the staff would get their hands on their pay slip a good two or more days sooner than they would via snail mail.

But pay slips aren’t the only thing in a large organisation that could benefit with some modernisation. There are stacks of examples of manual data entry, duplication of information and inefficient processes that could be improved. They exist in every corner of a big organisation. The problem is, in many ways, quite overwhelming. It got me thinking and here we are.

The problem

Inevitably, a business or department develops processes which, over time could be done more efficiently. The dramatic drop in price of modern technology has made access to computers ubiquitous throughout an organisation and consequently, processes changed.

Take the library, as an example. When you wanted to borrow a book in the pre-computerised library, there was a manual, paper-based process used to keep track of what was borrowed, by whom and when it was due back. The librarian would remove a little card from the front cover of the book and record your membership number and stamp a date. Keeping track of overdue books was a manual process that involved sifting through the cards for the loaned books.

Fast-forward to the age of the modern computer and we have databases and barcodes and all manner of electronic wizardry that saves us from spending valuable work hours doing repetitive work. The notion of technology as a business tool is now well established.

Technology has changed the way we work. And it moves at such a pace that, oftentimes, we’re not keeping up. We’re doing some things better, but, of course, some things get forgotten or left behind. Sometimes, we’re so busy running the system, feeding the system, that we don’t have the opportunity to take a step back, look at the process and ask, “is this the best way we could do this?”.

Somehow, you need to facilitate that step back.

Hit Squads

I’m a bit of a fan of 37 signals and the way they go about things. I was particularly intrigued by a couple of posts: A Teams = 12 people and 2010: The year of the products + a new way of working. I’ll walk through the ideas that underpin the concept.

Small teams are agile teams. Agile teams move quickly and get results. Matt from 37signals contrasts special forces teams with conventional troops:

The small team size comes with a bunch of advantages: They’re self-contained, can work swiftly and quietly, don’t have the presence of conventional military troops, and are able to operate without a big infrastructure.

So, translating that to our large organisation context, the notion is that small, highly skilled tactical teams can be used to produce results disproportionately greater than their size. They can work on problems that impact a large number of people and get results quickly. These teams use technology (that is, they write task-specific code) to automate, streamline and improve business processes that have been left behind. I’m calling these teams “hit squads”.

What do these teams look like? Well, 37signals put their teams together with two programmers and a designer. In a large organisation, I think that team need also include a subject matter expert who can act almost in a business analyst role.

You need someone who intimately understands the process you’re trying to improve, someone who works at the coal face, to be a part of the team. That person acts as an interface between the people using the system and the programmers making it all happen.

Thus, my hit squad is comprised of:

  • Programmer/Lead
  • Programmer
  • Designer
  • Subject matter expert/business analyst

These teams work together (following the 37signals model) for two months at a time. They work on a specific project in that time and the goal is to deliver the completed project at or before the end of that two month block. At the end, the team is disbanded. You reform different teams (i.e., you’re not always working with the same people) for the next project.

In a big organisation, a tactical, business-problem-solving, tech hit squad is a low-risk proposition. Four people for eight weeks. If it works, great! You’ve just improved the business. If it doesn’t, then, you’re only down 8 x 4 weeks of salaries, which isn’t the worst thing in the world.

Special powers

I’ve found the most frustrating challenges I’ve faced in big organisations is navigating the bureaucracy. You might have a great idea, but it’s got to be vetted, discussed and thrown around by seven different committees first, then be get budget approval, have a spec written up, go to tender… Only to be told by the corporate IT department that it can’t be done. I can’t emphasise enough just how toxic that process is to grassroots-led improvement.

To make these hit squads effective, they need to be given the authority and resources to get the job done. For me, that’d probably mean things like:

  • Not having to use the company IT stack (I’m way more productive with my own gear)
  • Cooperation from the stakeholders (people need to talk to you and respond quickly)
  • Support from management
  • Support from IT to deploy a “non-complying” solution

Without wanting to hijack the post and turn it into a complete corporate-IT-bashfest, here’s the deal: technology is developing at a ridiculously, unbelievably fast pace. The traditional models of networks and servers and applications and IT departments… That’s all changing. Heck, it’s changed. There’s a start up appearing every other week building the services of tomorrow and they’re using next-generation technologies to do it. Corporate IT has to keep up, because it’s the greater business that they’re there to support that will suffer if they don’t.

An example

Like most people, my employer asks me to keep a record of the hours that I work and submit them to the pay office every week. I sit down at the end of each day and fill in my hours with a pen on a specially printed carbon-copy book. At the end of each week, my direct boss collects and signs the time sheet (authorising it) and then forwards it on for checking. That next person checks it to ensure I was indeed working the days I said I was and then forwards it on to the pay office. The pay office staff then manually enter in the data from my hand-written timesheet to generate my pay. In dot-point form:

  • Employee hand-writes time sheet
  • Line manager collects and authorises time sheet
  • Employee’s recorded hours checked against database for accuracy by administrative person
  • Time sheet forwarded to pay office
  • Pay office manually enters my hours into pay system

The hit squad would deal with this problem by developing a web-based time sheet that allowed all people involved to do their part easily and without double-handling data:

  • Employee fills in an online form
  • Employee’s hours automatically checked against database for accuracy
  • Line manager authorises time sheet at the click of a button
  • Time sheet sent electronically to pay office - no manual data re-entry

That’s an example of a project a hit squad could deliver in eight weeks that would have multiple benefits to the organisation:

  • Employees can manage their time sheet anywhere they have Internet access
  • Administrative person to check hours for accuracy no longer required
  • Line manager no longer has to physically collect and sign time sheets
  • Pay office time sheet entry eliminated, turn around times dramatically reduced

To my mind, that’s a better service for less money. And what would it take? Eight weeks and a hit squad.

Conclusion

Any large organisation has old processes that could be better, but aren’t, because that’s how they’ve always been done and people don’t have time to step back and see that they need improving. Small, focussed, well-resourced tactical technology teams can rapidly develop solutions that revolutionise business processes, improving service and saving money.

I’m @ndrewreid on Twitter and I’d love to hear your thoughts.

Deploying an Octopress Site to Amazon S3

In deciding that I was going to get a blog up and going again, I decided that the very awesome Octopress would be an excellent platform. I’d also been thinking about using Amazon’s S3 and CloudFront to host the site (to cater for the tens of squillions of visitors I won’t get).

One of the great things about Octopress is that after writing your post in whatever text editor you fancy, deploying the site is as simple as running rake deploy in your console. The only trouble is that, out of the box, it doesn’t magically deploy to an S3 bucket, meaning there’s usually another step involved to copy the generated site to Amazon.

A bit of research showed that there are already some implementations out there that address this issue. Jacob Elder wrote a post on Deploying Octopress to Amazon S3 as well as a pair of pull requests that uses s3cmd to transfer files from your computer to S3.

The only problem I have with the s3cmd implementation is that it requires an external library that you have to install manually in order to make it work. It’s not pure Ruby – the dependencies don’t get installed by bundler. It’s harder to make it fly than it should be. Out of a number of pull requests by various individuals, only this one by Jerome Bernard seems to do it in Ruby (using the right_aws gem), but his implementation seemed rather more involved and feature-packed than I had need for.

Thus, I’ve made a very modest attempt at solving the problem myself, as detailed in this pull request. It’s pure Ruby and uses the Fog gem to do the heavy lifting. It’s very simple:

  • The local public folder is traversed and a hash created
  • Directories are created in the S3 bucket
  • New or changed files only are uploaded to the server (comparison of local/remote ETag)
  • Orphaned files are removed from the remote S3 bucket

I suppose there are other features that could be cool, like invalidating the CloudFront distribution based on the changed files or something. But, without wanting it to be too complex, this is a good start. It gets your blog up onto S3 with minimum fuss.

My mediocre code could be refactored, also. I have a feeling that there are too many if statements in there that could be expressed more simply and elegantly by a more experienced Rubyist.

(Hilariously stupid postscript: I used my actual access keys in the commits (I’d been testing it to ensure it was working before commiting!) and forgot to scrap the real data before I pushed. Goose. For the record, those keys have been deleted! Whoops!)