Category: Code

The Great Hackintosh Experiement


A few weeks ago I decided to embark on a great experiment….to see if I could successfully install Max OSX 10.6 on my PC hardware.  This is not a task for the light-hearted.  Apple likes to keep their OS running on their own hardware, which is prohibitively expensive (compared to PC hardware).  I wanted to experience OSX for myself,  but I wasn’t going to fork over $1500 for new hardware when I have a perfectly capable machine here.  So I decided what the hell…why not try, right?  I’m going to detail every step I took to get this beast up and running.

To start, if you’re even considering any of this, you need to make sure you have compatible hardware.  To make life really easy, stick with Intel processors if you can.  Apple uses Intel in all of their systems (as of this posting..who knows if that’ll change in the future), so if you want the most pain-free experience, start with that.  Motherboard support seems pretty good across the board, as long as you’re sticking with simillar hardware to what’s in the Mac.  Here’s a list of all the hardware I have in my system:

Processor:  Intel Core 2 Quad Q9550
Motherboard: Asus P5K-E Wifi/AP (using the P35 chipset)
RAM: 8GB DDR2 1066 (4 X 2GB sticks)
Video Card: XFX ATI Radeon 5870
Monitors: 3, one hooked up to DisplayPort, the other 2 to DVI
Sound Card: Sound Blaster Live 5.1 USB
Hard Drive: 250GB SATA

Now these were all the important pieces.  I do have an Asus Xonar DS as my main sound card in Windows, but there aren’t any Mac-compatible drivers.  I just dug up my old Sound Blaster USB one to use instead.  I also have my old Geforce 8800GT video card sitting in the extra PCI-Express slot, which I use in Windows as my PhysX card.  I wasn’t intending on using this at all, but I wanted to leave it in the system if I could.  It seemed like all of this hardware would work so the next step, OS installation.

For this you’ll need a few things things.  First, get a retail copy of OSX Snow Leopard from Apple.  It’s only $30, so it’s worth going legit (or as legit as you can…).  Plus it’s much less of a headache that way.  Some of the pre-built OSX images out there (like iAtkos and whatnot) have extra drivers and stuff in them, and can cause problems when you update(as I discovered…my first experiment didn’t turn out well using that method).  Second, you’re going to need a a couple pieces of software called iBoot and Multibeast.  You can get both here.  iBoot is going to allow you to boot into OSX since regular PC hardware won’t work by itself.  Multibeast will allow you to make small tweaks and install extra drivers that will make your life much easier.  So I downloaded both of those, burned iBoot to a DVD, and just threw Multibeast onto a USB stick.  Also while you’re at it, grab the OSX 10.6.7 Combo update from here and throw it onto a USB stick too.  Makes life easier later.

I’m only sticking with 1 hard drive here too…again, to make my life easier.  Make sure it’s empty (or at the very least don’t mind formatting it).  You’re also going to need to make sure your BIOS has the SATA system set to ACHI.  If not, iBoot and the install DVD won’t boot.  You’ll be able to find all these settings in your BIOS.

Put in iBoot and restart your computer.  It should boot into a menu where you can choose to iBoot…don’t yet.  For me, I had to do 2 things here…first, unplug the SATA cable from my HDD.  Without this I was constantly getting EBIOS read errors when going into the OSX Installer.  Second, eject iBoot from your DVD drive, insert the Snow Leopard DVD and press F5.  This should refresh the menu and the new option should say Mac OSX Install.  Choose that and you’ll begin the boot process.  Once the Apple logo comes up, you can plug the SATA cable back into the HDD.  When you can take control in the installer, just go through the menus.  Once you hit the point where you can choose where to install the OS, make sure you create 2 partitions.  One for the main partition and one for a backup (trust me…you’ll need this).  Then just install to the first partition and away you go.

