If Life was a Cron file…

* 6-8,17-19 * * 1-5 drive.sh
* 9-17 * * 1-5 work.sh
* 23,0-5 * * * sleep.sh
* 9,11,13,15 * * 1-5 coffee.sh
* * * * 1 case_of_the_mondays.sh
* 7-23 * * 6,0 fun.sh

Posted in Misc, Tech | Comments Off

UINavigationController and Rotation

Recently working on a project that needs a video displayed from a table view inside of a UINavigationController stack. The video needs to be in Landscape mode, while the rest of the project can be in Portrait or Landscape. The view controllers are pushed onto the stack, and each of the view controllers overrode the shouldAutorotateToInterfaceOrientation: method. The landscape controller had return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);; the rest of the controllers simply returned YES. So far, so good.

Here’s the problem. The view controller that contained the video (aka VideoViewController) arranged its elements in landscape mode, but started in potrait mode. Rotating it to Landscape mode corrected the issue, then rotating it back to Portrait mode, it still looked ok:

I could not make this work using the pushViewController method on the root view controller’s navigationController. But, for some strange reason, presentModalViewController: presented this view in the correct orientation. So the table view gets pushed onto the NavigationController with pushViewController and the VideoViewController gets presented as a modal view. The interesting thing about it is if you specify YES for the animated parameter, it doesn’t look like a modal view controller — meaning that it doesn’t pop up from the bottom like normal modal VCs, but rather from the side, and doesn’t look unnatural.

This is only a workaround until I can figure out why a regular pushViewController call doesn’t rotate the view, and I was lucky enough that in this instance a modal controller worked out well.

Posted in Apple/OS X, Objective-C, Programming | Leave a comment

Constants in Objective-C

If you’re a Java programmer developing on the iPhone platform, you’ve probably wondered about how to set constants in your programs. Undoubtedly, you have have come across the #define preprocessor macro, and maybe a few other methods, but I’m going to show you my approach to this problem using the singleton design pattern. Continue reading

Posted in Apple/OS X, Objective-C, Programming, Tech | Tagged , , , , | Leave a comment

BootCamp Success!

I finally got around to installing Windows XP through Boot Camp and will document my experience here. I am running a 2007 Mac Book Pro 2.4GHz with 4GB of RAM and an NVIDIA GeForce 8600M GT on OS X Leopard. The point is to have a computer on which my wife can play Team Fortress 2 with me. Her idea. Honest. :)

