10^9: A One Billion Pixel Project - Beta 0

Posted by Chad

My latest project has just been released in Beta. It’s at 9figs.com and is a goal oriented project. The goal is to receive 1 Billion pixels, uploaded from users, to display in our widget.

This is built with Ruby on Rails except 2 files. The scripts that serve up the widget content and handle the resulting click-throughs are PHP. As the project grows, these files will likely receive a very high number of requests so RoR speed issues are a concern. Initially, I wrote them as part of the Rails app and then ported them over to PHP. Since, it has been over 2 years since I’ve touched anything ending with .php, this made the transition easy. PHP still remains extremely easy to pick up. You just have to remember to end all your lines with a semi-colon.

The widget serving file was extremely slow in Ruby. Each request generated several RMagick objects and it would not have taken many requests to pull the server to a halt. Or, require a more advanced (read: expensive) hosting solution. I was impressed by how fast the same logic could execute when written in PHP. I do miss that benefit of PHP.

I was able to build the entire app in 28 hours of development time. Speaking as a freelancer who only codes a few hours a week, productivity is key. So far, I haven’t found a case where I am not more productive in Rails than I would be in PHP (and I’m not interested in learning anything else).

Go check out the project and get the widget up on your site.

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.

RMagick + Dreamhost = The Death of Me

Posted by Chad

I have been working on a little application that I am ready to put into production mode. It only uses two gems (plus their dependencies); RMagick and ObjectiveFlickr. This is probably the simplest app since “Hello World” but, of course, I ran into a snag almost immediately.

The issue involves RMagick, if you didn’t already guess by the title of this entry. Any time I issue require 'rmagick' in the app, it breaks. The production.log shows MissingSourceFile (no such file to load -- rmagick) as the problem. Meaning, that RMagick can not be found. I know it is installed because the bash command gem list shows that it’s there.

There are instructions to install my own versions of ImageMagick and RubyGems. I have already installed my own RubyGems at /home/<user>/.gems so that I can install/update certain gems (eg. ObjectiveFlickr). While I do not need the most recent version of RMagick, the instructions are straight-forward and if it works I’ll take it.

The compiling of ImageMagick went without problems (I think). However when it came time for the gem install rmagick I get an error almost immediately saying the required libraries are not installed (eg. ImageMagick). My suspicion is that I need to tell it where to look for my installation of ImageMagick but I have no idea how do that.

Google is not giving me any useful results, although, I have found others posting about all types of Dreamhost + RMagick problems.

As you could guess with the other gem being an interface to the Flickr API, I am processing images and therefore need RMagick. The app is rendered useless until I can get this issue resolved. It’s a pretty nifty little app, I couldn’t find any thing else out there doing the same thing with the Flickr API, I hope to share it with you soon, until then the functionality is my little secret!