Once installation is done and you reboot, you’ll need to make sure you put iBoot back in.  You’re going to need to keep that in the drive every time you boot for the time being (we’ll fix that up later).  When you get to the iBoot menu you’ll be able to choose 2 options: either iBoot or your new OSX partition.  Move over to the OSX option but before you hit enter I had to type “PCIRootUID=1”.  This allowed me to actually boot into the system…without it, it would just lock up.  Press Enter and you should see the intro video…go through the steps, create your user account, blah blah blah.  After this, you should be in!!  Awesome…except for me.  I didn’t have the correct video resolution (let alone proper desktop expansion across 3 monitors), nor did I have network access.  That’s ok…we’ll fix both in short order.  First thing to do is to make a backup…go to Applications->Utilities->Disk Utilities, and do a restore from your main partition to the backup one.  If you run into any problems along the way, you can just use iBoot to boot into that partition and restore back to the main one (which I had to do on multiple occasions).

Now back to the system.  I fixed my network problem first because I didn’t have the 10.6.7 on a USB stick.  But if you do, we’ll install that first.  If not, look below for the network fix but be prepared to reapply that after the OSX update (it updates the network drivers, forcing you to do the entire process again).   Install the OSX update off of your stick (or from a networked drive in my case) but DON’T RESET after you do…just leave the installer up.  If you do at this point, you’ll have a busted OS and need to restore.  At this point, fire up Multibeast.  It may crash (and bring down the Update installer window too) but don’t worry…just restart Multibeast.  Go through the Multibeast screens and when you get to the point where you can choose different options, you’ll want to install EasyBeast and the PCIRootUID fix.  This should make it so you won’t have to type anything in when you boot.  Restart.

At this point, I had proper video resolution.  I made some adjustments in the Display settings but that was it.  Great.  Now to get connected to the Interwebz.   This part was tricky.  There didn’t seem to be any kexts out there for my specific network chipset but I luckily found this great walkthrough.  The trick here though is my network didn’t come back right away.  It took a couple resets…but that’s ok.  Also since my motherboard had wifi, I wanted that to work too if I could.  Lucky for me Realtek (the wifi chipset manufacturer on my board) provided drivers.  I found them here.  Ran that installer, restarted and backed everything up.

Once network access was up and running, I was almost done.  There was just a few small things I still wanted to get fixed.  First, the OS only detected 4 of 8 GB of RAM.  Also, I was still at the mercy of iBoot…EasyBeast isn’t enough for my machine, not if i wanted to keep hardware accelerated graphics.  I wanted to be able to boot into my system without the need of a boot disc if I could.  Lastly, I was still in 32-bit mode.  Ideally I’d like to be running the 64-bit kernel if I could.

Well the first and second problems were easily solved with 1 step.  Using Multibeast, I installed the Chameleon ATI Experimental Bootloader.  Once this was installed and I restarted the system, I was able to boot into OSX without the help of iBoot and the machine detected all 8GB of RAM.  In order to get it to boot into the 64-bit kernel though, I needed to modify the boot.plist file.  Look for a file called located in the /Extra folder off the root of the hard drive.  Open this file in TextEdit, and look for an entry for “Kernel Flags”.  You probably see an string entry just below that says “arch=i386”.  Change that to “arch=x86_64” and reboot once more.  You should now be running the 64-bit kernel. Remember, after this point, do another backup.

I was now at the point where everything essential to my computing experience was good to go.  I had a desktop that spanned 3 monitors, I had sound and network access…I was solid.  I was now able to install all of my other software, run updates through the Apple Software Updater thing…all that good stuff.  As I kept saying above, any time you are going to install a new driver or a system update from Apple, always make a backup of your drive incase something screws up. You can then always just revert back to the last good state (albiet after a somewhat lengthy copy process).  But that’s better than having to reinstall everything again.  There’s still small things: I can’t put my system to sleep (not sure if it’s even possible to fix that) and I still have my main windows drive unplugged while I use OSX, but that’s fine.

