OS X Sync Network Time Script

For a project I was working on, I needed to sync the time on hundreds MacBooks so they would join an Active Directory domain properly. I needed to find a way to script this, but after scouring the internet for solutions and various combinations of ntpdate or ntpd commands, nothing seemed to work with consistency.

With ntpdate, I kept getting errors complaining that the NTP socket is in use. As it turns out, you cannot use ntpdate to sync the network time if you have “Set time and date automatically” enabled in System Preferences. The solution? Disable it, sync the time, and re-enable it. Thankfully, we can do that all from the command line:

# systemsetup -setusingnetworktime off
# ntpdate time.apple.com
# systemsetup -setusingnetworktime on
Should I be surprised that I got a BSOD within 10 minutes of using Windows 8? At least they cleaned it up a bit.

Should I be surprised that I got a BSOD within 10 minutes of using Windows 8? At least they cleaned it up a bit.

Manually Setting Rhino 4.0 Zoo Server

Allowing Rhino 4 to try to find a Zoo server on its own on a larger network can be quite frustrating if there are firewall restrictions in place or if the server is on a separate network than the clients. Thankfully, you can just specify the NetBIOS name of the server that Rhino looks for in the registry as a string.

Just create a string called zoo4with the NetBIOS name of your Zoo server as the value in one of the following locations:

Rhino 4.0 on Windows 32-bit


Rhino 4.0 on Windows 64-bit


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
> 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


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>