Adding random contacts and email addresses to the iPhone simulator address book


I needed some test data in my iPhone simulator’s address book to test out some functionality in the Raptr iPhone app, but adding contacts one by one would have been onerous, especially since I wanted several hundred!

Thankfully, you can programmatically add contacts to the iPhone contacts so I came up with the following snippet for a quick and dirty way to add a bunch of random contacts with random email addresses:

ABAddressBookRef addressBook = ABAddressBookCreate();

// create 200 random contacts
for (int i = 0; i < 200; i++)
	// create an ABRecordRef
	ABRecordRef record = ABPersonCreate();

	ABMutableMultiValueRef multi = ABMultiValueCreateMutable(kABStringPropertyType);

	NSString *email = [NSString stringWithFormat:@"", i, i];
	ABMultiValueAddValueAndLabel(multi, email, kABHomeLabel, NULL);
	NSString *fname = [NSString stringWithFormat:@"Name %i", i];
	NSString *lname = [NSString stringWithFormat:@"Last %i", i];

	// add the first name
	ABRecordSetValue(record, kABPersonFirstNameProperty, fname, NULL);
	// add the last name
	ABRecordSetValue(record, kABPersonLastNameProperty, lname, NULL);
	// add the home email
	ABRecordSetValue(record, kABPersonEmailProperty, multi, NULL);
	// add the record
	ABAddressBookAddRecord(addressBook, record, NULL);

// save the address book
ABAddressBookSave(addressBook, NULL);

// release

Put this inside -viewDidLoad or -loadView, launch the simulator and you’re set: 200 random contacts added to the simulator’s Contacts app. Make sure you remove this code snippet after you’ve run it once or you’ll keep adding random contacts. If you ever want to clear out the contacts on the simulator just go to the menu: iPhone Simulator -> Reset Content and Settings…

Downloading earlier versions of iPhone OS


If you’re ever in need of downloading an earlier version on the iPhone OS, iClarified has a list of iPhone firmware files for download from Apple’s servers. This is great if say you need to downgrade your iPhone 3G from iOS 4 back to iOS 3.1.3.

Grain of sand: 0, Canon SD800 IS: 1


Our trusty Canon PowerShot SD800 IS locked up the other day in the lens open position and whenever it powered up a “Lens error, restart camera” error message appeared on the LCD screen and the camera would then shut off.

Ends up that there was a single grain of sand that was stuck in between the gears that open/retract the lens. The cover is secured by a few tiny screws so it’s actually pretty easy to open up. Once I got the little bugger out from in between the gears (simply by manually turning the gears by hand), I fired up the camera again and the lens started working again!

Here are some disassembly pics, with the gears that control the opening/retracting of the lens circled in yellow.

Swapping out the hard drive in your DirecTV DVR with a larger one, and copying your content over


We have DirecTV’s HD DVR service at home but we were beginning to outgrow the stock 320GB drive in our HR21-700 receiver as it is chronically under 10% free capacity. I decided to pick up a Western Digital 1TB Green drive (model WD10EADS) to replace it.

This forum post on contains a pretty detailed walk though with photos detailing the removal procedure. Although the photos are of a slightly earlier version of the HR2* series receivers, the steps are pretty much the same.

You can simply swap the drives without copying your existing shows to the new drive, but I decided to copy over my old shows. The directions posted on using GParted worked like a charm. Be prepared for the data to copy from drive to drive though…it took about 2 hours and 15 minutes for me.

Updating WordPress via SSH instead of FTP


I’ve shut off FTP access to my server a while back, since FTP passwords are passed in plaintext over the net which is A Bad Thing™. For the occasions that I would need to update WordPress via its web interface, I would start up the FTP daemon so that I could use WordPress’ auto-update feature, and then shut it back down after I was done. Not that big of a hassle, but it required me to login into my server before doing anything from the web interface which was one step too many.

I discovered that WordPress has built-in support for updating via SSH2 if PHP has the PECL SSH2 library installed. Following is a quick summary of how to get it running.

The PECL ssh2 library requires libssh2 which I downloaded and then compiled painlessly with a

$ ./configure
$ make
$ make install

Once libssh2 was compiled and installed, I installed the PECL ssh2 library via

$ pecl install -f ssh2

The -f flag is to force the install since ssh2 is still in beta & you’d otherwise get a warning like

Failed to download pecl/ssh2 within preferred state "stable", latest release is version 0.11.0, stability "beta", use "channel://" to install

After installing ssh2 via pecl, i edited the php.ini file (located at /etc/php.ini for me) to tell PHP to load this extension

and then restart apache afterwards (via apachctl, service httpd restart, or whatever is appropriate for your system) so that the library would be available to PHP.

After apache comes back up, you should see a new option (SSH) in the wordpress upgrade page (which applies to plugins as well).

BTW, if you’re on a Red Hat Fedora system and/or use yum, you might be able to just pull the libssh2 rpm from yum instead of compiling it:

$ yum install libssh2
$ yum install libssh2-devel
$ yum install libssh2-docs
Page 3 of 1612345...10...Last »
Go to Top