I’m now rocking OSX and can happily develop for the iOS platform without having to jump through hoops using a Virtual Machine.  If you have any questions/comments, please post below. I’ll update this article as I go with new discoveries and whatnot.  But for now, I hope this guide helped.


Until next time…

VisualSVN and Trac on Windows Home Server

At home here, I’ve set up a simple little home server for all my media storage.  I run Windows Home Server on it (for those that don’t know what it is, check here).  Suffice it to say, it’s a nifty little server OS that shares easily with my XBox 360 over the network, and it’s very extensible.

Anyways, the point of today’s post isn’t to talk about Windows Home Server (although I can make a seperate post on it later discussing it further…).  Today, I’m gonna talk about setting up some extra services on it so it’s not just used as a media storage server.  I needed to set up an SVN repository on it, along with Trac to handle some of my personal projects.  SVN is a version control system mainly used for code, and Trac is a Wiki and bug tracking software used to keep track of all kinds of things for any sort of project.  I use both of these at work, and am very familliar with them, so I decided for my personal stuff, I would stick with what I know.

Now, installing anything that’s not specifically meant to run on a Windows server can be a little tricky, but fortunately I discovered for this little experiment, it wasn’t too bad at all.  To start, I needed a version of SVN that would run on Windows.  Conviniently, I found something called VisualSVN Server.  It’s a fully functional SVN server, but has a nice GUI interface for managing it in Windows.  You can create your repositories here (and easily set them up with the base trunk, tags and branches directories that all SVN repositories should have), and also create users and groups.  Perfect.  Much easier than mucking with ini configuration files.

The second part to this puzzle though is Trac.  Now, for both SVN and Trac, you need a web server.  Windows Home Server convinently comes with IIS for it’s own web serving capabilities, but trying to get SVN working with IIS is a nightmare in of itself, let alone Trac too.  VisualSVN Server includes a version of Apache, so I figured Trac could hook right into that.  Well, as luck would have it, the guys over there running VisualSVN has detailed some nice instructions here, along with a package you can download to get yourself up and running.  Now, I basically followed everything on that page there to the letter, except 1 small thing.  I couldn’t get the SVN server to start after I installed Trac.  I had to grant access to the folder the Trac libraries were installed too (‘Program Files\VisualSVN Server\trac’ in my case) to the Network Service user.  After that, everything started up correctly.

Now, the package that I downloaded to install Trac didn’t include the latest version (they’re up to 0.12 now….VisualSVN provied 0.11.6).  I really wanted 0.12 as that’s what I’m used to at work now, so I thought I’d take a shot at trying to upgrade it.  This turned out to be much easier than expected.  I went to Trac’s download page and grabbed the Windows zip package.  I unzipped it to some temporary folder, opened a command prompt, and typed the following:

python D:\Temp\Trac 0.12\ install

*where D:\Temp\Trac 0.12\ is where you unzipped the package too

After things were installed, I started the SVN server back up, and bang…I was in business.

Anyways, I thought I’d share this little adventure to anyone who might find this useful.

Until next time…

C#/.NET trick for catching exceptions

Here’s an interesting little tip for anyone who’s writing a C# and/or any .NET application.

I’ve been writing/maintaining a relatively large application used by many different users, and have discovered many bugs that can come up over hours and hours of use. Well, us programmers are all just human, and don’t always write bulletproof code, especially when that code is run by 10’s or 100’s of different people. Most of the time when something bad happens, an exception is thrown by the application. If this exception goes unhandled, the program just crashes. It would be kinda handy sometimes to be able to catch each and every one of these unhandled exceptions, and at the very least log the problem and gracefully exit the program.

This is pretty trivial to do in any .NET application, and for an example using C#:

  1. Application.ThreadException += new ThreadExceptionEventHandler( OnThreadException );
  2. Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
  3. AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( UnUnhandledException );

