Friday, February 1, 2013

Microsoft Keyboard with Mac OS X

Boring story...

(you can skip this part)
I've always favored using the best tool for the job at hand.   This is something I learned along time ago when working with my grandfather in his workshop.  If you have a nail then the tool to use is a hammer.  Probably not just any hammer either, there are actually hammers designed to drive nails and ones that aren't.   Of the ones designed to drive nails there are different sizes and different manufacturers.  Sometimes the manufacturer makes a difference and sometimes it doesn't.  I've never forgotten those years and I always have looked to apply those same principals in choosing technologies to work on various software projects during my 28 years developing software commercially.  That's what left me trying to use the keyboard I have grown quite use to using with the new Mac Mini that I just recently started using.   In this instance writing code is the nail and my hammer of choice is the...

Microsoft Natural Ergonomic Keyboard 4000 v1.0

It is perfect for me.  Unfortunately, even with the Microsoft supplied Mac OS X Intellipoint device drivers the keyboard was frustrating to use on the Mac Mini.  The most frustrating point was the number pad NumLock key.  It simple didn't function as a NumLock.  The keypad on this keyboard when attached to the Mac OS X 10.8 (Mountain Lion) operating system was simply always in number mode.  I use the number pad to navigate around my code and it simply would no longer work.  I was frustrating myself trying to use the keyboard.  I would edit code and constantly being inserting 2's, 4's, 6's and 8's.   What a mess.   Countless searches trying to find a solution turned up many people who shared my problem but NO solutions.  I started to contemplate,  was it time for a new hammer?   I think not!

As luck would have it I found an answer!

KeyRemap4MacBook
http://pqrs.org/macosx/keyremap4macbook/

We despite the title it worked for my Mac Mini.  In no time at all this genius little utility fixed the issue for me by making the NumLock key work.  I was so happy I donated to his cause so he could have a couple beers on me.

If you decide to use the utility to solve this particular problem I can save you some time looking through the hundreds of settings available with this utility.  Once you have it installed.  Go to System Preferences -> Other -> KeyRemap4MacBook  then choose the section labeled "For PC Users" and you'll see a few different options.  The one you want is:

"Use clear key to toggle "Keypad as Arrow (PC Style Home/End/PgUp/PgDn)"

In addition to that setting there are a few others under this same section that will likely help you out if you're like me and spend a majority of your day using a Windows OS.

As always I hope this helps someone with the same issue I was having.

Tuesday, August 7, 2012

MySQL where to start performance tuning

Recently I needed to setup an instance of MySQL on CentOS and I found myself once again wonder where to start tweaking to get initial performance of the server beyond defaults. I'm a firm believer that early optimization can lead to problems but I figured there must be some basic common sense things to do with MySQL that would tune it to the environment where it lives. My initial search turned up this page:

http://library.linode.com/databases/mysql/centos-5

I often start with documentation on the linode.com site since I use there VPS services. Rather then just blindly make the changes recommended for a "low" memory environment I decided to do a bit more reading in the MySQL documentation. I was trying to discover what (if any) difference there was between "key_buffer" (shown on this linode page) and "key_buffer_size" (as outlined in the MySQL documentation) I never did find an adequate explanation although one post I found suggested that key_buffer_size was depreciated. (apparently they both will work) In any event, I didn't dig any further because in digging around I found a script that seems to be quite helpful with my original quest to tune MySQL to my server environment.

You can locate the page here:

http://www.day32.com/MySQL/

There are several scripts on this page that may be useful for future stuff but the script MySQL Performance Tuning Primer Script located at the top of the page is the one I started with. I downloaded it using:

wget http://www.day32.com/MySQL/tuning-primer.sh

I reviewed the script (just stating the obvious and if you don't know why then you shouldn't ever download anything) before marking it as execute and running it. This script ran without any problems on CentOS. It dumps a bunch of recommendations to the console and upon the initial review it the recommendations appear to be solid.



Of course, I didn't stop there. I wanted to run the script on a VPS (linode.com) where I have another instance of MySQL. This server is setup with Ubuntu 10.04 (Lucid) and unfortunately the script did not run immediately. I received a nice error message from the script:

"Error: Command line calculator 'bc' not found!"

The script has a dependency on BC, a free command line calculator. I installed this with:

sudo apt-get install bc

to provide the necessary dependency and this got things going on Ubuntu for me.

Overall the script will be most useful if you have been running your MySQL instance for a while and have some useful data for it to review.

REFERENCES
MySQL Scripts by Matthew Montgomery
Reference to key_buffer_size being deprecated
MySQL documentation