Clean Windows 7 OEM Installation

Here’s the situation: you’re “the computer guy” to your family or friends. They just got a new computer and ask you to get it in good working order before they start using it. You power it on to find trials of Norton and Office and 30 other programs that can only be considered bloatware. You’d like to perform a clean installation but keep their license. Here’s how:

  1. Backup your old activation files with ABR (Activation Backup & Restore).
  2. Use this ei.cfg Removal Utility to remove ei.cfg from your Windows 7 ISO.
  3. Burn the ISO to a disc.
  4. Install Windows 7 from the disc. When prompted for the edition, choose the same edition that was pre-installed on the computer before.
  5. When prompted for a product key, do not enter one, just click Next. Uncheck the box to activate Windows automatically, as well.
  6. Continue with your Windows installation as per usual.
  7. Restore the license with ABR as soon as Windows is installed.

If these steps don’t work for you, there is a more detailed guide by the creator of ABR that you can check out. Essentially, you’re just migrating your license files from the old installation to a clean installation on the same computer.

Storing IP Addresses in MySQL

While storing IPv4 addresses as strings as MySQL may seem like the obvious solution, there’s a better one: storing them as long integers. Specifically, you will want to make your IP address field an unsigned bigint.

To convert IP addresses to long for database storage in PHP, there is a convenient function: ip2long(). Going back to an IP address after pulling it from your database is just as easy: long2ip().

Singleton MySQL Class for PHP

This seems to be a pretty flexible and well-coded MySQL class for PHP.

Create a MySQL User With —skip-grant-tables

A friend of mine lets me use his box for almost anything I want and made me a sudoer. Today, I needed to create a MySQL user for myself without knowing any of his passwords. Here’s how I did it:

$ sudo service mysql stop
$ sudo mysqld_safe --skip-grant-tables &
$ mysql -u root
> FLUSH PRIVILEGES;
> CREATE USER '<username>'@'localhost' IDENTIFIED BY '<password>';
> GRANT ALL PRIVILEGES ON *.* TO '<username>'@'localhost' WITH GRANT OPTION;
> exit;
$ sudo kill <mysqld-pid>
$ sudo service mysql start

Ta-da!

CentOS Apache Basics

Slicehost has a nice article for getting started with Apache on CentOS.

CentOS yum Cheat Sheet

List software that requires updates

# yum list updates

Apply software updates

# yum update

List all available packages

# yum list all

List all installed packages

# yum list installed

Search for a package (wildcards acceptable)

# yum list <package>

Install a package

# yum install <package>

Remove a package

# yum remove <package>

Update a package

# yum update <package>

Cyanide and Happiness iGoogle Gadget

A few years ago, I created a gadget for iGoogle that displays the latest Cyanide and Happiness web comic. This gadget is my most widely used piece of “software” today.