The first line adds an event handler to the ThreadException event, which will be fired every time an unhandled exception happens inside the main UI thread of the application. So, if you have, say, 2 separate components to your application running on 2 different threads ( the main UI thread…Windows forms stuff, and a processing backend), you could gracefully shut down and restart the UI.

For the 2nd line, this tells the application to handle all exceptions, regardless of what the user has set in the application settings. This is directly then made use of in the next line, where we add an event handler to the UnhandledException event on the Current Application Domain. This way, any other unhandled exceptions from any other threads that are running in your application will be caught and this event will be fired with all the information you need. In my case, I gather up the exception details, allow the user to enter a description of what they were doing, and send an email to myself with all these details.

The one catch when dealing with unhandled exceptions is that once they occur, even if you catch them with this method, you won’t be able to recover from the crash. The programs is going to exit, regardless. But, like I said, at the very least you can log the error in some way, so you can figure out what went wrong and prevent it from crashing again.

I just figured this might help any potential .NET developers out there. I pulled most of this from Microsoft’s MSDN site here.

Until next time…

Artisteer and Menu Bars

When I was building this site, I decided to build it upon WordPress.  For those who have used it before know that it’s a pretty damn good piece of blogging software.  It’s really easy to use, and extremely extensible.  Themes are also a big part of WordPress, and there’s tons of different ones out there that you can use.  I did look through many different ones, but none of them really stuck out to me.  I wanted something that was different…something that was me.

I’m not much of a designer though.  So, I did a bit of research, and came across a nifty little piece of software called Artisteer. Artisteer is basically a GUI-based theme generator.  It’s great because I didn’t have to much around with a ton of PHP and CSS code to get the theme the way I wanted.  I recommend anyone try it out if you have a WordPress site.

Anyways, the main point of this post is not only to tell you about how good Artisteer is, but also how picky it can be.  In the tool itself, Artisteer shows a Categories and Archives dropdown menu, as seen on my site here.  But, the problem is when you export the Artisteer theme, it doesn’t come with those menus, and it wasn’t very clear on how to add them.  After spending a few hours fiddling with WordPress functions and PHP code, I ended up adding this code to my functions.php file for my theme, inside the art_menu_items() function:

  2. /* Already existing code */
  3.     if (true === $showHomeMenuItem || ‘page’ == get_option(‘show_on_front’))
  4.         echo ‘<li><a’ . ($isHomeSelected ? ‘ class="active"’ : ) . ‘ href="’ . get_option(‘home’) . ‘"><span><span>’
  5.                 . $homeMenuItemCaption . ‘</span></span></a></li>’;
  7. /* Code for categories */
  8.         wp_list_categories(‘title_li=<a href="#" title="Categories"><span><span>Categories</span></span></a>’);
  10. /* Code for archives */ 
  11.         echo ‘<li><a href ="#" title="Archives"><span><span>Archives</span></span></a><ul>’;
  12.         wp_get_archives("type=monthly");
  13.         echo ‘</ul></li>’;
  15. /* Already exsisting code */
  16.         add_action(‘get_pages’, ‘art_header_page_list_filter’);
  17.         add_action(‘wp_list_pages’, ‘art_list_pages_filter’);        
  18.         wp_list_pages(‘title_li=’);
  19.         remove_action(‘wp_list_pages’, ‘art_list_pages_filter’);
  20.         remove_action(‘get_pages’, ‘art_header_page_list_filter’);

By adding the title_li parameter with a link tag for Categories in it (even in this case it’s blank) for the wp_list_categories() function, it allows for the CSS to pick it up correctly, like the rest of the pages that are used in the header. For the archives section, a bit more work was needed. You need to add a new list item tag for the archives manually, start a new list inside that, and then just call wp_get_archives(). Then, finish off with the closing tags for the inner list and the list item itself.

Anyways, I hope that’s of help to anyone looking at adding categories and/or archive menu items to their navigation bars.

Until next time…