Quick Tip - Install the AMD 64 version of Opera 9.5
Posted by Vince Wadhwani on Feb 12, 2008 in | gnu/linux | html/css
If you're into testing your websites on lots of different browsers then you probably have a solution for IE6, IE7, Safari, Konqueror and Firefox. If you're using the AMD64 version of Debian or Ubuntu you may also want to add Opera to the mix. Unfortunately, if you go through their website you'll only be offered the i386 build. So what do you do if you want the Opera browser natively on your x86_64 machine?
Quick Tip - Get a visitors IP address
Posted by Vince Wadhwani on Feb 10, 2008 in | ruby
A while back I had a tip about getting a user's IP address using Ruby. I'm not exactly sure when it happened but the method I used in that post suddenly stopped working on me. If you used that to get a user's IP address in your code you may find that all values are coming back as 127.0.0.1. Hardly useful. Instead, try this snippet:
<% @ip = request.remote_ip %>
There are more banks than browsers
Posted by Vince Wadhwani on Feb 07, 2008 in | general
I was pretty stunned today when I signed up for Online Banking at SunTrust to find out that their corporate version for small business wouldn't work with Firefox. This has been the case since at least 2005 when I last interacted with them so it's not a new problem. Message to SunTrust: There are more banks than web browsers. I am not changing to Windows and using IE just because you can't get your act together.
Quick Tip: Enable PHP5 in OS X Leopard
Posted by Vince Wadhwani on Jan 29, 2008 in | Mac/BSD
If you upgraded from Tiger to Apple's OS X 10.5 Leopard you may find a few things that were OS related stopped working. In my case, PHP5 no longer responded as expected. Sure enough, some digging found it was disabled. Fortunately, it's pretty simple to get running again in Leopard.
Open up a terminal and type:
sudo vi /etc/apache2/httpd.conf +114
After typing in your password you'll find yourself on the exact line related to PHP5 that you need to uncomment. Remove the # at the start of the line so it looks like this:
LoadModule php5_module libexec/apache2/libphp5.so
Then head over to your System preferences and stop/start your web server in the Sharing pane by unchecking and re-checking the box that says Web Sharing. That'll restart Apache2 for you -- this time with PHP5 enabled.
Text Editing
Posted by Vince Wadhwani on Jan 26, 2008 in | gnu/linux | ruby
When you write code, the text-editor you use makes a big difference in your productivity. Textmate is the biggest thing I miss from using Mac OSX. There have been many attempts and some progress has been made along the way. I went through a few different applications but I think I've finally settled on Gedit. If you're interested in reading why (and where I went to customize my install) then by all means click through.
Install FreeImage & ImageScience on Ubuntu Gutsy
Posted by Vince Wadhwani on Jan 22, 2008 in | gnu/linux | ruby
I wrote up an article on compiling ImageMagick and installing Rmagick 2.1 but for some reason, even though the gem got installed, I couldn't resize images. After a half day banging my head against it, I finally gave up. Next up, ImageScience. It uses less memory anyway so if this serves your purpose, follow along.
Compile Imagemagick for Rmagick 2.0 gem
Posted by Vince Wadhwani on Jan 22, 2008 in | gnu/linux | ruby
If you've updated your gems recently you may have noticed that the latest rmagick isn't working. I've run into this problem on Feisty, Gutsy, and Debian Sid. The culprit is a version of Imagemagick older than 6.3.0. The Rmagick gem used to work with Graphicmagick so I'm not entirely sure why it refuses to install, but I get an error that says:
Can't install RMagick 2.0.0. You must have ImageMagick 6.3.0 or later. *** extconf.rb failed *** Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/rmagick-2.1.0 for inspection. Results logged to /usr/lib/ruby/gems/1.8/gems/rmagick-2.1.0/ext/RMagick/gem_make.out
Bleh. In order to get around this, you'll have to compile Imagemagick from source. Here's how I did it (the somewhat painless way)
Code to verify and create a mod10 check digit
Posted by Vince Wadhwani on Jan 17, 2008 in | ruby
If you're accepting credit cards in your ruby application you may need to use the Mod10 (also known as a Luhn) algorithm to check the final digit. There's sample code to do that in just about every language including ruby. I'll post my snippet below plus reverse it so you can create a check digit too. Why? Because sometimes you need to do that and also because it never hurts to independently verify your check digit with another method. Here goes:
Quick Tip - Install an older version of Rails
Posted by Vince Wadhwani on Jan 14, 2008 in | ruby
Following up a bit on a post I wrote a few days ago on some tips to upgrading your rails app for Rails 2. What happens if it just won't work? Then, later on you do a fresh install of rails and get the latest/greatest version while your app still depends on an older version? Well, if you didn't freeze rails with your app you still have a way out: install an older version of rails with rubygems. The command is easy:
sudo gem install rails --version 1.2.6
Lastly, you'll want to make sure your config/environment.rb has a line in it to match your older version of rails:
RAILS_GEM_VERSION = '1.2.6'
Force uninstallation of a package in Debian
Posted by Vince Wadhwani on Jan 12, 2008 in | gnu/linux
Sometimes Debian packages don't play nice. They install fine but try to upgrade them or remove them and they'll have a fit. It's happened to me on Lighttpd before and it just happened again with Wifi-radar. This time the error on removing the package said:
The following packages will be REMOVED: wifi-radar 0 upgraded, 0 newly installed, 1 to remove and 5 not upgraded. Need to get 0B of archives. After unpacking 238kB disk space will be freed. Do you want to continue [Y/n]? y (Reading database ... 156000 files and directories currently installed.) Removing wifi-radar ... Stopping wifi-radar daemon...invoke-rc.d: initscript wifi-radar, action "stop" failed. dpkg: error processing wifi-radar (--remove): subprocess pre-removal script returned error exit status 255 Starting wifi-radar daemon...Errors were encountered while processing: wifi-radar E: Sub-process /usr/bin/dpkg returned an error code (1)