That is all.
Category Archives: ubuntu
Finding and Fixing Broken Images with Ruby
A family members was having a problem with some mixed up image names on a static html site. I could have fixed it manually in a few shakes, but that’s no fun. Instead I used hpricot to scrape, open-uri to test for broken-ness, Find to search and some good old fashion regex to correct.
This was my first time messing around with hpricot and I found it to be powerful and easy to use, two thumbs up. I foresee some scraping and spidering posts in the near future.
On to the code:
My final script was a bit hairy so I broke out the bit I used to find the broken images.
If you run the script it’ll print the offending paths to screen:
ruby image_scanner.rb http://site.com/busted.html
Or you can call the get_broken_images method to get an array back:
require 'image_scanner' scanner = Image_Scanner.new broken_images = scanner.get_broken_images "http://site.com/busted.html"
In case you’re interested, I’ve also uploaded the full code that I used to search for and correct the images although it’s implementation specific, riddled with lazy and is poorly tested. Read the disclaimer!
Just run it and be amazed!
ruby image_scanner.rb http://site.com/busted.html /media_folder /busted.html /fixed.html
Download only the broken image scanner
Download the full script
Ubuntu Hardy Heron ColdFusion 8 Oopsie
Somehow I managed to bugger up the ColdFusion installation on my beloved laptop. Whenever I would try to start the cf server I would get the following not-very-helpful message.
Running the ColdFusion 8 connector wizard ====================================================================== Configuring the web server connector (Launched on the first run of the ColdFusion 8 start script) Running apache connector wizard... ======================================= There was an error while running the connector wizard Connector installation was not successful
I googled around enough to realize that since it didn’t appear to be a common problem, that it was probably something I did. And it was.
As you may have figured out by now, I’m not a server-config kind of guy. I poked around a little bit and found an interesting looking shell script at /opt/coldfusion8/bin/connectors/apache_connector.sh. Running that gave me a much better error message:
Could not find directory /etc/apache2/apache2.conf
I opened the file and realized that the paths were all boogered up, meaning the paths I entered when installing ColdFusion where all buggered up. In any case, I fixed the incorrect paths and here’s what the file looks like now:
#!/bin/sh # # Configure the Apache connector. # -dir should be the *directory* which contains httpd.conf # -bin should be the path to the apache *executable* # -script should be the path to the script which is used to # start/stop apache # ../../runtime/bin/wsconfig -server coldfusion -ws apache -dir /etc/apache2 -bin /usr/sbin/apache2 -script /etc/init.d/apache2 -coldfusion exit $#
And Voila!