Map the Apple key to Ctrl in Windows Boot Camp

Heavy computer users are familiar with keyboard shortcuts such as ctrl-c to “copy” and ctrl-v to “paste.” If you’re a Mac user and you switch back and forth from Windows to OS X often you’ve probably felt some pain using keyboard shortcuts.

For some silly reason Apple decided to default standard keyboard shortcuts to use the Apple key (also called the Command key) instead of the ctrl key. That means to copy text in Windows you press ctrl-c, but to copy text in OS X you press Apple-c. RIDICULOUS!

Never the less, I’ve gotten use to working with the default OS X keyboard layout, and this has made switching back and forth from Windows Boot Camp to OS X incredibly confusing. I’ve started pressing ctrl when I should be pressing the Apple key and vice versa.

Luckily I’ve discovered a nifty tool that will update your Windows registry to make the Apple key act like ctrl in Windows. Here’s the simple step by step guide.

  1. Download and install SharpKeys.
  2. Run SharpKeys and click the “Add” button.
  3. In the “From key” column click “Type Key” and press the Apple key. Click “OK.”
  4. In the “To key” column click “Type Key” and press your left ctrl key. Click “OK.”
  5. Click “OK” to dismiss the key mapping menu.
  6. Click “Write to Registry” and reboot your Mac.

Alternatively, you can set your ctrl key to behave like the Apple key in OS X by going Settings -> Keyboard -> Modifier Keys : then swap “Control” and “Command” key functions in the drop down, and click “OK.”

Now you can have some hot-key sanity when switching back and forth from Windows Boot Camp to OS X.

Downgrade PHP 5.3 to 5.2

Like many others, I recently upgraded my Production server to PHP 5.3. I’m not quite sure of the reason anymore. I think I was trying to integrate a PHP profiler that required something in 5.3. Whatever my original reason, after I got 5.3 installed on my server, it started slowly hemorrhaging memory and occasionally freezing up, always during the middle of the night while I slept of course. So, today I set about downgrading PHP 5.3.2 to PHP 5.2.13. Here is what worked for me.

The Setup

First off, I’m running Ubuntu-Hardy, and both my PHP 5.3 and 5.2 distributions came from dotdeb.org. I have a Production server and a Test server that I try to keep as similar as possible. The first thing I did was make a backup of my Test server with PHP 5.3 installed and my app functional. Then I began hacking away on my Test server trying to successfully downgrade to PHP 5.2. When I screwed the Test server up beyond repair, I restored from backup. Likewise, when I made progress I documented my steps, restored from backup, and tried to repeat my success. I did this several times and eventually made a script that successfully downgraded PHP. I rehearsed this script 3 times on my Test server, backed-up my Production server, then repeated the script on my Production server. IT WORKED!

NOTICE: I probably have a couple of unnecessary steps in here that I didn’t bother to investigate their necessity. You may also need to uninstall and reinstall different PHP modules than I did, depending on the requirements of your applications.

My Final Steps

  1. Remove PHP
    1. sudo apt-get remove php5-common
    2. sudo apt-get remove php5-cli
    3. sudo apt-get remove php5
    4. sudo apt-get autoremove memcached
  2. Update your sources list to point to PHP 5.2
    1. sudo nano /etc/apt/sources.list
    2. Remove the references to PHP 5.3 packages. For me that was:
      deb http://php53.dotdeb.org stable all
      deb-src http://php53.dotdeb.org stable all
    3. Add the following 5.2 packages:
      deb http://http.us.debian.org/debian stable all
      deb http://security.debian.org/ stable/updates main contrib
      deb http://packages.dotdeb.org/ stable all
  3. Install PHP 5.2
    1. sudo apt-get update
    2. sudo apt-get install php5-cli
    3. sudo apt-get install php5
  4. Reinstall any PHP modules your application requires. For me that was:
    1. sudo apt-get install memcached
    2. sudo apt-get install php5-memcache
    3. sudo apt-get install php5-curl
    4. sudo apt-get install php5-mysql
  5. sudo reboot

After my production server rebooted, I had to fidget with Apache to get it started again. You may have to:

  • sudo /etc/init.d/apache2 restart
  • sudo /etc/init.d/apache2 stop
  • sudo /etc/init.d/apache2 start

Hope this helps!

Installing Cassandra on Ubuntu Linux

Cassandra is a highly scalable, eventually consistent, distributed, structured key-value store. It’s an alternative to SQL if you don’t need relational data structures. The best part is it’s super fast, and distributed. The worst part is there’s not much documentation or community, at least compared to MySQL. So, I’m doing my small part to contribute to Cassandra. Here’s how I installed Cassandra on Ubuntu 8.04.2 LTS (hardy), but these directions should work on pretty much any Linux distro.

1. First upgrade your software as is with the following two commands (just for good measure):

sudo apt-get update
sudo apt-get upgrade

2. Now, open up your Debian package sources list with Nano for editing using the following command:

sudo nano /etc/apt/sources.list

3. Next, add the following sources to your /etc/apt/sources.list file.

deb http://www.apache.org/dist/incubator/cassandra/debian unstable main
deb-src http://www.apache.org/dist/incubator/cassandra/debian unstable main

After you add these two lines, press cntrl+X to close Nano. It’ll ask “Save modified buffer?” Press Y. Press Enter when Nano asks “File Name to Write.”

4. Run the update to install Casandra with this command:

sudo apt-get update

5. ERROR! At this point you receive an error similar to this:

W: GPG error: http://www.apache.org unstable Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F758CE318D77295D

6. Use the following three commands to ignore the signature error, and continue installing:

NOTE: You must replace the key value ‘F758CE318D77295D’ with the key value you received in your error message.

gpg --keyserver wwwkeys.eu.pgp.net --recv-keys F758CE318D77295D
sudo apt-key add ~/.gnupg/pubring.gpg
sudo apt-get update

7. Install Cassandra:

sudo apt-get install cassandra

8. Next you need to change Cassandra’s default port number from 8080 to something else, because the 8080 port typically conflicts with SSH terminal connections. Use Nano to open up the Cassandra configuration file using the following command:

sudo nano /usr/share/cassandra/cassandra.in.sh

9. Then change the port number 8080 on the following line to 10036, and save the file:

-Dcom.sun.management.jmxremote.port=10036 \

10. Start Cassandra with the command:

/etc/init.d/cassandra start

Once you have Cassandra running, test it with Cassandra’s command line tool CLI. Use the example found on the Cassandra Wiki.

How to Update Ubuntu Hardy to PHP 5.2.9

First upgrade your software as is.

>> sudo apt-get update

>> sudo apt-get upgrade

Then add the following to your /etc/apt/sources.list file.

>> sudo nano /etc/apt/sources.list

deb http://http.us.debian.org/debian stable all
deb http://security.debian.org/ stable/updates main contrib
deb http://packages.dotdeb.org/ stable all

Finally run the update to install PHP 5.2.9.

>> sudo apt-get update

>> sudo apt-get install php5-cli

>> sudo /etc/init.d/apache2 restart

How to increase or decrease your Boot Camp partition

If you’re running Mac OS X and Boot Camp you may need to increase or decrease the size of your Microsoft Windows Boot Camp partition, depending on what great videos games are out for Windows at the time. 😉

To accomplish this task without losing all your Windows data you need 3 things.

  1. Mac OS X 10.5 (Leopard)
  2. An HFS+ Mac-formatted external drive
  3. Winclone

To decrease the size of your Windows partition use the following steps.

  1. Make a backup of your Boot Camp partition from Windows. (optional)
  2. Run Winclone.
  3. In the “Tools” drop down click “Shrink Windows (NTFS) file system.”
  4. Follow the onscreen instructions.
  5. Wait… it takes awhile.
  6. In Winclone create an “Image” to your Mac-formatted external hard drive.
  7. Use Boot Camp Assistant to return your drive to a 100% Mac-formatted partition.
  8. Use Boot Camp Assistant to make a new Boot Camp partition larger than the file size of your “shrunk” Windows partition image, but smaller than your original Boot Camp partition size.
  9. When it asks for Windows disk, quit Boot Camp Assistant.
  10. Run Winclone again and “Restore” your Windows image to the new partition.

To increase the size of your Windows partition use the following steps.

  1. Make a backup of your Boot Camp partition from Windows. (optional)
  2. Run Winclone.
  3. In Winclone create an “Image” to your Mac-formatted external hard drive.
  4. Use Boot Camp Assistant to return your drive to a 100% Mac-formatted partition.
  5. Use Boot Camp Assistant to make new Boot Camp partition larger than your original partition size.
  6. When it asks for Windows disk, quit Boot Camp Assistant.
  7. Run Winclone again and “Restore” your Windows image to the new partition.

Kind of a pain, but it’s doable. I’ve altered my Boot Camp partition numerous times using the methods above.