• using Ruby to rename files and edit their content ·

    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 ·

    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 ·

    Note: if this tutorial doesn’t help you, possibly because fdisk reports 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.lst file 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 hide and unhide commands in the configuration–mistake number 2. I rebooted and successfully got into Windows.

  • using Javascript and CSS to mark outgoing links ·

    It may be useful to your visitors to know which links will take them off of your site without having to hover over all of them. It might also be a nice touch to mark links pointing to PDF documents, for example, with a little Adobe PDF logo. With the help of Javascript and CSS, you can do this pretty simply.

  • using AJAX to implement a live search ·

    I recently implemented a live search on the quotes page, so I figured I’d give a tutorial on how I did it. A “live” search is like a regular search feature, but if the user has Javascript enabled, the search will run as they type, instead of waiting for them to hit the ‘Submit’ button. There are a couple of advantages to this, one being that it’s a bit quicker than a traditional search because it starts working immediately; another advantage is that it might help you narrow down your search better (e.g. you initially want to search for ‘frogs’, but you get just ‘frog’ typed in and see results that interest you that wouldn’t have seen with a ‘frogs’ query). However, I think the main benefit from a live search is that it’s cool. :)

  • using AJAX to spiff up a gallery ·

    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 ·

    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 -a on 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 ·

    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 ·

    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: