Silly little time consumers

Posted by Chad

I’ve wasted a pretty good amount of my coding time lately because of some oversights made while programming. To be expected when learning a new language and framework I suppose (Ruby on Rails). No, no, no—that’s the easy excuse. Most of these errors were not related to Ruby or Rails, just me being careless.

The RMagick debacle

This one cost me the better part of an entire day. You’re going to laugh. As I said in the previous post, this RMagick thing had me going mad and running in circles. I ended up trying to contact the DreamHost support to see if they could help me out. I know the run around, I used to give it when I was running my web hosting business back in the ‘03, they will tell me they can not help me debug my program and that RMagick is working for everyone else, so I must be doing something wrong. I knew that, I was hoping for help as to what I was doing wrong.

Fast-forward to the following day. I had to go to work and effectively clear my mind from everything Ruby, Rails, RMagick and DreamHost. The next day, I had class but when I came home (I just then received a reply from DH, telling me it’s my problem) I decided to give it a quick glance. This is where I acknowledge that sometimes when I get stuck on something, I like to walk away, take a break, walk the dog, eat a sandwich, etc. I can rethink the problem and come back with a new approach. So, during my 2 day hiatus I was able to clear my mind from the problem.

When I returned to the code, my first thought was; “concentrate on what was different in my local environment as opposed to the DreamHost environment and try to identify the problem”.

The Problem

Windows + require 'rmagick' => success!!!

Debian + require 'rmagick' => failure!!!

The moment I thought about it that way, it clicked. I needed to use require 'RMagick'! And of course, it worked. Windows is case insensitive while Linux is case sensitive. Go ahead, laugh, I told you that you would.

Answering my own questions

This is a story about paths. This way, that way, any way… but not there? Most of the story unfolded in a one way conversation with myself on Dmytro Shteflyuk’s awesome post about using ffmpeg/mencoder via Ruby. What that side of the story doesn’t tell is that I spent about an hour wrestling this issue before I decided to ask Dmytro for help.

For the most part, I was using his instructions to encode some video through my app. By putting the code in a model, I was trying to load/write the images/videos from my app/models directory.

This is another trend that I have noticed that helps me troubleshoot problems. The simple act of writing an explanation of the problem helps clarity it and sometimes often times I think of the solution mid-explanation and the post never even gets submitted.

In this case, I did submit the post. Afterwards, I proofread it. While proofreading, I got the idea that maybe it was a path issue. Sure enough, as mentioned in the reply to myself, I edited the code to include the images/videos absolute paths and problem solved.

Total waste of time? (What I learned)

Be more thorough in the initial draft of my code. Developing on Windows can make me sloppy in some areas. Troubleshooting should not continue into frustration. It’s simply not productive and may compound the problem. Take a deep breath, clear your mind, come back with a fresh approach. Put the problem in writing, it will give you another way to look at it and will open up a little creative right brainedness that may be needed.