As I indicated in an earlier post, my first hurdle was to get my MacBook’s hard drive defragmented enough for Boot Camp to be able to partition it. In theory, the HFS+ filesystem used by Mac OS X does not get fragmented due to how it was designed and how OS X uses the filesystem (read all about it on Apple’s website: http://support.apple.com/kb/HT1634).

As one of my favorite professors once said: “The difference between practice and theory is small in theory but large in practice.”

As it turns out, in order to partition a hard drive, and make a new 32GB partition, you need to have 32GB of free, continuous space. My understanding is that Boot Camp attempts to clean up smaller files and try to defragment. But if you have ever used larger files on your system such as in a virtual machine or gigantic movie files when you’re doing movie editing, you are basically left with a partition which Boot Camp refuses/is unable to partition.

I was left with one of two options:

  1. Buy iDefrag – a $30 defrag software
  2. Reformat the hard drive and reinstall OS X

I don’t like to pay for software. I’m one of those free software advocates. I especially don’t like to pay for software to fix something which should not have been broken in the first place, or, which other operating systems (ahem, Windows) include with the operating system.

So, I was left with option 2. Reformat and reinstall.

The plan was simple:

  • Back up all my data using Time Machine
  • Double-back up all my data using Carbon Copy Cloner (http://www.bombich.com/), JUST IN CASE, on a different drive
  • Put in Leopard CD, reinstall
  • Retrieve data using Time Machine Migration Assistant
  • Partition the drive using Boot Camp
  • Install Windows
  • play Team Fortress 2 with my wife and best friend

Let’s start with backing up. I needed to do this right because my Master’s thesis is on that drive, so I wanted to be extra careful and diligent in making two copies of everything.

It’s important to remember that in order to use Time Machine OR CCC, you NEED to have a HFS+ formatted external drive. I had only one 750GB HFS+ drive. So redundant backup was out of the question already. Well, I manually backed up all my files smaller than 2GB, which is the filesize limit on a FAT32 filesystem.

So with everything backed up to the HFS+ drive using Time Machine, I held my breath and did a Carbon Copy Clone onto the same drive (stupid I know, but phew, no problems!). All my other files were safely and redundantly manually copied to my FAT32 drives.

Next came the reinstall. But wait, I lost my Leopard CD! Luckily, I made a copy using Disk Utility from which I made a dmg file and another copy. This worked well. I reinstalled Leopard OS X and got to the “Would you like to migrate your data?” screen. I selected “Restore from a Time Machine backup,” selected my USB drive, and let it copy files while I did some things around the house.

4 hours later, the progress bar is still at 0%, and the drive is flickering. This is not good. I had no choice but to turn off the system manually (there was no cancel button on the only window on the screen), restart, and hope my data is ok. Luckily, it was.

I decided to use a different approach and fired up Migration Assistant from the Utilities folder once Leopard was installed, selecting the same option (restore from TM). This time, the progress bar moved, the hard drive churned, but received an error message at the end that there was a problem with my main user account (where all the data was located). Turns out that the restore only partially restored — none of my preferences or applications were restored. I manually dragged over applications like Firefox from the Applications directory on the drive, which seems to work (except for Adobe Photoshop and VMWare Fusion).

Demoralized, but not defeated, I cut my losses and partitioned the drive. It worked this time! The Windows XP installer presented me with the familiar blue installation screen. After going through all the license agreements and such, I had to choose how to handle the new partition. My choices were:

  • Format the partition using FAT32
  • Format the partition using NTFS
  • Quick Format the partition using FAT32
  • Quick Format the partition using NTFS
  • Convert the partition to NTFS (I chose this)
  • Leave the partition as is

That was the wrong choice. The machine rebooted, and showed a message like “Invalid startup disk.”

Apparently, the right choice was Format using FAT32 (or NTFS). So, back to OS X, use Boot Camp to restore and repartition the drive, and select the right option this time in the Windows installer.

Note: if you need to eject the Windows XP CD because you may have something of value written on it (maybe some kind of a serial number?), you need to eject it after Windows installer restarts and BEFORE it actually boots. Remember, there is no physical eject button on Mac’s computers, and the keyboard button WILL NOT WORK.

I finally installed Windows XP SP2. Great. But, it didn’t recognize the ethernet card, the wireless card, video card… in fact, if there was anything to be recognized, Windows failed at it.

AH! But the drivers! According to Apple’s instructions, put the Leopard CD in while in Windows, and an installer will automatically start up the driver installation process.

But this wasn’t working. In fact, when I inserted the Leopard installation CD, there was nothing on it — it was blank. I finally realized that the original CD is a dual-format CD, HFS+ and iso9660. Since this is a copy of the Leopard CD, and Disk Utility didn’t make an exact copy, I had no way of getting the drivers unless I found them online or got the original CD again.

Don’t even bother looking online, Apple doesn’t provide them (why?!), and as a rule of thumb I never download executable torrents (unless they are Linux ISOs).

I ended up borrowing a friend’s Snow Leopard CD, which worked. The video driver, ethernet driver, sound, microphone, isight, everything is fine.

Except wireless. Wireless wouldn’t connect to my Airport Extreme router saying that the network is out of reach (even though it’s sitting RIGHT NEXT TO my machine). I found a forum that basically said that in order to get it working with XP, I have to change my encryption on the router from “WPA2 Personal” to “WPA/WPA2.” Lo-and-behold, it worked.

The final hurdle was installing Service Pack 3. Starting the install, I get the following message “an error occurred while copying file osloader.ntd.” This forum helped explain that. To summarize, you have to remove the Mac partition from the Windows partition table, install SP3, and re-add it.

So there you have it. It’s a painful process which for once, in my opinion, isn’t Microsoft’s fault. But it’s worth it to see spies burned, heavies backstabbed, and pyros ubered.

Posted in Misc | Comments Off

Linux and OS X miscellaneous stuff

To “burn” a .iso or .img file to a USB device, type:

sudo dd if=bt4-pre-final.iso of=/dev/disk1 bs=1m

where /dev/disk1 is your particular disk. In OS X you can find out by going to the Disk Utility and selecting information on your target drive. In linux, type `dmesg` and that should give you the drive name.

I will be editing this to add more stuff.

Posted in Misc | Comments Off

OS X Inconsistencies

Many people are surprised to hear me say that I don’t think OS X has a well-designed GUI. As one of my professors puts it (I paraphrase):

Criticism is good. Criticism leads to change. Criticism makes things better.

In this post, I will try to do my part in making OS X better. The following is a list of GUI inconsistencies that bother me on a regular basis with OS X Leopard.
Continue reading

Posted in Apple/OS X, Tech | Leave a comment

Resetting MySQL Passwords

I downloaded a Ubuntu 8.10 VMPlanet.net image with MySQL server, but the root password was set to something other than the standard vmplanet.net password. Logging in without a password or username didn’t give me enough permissions to set my own users and change passwords. Here is the solution for this problem (thanks Keystone IT Tech!). Continue reading

Posted in Linux, MySQL, Ubuntu | Leave a comment

Grown-up Kids

We’re all kids at heart. It’s no secret that my wife and I enjoy waving our Wiimotes at the TV, driving the Warthog through alien-infested marshlands, or jumping around in giant, inflatable castles. A while ago, we were playing various ticket-rewarding games at our local arcade — basketball, whack-a-mole, skee-ball, etc. But the payout is very small in comparison with what you can get at the reward counter, something like 100 tickets just for a pen.

As we were deciding what to get with our hard day’s play, we decided it’s probably better to just give the tix away than to add another piece of plastic to our collection of junk. It felt good. The expression on the kid’s face, followed by his parents forcing a thank you (“now Jimmy, what do we say?” followed by a thin “Thank you”) brings a smile to our faces. Usually, the kids are shy and their parents thankful.

So we now do this every time we go to the arcades. We play till we’re sore or out of money, and then give the tickets to kids (tip: always make sure that the parent is with the child before approaching lest someone gets the wrong impression).

So go out there and put a smile on a kid’s face!!!

Posted in Misc | Leave a comment

OS X .htaccess

For some reason, I could not get .htaccess files to work on my system for the longest time. I’ve since upgraded to Leopard, and I eventually just gave up on it (I could do that, since I’m only running a development environment).

Anyway, the solution depends on which version you’re running:

For Tiger, edit /private/etc/httpd.conf AND /private/etc/users/username.conf for the correct directives

For Leopard, edit just /private/etc/apache2/httpd.conf

Days of pulling hair solved because I was looking in the wrong places.

Update: because of the upgrade from Tiger to Leopard, ALL of the above directories were present on my system, but only /private/etc/apache2 was being used.  This is because Leopard uses apache2 and Tiger uses apache 1.3.  Obviously, apache2 uses /private/etc/apache2 instead of /private/etc/httpd.  If you had installed Leopard from scratch, this would not be a problem.

Posted in Apple/OS X, PHP, Tech, Web Dev | Leave a comment

The Final Blow

Here is the video that killed my camera A85:

RIP my little Canon A85. You went out like a true champion.

Taken at the Prescott Rally, Prescott, AZ, October 6th, 2007.

Posted in Misc | Leave a comment