Reading List: Ruby on Rails Tutorial: Learn Web Development with Rails (2nd Edition)

Over the past several months, I very slowly worked my way through Michael Hartl’s Ruby On Rails Tutorial and just wrapped things up last weekend.  As someone who has worked in many different programming languages over the years, I found this to be a great survey on how Rails can be used to build functional web apps.

The majority of the book is spent methodically building out a basic Twitter clone.  I like the way that concepts like MVC and TDD were introduced, but I question whether I might have been a bit lost if I wasn’t already familiar with them.

The writing style was very easy to follow, and I liked the predictable flow of Write Tests, Code, Test, Repeat.  I do wish that whomever curates the Kindle version would eliminate all of the “Click here to view code image” links, but that was only a minor distraction.

The author rightly states in the intro that a basic understanding of HTML and CSS is needed.  If you’re starting without that baseline, a lot of the sample app is going to seem like magic, and relying on magic is a bad way to code.  As it stands I feel like a lot of the Ruby code in the book was a bit on the mystical side, so I’m probably going to find a good Ruby book for my next technical read.  If you want to take a look at where my sample ended up, you can see the code at: https:/github.com/hallihan/rails_tutorial and I’ve got the sample running on Heroku at http://yamf.net.

Overall I’d say that if you’re familiar with other web frameworks like ASP/ASP.Net, PHP, JSP, etc. this is a great book to introduce the Rails framework.  I’d probably recommend diving into a Ruby book first if you have the interest.

The book is available from Amazon

Waking me up to complain about a low battery is terrible UX

If you design a product that might wake me up in the middle of the night, you should meet the following bar: I, or someone I love, must be in danger.  Not a hypothetical “If the power goes out and if something in the house is still managing to produce CO without power” type of danger, but something more actual and imminent.

Smoke and CO detectors seem to have been designed with a severe disregard for how the customer will react to the various interaction points other than a true emergency.  I can remember several times in my adult life when a chirping detector has induced me to get out a ladder in the middle of the night and climb up to check on various possible sources of the chirp, all in a semi-alert state.

Last night, the culprit was a CO detector that happened to be plugged in to the wall in our master bedroom, perhaps about 3 meters from where I sleep.  The acoustics of the alert sound on this device seem to have been designed to make it echo and reverberate around the house, which is great for an a alarm, but again is horrible for a low battery warning.  In my efforts to find the noise that only repeated every minute or two I got out two different ladders, stood on the ladder near the upstairs smoke alarm, then the downstairs one, then climbed into the attic to check that one, then stood in the room listening for the chirp again, then up to the attic to see if maybe there was another alarm up there that I didn’t know about.  Thankfully my wife happened to look down at the right moment and correlate a chirp with this CO detector plugged in to the wall.

I know that I should have probably replaced the battery at some point, but honestly I had totally forgotten about this particular detector.  It’s one of 3 CO detectors in our house, and I’m pretty sure that it’s been 3 or 4 years since the battery was changed because it runs off house power and the battery is just for power failures.  The end result of this particular warning was that the device was unplugged and batteries removed so that we could get back to sleep.

This morning as I tried to get back to sleep I was wondering how many middle-of-the-night ladder injuries are attributable to low-battery chirps.  I’m guessing that the low battery behavior is probably design-by-regulation and that manufacturers like First Alert don’t have a lot of latitude to make this better, but I see that Nest Protect is trying to solve the UX gap, although at quite a premium on price.

Recovering from a lost SSH Key File on Amazon EC2 Linux Instance

Recently I went to log in to an EC2 instance and I realized that I could no longer find the private key file that I needed to connect via SSH.  I looked around the Internet for recovery instructions and found some complicated pointers regarding creating a snapshot and then an AMI then using that to create a new instance.  This seemed like overkill, and I couldn’t get it to work when I tried it anyways (The new instance always stalled at 1of 2 Status Checks and I couldn’t connect).

On a whim, I decided that the key file had to be somewhere on the image and that I could probably find and replace it.  I was successful so I thought I would outline the steps here for others.

Warning, the following comes with a “Worked on my machine” guarantee, which basically means that you shouldn’t try this unless you understand what’s going on.

For the sake of keeping things straight, I’ll refer to the instance with the lost key as Instance A.

  1. Create a new instance with the same Linux build as the instance you need to access.  Create a new key pair.  Remember to actually save and back up the private key this time.  I’ll call this new instance “Instance B”.
  2. Shutdown Instance A.
  3. Detach the root volume from Instance A.  Note where it was attached, usually /dev/sda1
  4. Attach this volume on Instance B, note the mount point.  It will probably be something like /dev/sdf. Some Linux distros will actually use /dev/xvdf instead of sdf.

  5. Connect via ssh to Instance B.
  6. Run: sudo mount /dev/xvdf /mnt (using the device that was noted when you attached)
  7. cd to ‘/mnt/home/ec2-user/.ssh’  (this will be ‘/mnt/home/ubunto/.ssh’ on Ubuntu builds, may be different for other distros)
  8. Run: ‘sudo mv ./authorized_keys ./authorized_keys.old’
  9. Run: ‘sudo cp ~/.ssh/authorized_keys .’ (<- This is the magic.  We’re copying the Public Key from the .ssh dir of the currently logged in user to the correct location on the mounted volume.)
  10. ‘cd’ back to home
  11. Run: ‘sudo umount /mnt’
  12. Detach the volume from Instance B and then attach back to Instance A as /dev/sda1 (or other original mount point as noted in step 3).
  13. Now restart Instance A and you should be able to connect with SSH.
  14. After you’ve successfully connected back to Instance A, you can Terminate Instance B.

