using Ruby to rename files and edit their content · Nov 21, 2007
Recently at work, the web admin for the computer science department came into our lab and told us that my employer’s site was broken. The admin had need to make all .php files not act as PHP scripts, and instead, all files with the extension .sphp would now run as PHP scripts. Since my employer’s site was built using PHP, that meant all of its pages were showing the source code instead of actually executing. I had to whip up a quick Ruby script in order to:
finding invalid foreign keys in Rails · Nov 15, 2007
Sometimes it would be useful to tell users of your Ruby on Rails application if there is a problem in the database, such as some foreign keys are invalid. As an example, let’s assume you have two models, Book and Author, such that each Book has an author_id which connects with Author via its primary key, id. That is, the tables are: books(id, author_id) and authors(id). Each table probably has fields other than that, but those are the only fields we need to worry about. Below is a method that generates an unordered HTML list for display to the users:
Grub Error 17 · Oct 25, 2007
Note: if this tutorial doesn’t help you, possibly because
fdiskreports your known Linux partition correctly as Linux, you might also try my Grub Error 13 with Grub Error 17 tutorial.
I just had an interesting time with trying to boot into Linux on my PC. Last night, I noticed my
/boot/grub/menu.lstfile had gotten overwritten when I performed some Ubuntu updates. This meant I had to add in configuration to allow Windows to boot, and since I didn’t have a backup of my old, working configuration–mistake number 1–I looked online. I found something that looked like it would work, even though it had Grub’s
unhidecommands in the configuration–mistake number 2. I rebooted and successfully got into Windows.
using AJAX to implement a live search · May 14, 2007
using AJAX to spiff up a gallery · May 3, 2007
Lightbox is nice and all, but sometimes I find it clunky, particularly in Firefox when I have a lot of other tabs open. However, I don’t want to go the route of having an image load by itself in the browser, because it would be so much nicer to have it integrated into my layout. I could have a whole bunch of separate pages, one for each image, and do a full page load when a thumbnail is clicked, but that’s kind of a hassle. Well, with a simple PHP script and some AJAX calls, I can have my image load within the gallery page without a page reload.
how to reformat your pen drive · Apr 19, 2007
USB pen drives are everywhere these days, and for good reason, since they’re dead useful. I use mine with my Linux box, my Powerbook, and various other systems I’ve had cause to stick it in. After a while, my 1 GB drive was only holding a few hundred MB. When I would do an
ls -aon it, I would see several hidden directories, such as .Trashes and .Trash-sarah. Trying to
sudo rm -rf .Trash\*would fail out, however, giving complaints of a read-only filesystem. If you’re having such problems, or just really want to make sure your drive is clean, you can reformat it easily in Linux. I reformatted mine using Ubuntu, so the instructions have a slight bias; your mileage may vary. Warning: reformatting your pen drive will delete all its contents.
the ease of Linux with a focus on Ubuntu · Apr 5, 2007
It was the case, back in the day, that Linux was for the hacker elite, but those days are long gone. Now, you can pop in a live CD and you’re off. Most live CD’s offer an install option, so if you like browsing around the OS, double-click an icon on the desktop and it’ll install to your hard drive. When I got my new computer, to install Ubuntu, I just popped in the CD, let it boot, and chose the install option. I then sat back as it did everything for me. Oh, it asked me a few questions, such as my name, where I was located, etc., but those aren’t exactly questions that computer newbies would have trouble with. The whole thing was easy; I watched TV while I was doing it and just glanced over every now and then to see its progress. It rebooted when it finished and I was presented with a login screen. I typed the user name and password I’d chosen, and boom! I had a pretty desktop with very normal looking menus. If someone is used to Windows, they’re going to feel pretty comfortable with a distribution such as Ubuntu because the layout is easy to work with.
using Perl and Apache on OS X · Mar 22, 2007
I’m trying to do some work with a Perl app on my Powerbook but I was unable to get any Perl scripts to execute from my local server. At first, I was getting just the source of the Perl files spit back at me. I followed a few tutorials about getting /etc/httpd/httpd.conf set up, but then I kept getting 403 Forbidden errors when I tried to access .pl or .cgi files in my browser. I checked /var/log/httpd/error_log and saw: