Blogs and Stuff
Intellectual plumbing and 100% toll free.
Attachment_fu is a great plugin by Rick Olsen (a.k.a. techno-weenie). I use this plugin for one of the sites I maintain. I recently ran into a situation where I needed to regenerate the thumbnails for all the uploaded images. Attachment_fu provides no built-in support for this, so I had to get creative. A quick search on Google revealed a post by Michael D. Ivey that seemed like a reasonable thing to do, but was not sufficient by itself. So in this blog, I plan to cover the steps I took to automate the regeneration of thumbnails when you are using attachment_fu.
You ever have an old car that you refuse to relinquish because it continues to get 10 miles to the gallon and you've had so many memories with it? Sure, you've seen the commercials for those fancy cars that are more environment friendly, safer to drive, and have a built-in GPS, but you still refuse to surrender old "Eleanor" for some new technology. Until recently, I've been on that same bus only my car was Subversion. I've been using Subversion for the past two years as my Source Code Management (SCM) system of choice. Just recently, I spent over three hours dealing with a corrupt Subversion repository. This single event was the straw that broke the camel's back, in fact, it didn't just break the back, it smashed the camel into a little pancake. Therefore, I decided to 'Git' rid of Subversion and give Git a shot at the title.
When designing a web site, most of the work goes into making a well-designed and usable frontend interface. What doesn't get nearly as much love is the backend administrative interface. Like security, it typically comes as an after thought if at all. However, with this website, I needed a reasonably functional administration section that would allow me to manipulate data in the models and a somewhat presentable interface that wasn't so arcane that it was unusable. While I did write some custom code to manage certain aspects of the site, developing an entire administration section from scratch was about as palatable as a dish of warmed up horse droppings. Say hello to my new best friend, ActiveScaffold.
Over the weekend, Rails 2.0 was released to the masses. Packed with a flurry of changes, I decided to take the plunge. After grabbing a Coke, turning on some music, and firing up TextMate, it was time to rock and roll. One of the new features included in the release was RequestForgeryProtection, one that I wanted to take full advantage of to help protect against CSRF-based attacks. Considering I've been keeping current with each release cycle of Rails, I was hoping that the upgrade from 1.2.6 to 2.0 would be a piece of cake. Well, long story short, it wasn't. Not suprising I'm sure, but it was another late night of code wrangling that ended up putting me to bed around 5:20am on a Saturday morning.
It's 2am and like the cat in the picture, I'm a little disgruntled. The one thing I've always disliked about Rails on a Mac is the fact that RMagick is so darn hard to get working properly. You can do it from source, but then you have to update it manually. You can try to use MacPorts, but that's a very fragile process. I had it working in Tiger, but to be quite frank, I'm not sure how that happened and it must have been more of an accident than anything else.
In this installment of a blog, I'm going to be covering how I managed to get RMagick up and running using a combination of RubyGems and MacPorts. I'll start by saying, it was a very clumsy process. After having everything installed manually using a great tutorial on Rails Envy, I decided to scrap that in belief there had to be an easier way. When I tried to use MacPorts and then install the RMagick gem, I kept running into an error about it not being able to find the freetype library. It was indeed on the system (/opt/local/lib/...), but it wasn't where the gem installer was expecting it (/usr/loca/lib/...). Give me a break.
For those Ubuntu users out there, you are likely aware of the latest release, Gutsy Gibbon.Some of my buddies at work were wondering if I had upgraded the cluster o' servers in my office yet. The answer, at least until about 10pm tonight was no. In fact, after the last upgrade to Feisty Fawn, I was somewhat hesitant to ever upgrade again.
Alright, so no network would be complete if someone didn't use pine or otherwise configure SSH in a way that did some type of port forwarding. As it turns out, I have been using SSH for quite some time for a number of reasons including website management, email, and system administration. Although it's a convenient way to tasks remotely, it's certainly not intuitive nor does it provide the level of simplicity and convenience I wanted. I literally wanted to point and click my way to having secure remote access to my home network from anywhere in the world.
A long time ago in a distant galaxy I wrote a few firewall rules for iptables. At the time, they were more than sufficient to protect my lonely router from the filthy internet. My network gradually grew over the course of many years and since that time these firewall rules have been mangled, munged, and otherwise become unparseable to all but the most adept Linux operating system. Over the past two weeks, I set forth on a journey to take what was a lagoon full of random packet filtering rules and organize them in such a way that they actually made sense to a human.
Talk about sending so humor my way just at the right time. My friend Allen and I are heavy users of del.icio.us. He happened to use the 'from' feature to send me an image that not only made me start laughing out loud, but depicts exactly my struggle with web design. I'll share that in a moment, but let's focus for a second on the pains of being a web designer.
It just so happens that at least once, usually more frequently, per day I'm complaining about designing my website so that it's compatible with Internet Explorer, Firefox, and Safari. I guess it's more than a complaint, it's a 10-minute violent rant on why I wish I could put a hole through my computer. Basically, I only design for these three browsers because that's about all I have time for.
As many of you may already know, I am a Digg.com junkie. In fact, many of the articles and other information I read on the regular basis originate from articles posted on Digg. One of the cool features that Digg has is something known as Digg Spy. When you navigate your browser of choice to that page, it provides a real-time view into activity on Digg.com, such as stories being submitted or 'dugg'.
Well, I thought that was a pretty nifty idea so I spent about 8 hours applying that same idea to the Music section of this website. The music section of this site contains a 'Recent Tracks' menu on the left hand side of the page. Using some RJS and the periodically_call_remote() helper method in RoR, I managed to slap something together that works. Really, it does work, at least in Safari, Firefox, and my favorite...Internet Explorer.
Now, let me explain how this works. Let's say you find yourself somewhere in the Music section of this site. If a song is played while you are on a page, that menu will automatically flash yellow and fade away. It automatically checks every 60 seconds.
I actually stayed up until 6am this morning trying to work out the kinks. For the most part, I had it all working around 2am last night. Between 2-6am, I was in the rubyonrails IRC channel trying to track down a bug with the Effect.Highlight function. You see, the menu would be updated and flash yellow just like I wanted it to, but then I would lose the :hover functionality where the element changes to a white background when hovered over.
Long story short, I ditched the Effect.Highlight function and went with Effect.Appear with some other RJS'ish stuff that gets the same thing done. Alright, that's all the new features I can code up this weekend, if there are any bugs, please lemme know.