Note:
Running through sudo and doing chown and chgrp may not be necessary if your UID’s and GID’s match between Instance A and Instance B.

Simplify the Debate

As the election season continues to heat up, I’m consistently amazed by the ways that politicians choose to argue.  If you try to dissect the reasoning behind many fiscal conservative cries for spending cuts, it seems that they want to cut spending for the sake of reducing taxes.  This “tax-first” mentality may resonate with people who think they want more money in their pockets, but it leaves out the bigger part of the picture.

Every person participating in this debate needs to first evaluate the following two questions:

  1. What are the services I expect from my government?
  2. What am I willing to pay for those services?

Anyone who reflexively says that they don’t want the government to take any of their money should be called on to define what minimum services the government should provide and then their answer for question 2 should be reconciled with that level of service.  Anyone who comes up with a huge laundry list of services & social programs for question 1 should likewise be called to reconcile their answer to question 2 to a level reasonable to pay for those services.

Basically our entire complicated federal budget can be simplified to something like this:

(yes those bars are to scale, scary huh?)

Now there’s a large number of people who shout about the fact that the interest on our debt is going to bankrupt us.  Let’s split out interest spending on the above chart to see how big of a part of the problem that is:

(note for data nerds, the purple box gets smaller if you discount the portion of interest payments to the Federal Reserve that get kicked back to the Treasury)

I think it’s safe to say that no matter what your political slant that we’ve got a problem in that the spending column _way_ overshadows the income.

Now how we _fix_ the problem is the subject of many debates.  I think we collectively waste a lot of hot air shouting about how we’re going to fix things when we haven’t even come to a basic understanding about questions 1 & 2 above.  If you and I have a difference of opinion about whether the Federal Government should maintain the road outside my house, the interstate I drive on to get to work & the railways that bring coal to the power plant that provides power to my home, then we’re never going to agree on what marginal tax rate, and progressive tax structure would be appropriate to _fund_ those things.

Now in reality, question 1 _is_ the major divisive question in many political debates, but framing it as a question on tax policy first is dishonest.  Let’s discuss our differences on what we expect from the government and come to a legitimate compromise on what a reasonable level of government service is.  After we have agreed to a compromise on what the government should do, it should be possible, though not easy, to begin the debate on how we are going to pay for it.

No I will not alter links in a 4 year old post to help you optimize search results

Hopefully this isn’t too harsh.  I received a request today to alter an old blog post in a way that I can only assume is all about Search Engine Optimization.  The communication was mostly generalized flattery with a pass at being respectful of the integrity of my writing, but not enough that I think they actually took time to read through that specific post or any of my other writing.  I figured that the initial communication and my response might be interesting to those who’ve never had interaction with SEO folks.  Names and info removed.

 


From: [removed]
To: me
Date: Tue, 12 Jul 2011 18:10:32 -0400
Subject: Contact Request: Link in Blog Post

You have contact request!

Link in Blog Post
From: [removed]

Hi Rick,

I hope this message finds you well. I’m currently working on cleaning up [company name].com’s online presence and noticed you have a link to our site in your blog post. First off, thank you for finding us valuable enough to link to – we appreciate it! Part our clean-up process includes adjusting links to match the current title we’re using on our site outside of the [company name] brand name.

Your Post with Link: [link removed]

If you could please change the current link text from saying “[company name]” to “[company name] [important industry keywords]” it would be greatly appreciated.

Thanks for taking the time. Let me know if you have any questions on this change seeing as I fully want to respect your blog post as is as well. I look forward to hearing back!

Sincerely,

[removed]


Hello [removed],

I am not a big fan of altering links just to serve Search Engine Optimization. If your request below is really about cleaning up branding, I would gladly change the link but if I do so I would also add a nofollow tag. If [company name] prefers not to be linked to in this manner, or the original form from the blog post I wrote over 4 years ago, I’d gladly change the post to remove the link.

Just as a side note if you don’t know already, many bloggers are going to be defensive about this sort of thing. I’m not trying to be difficult, but taking time to edit a post just to serve your employer’s search rankings isn’t on my list of priorities.

I am a bit curious what sort of success rate you have with this type of request.

Regards,

Rick Hallihan