Tag Archive for 'OS X'

[Hint] Using Windows keyboard in OS X Leopard

Since sometimes I’m awfully lazy - I got myself a second keyboard, just for the sake of not having to carry one to office and back. At home I use my beloved Apple Keyboard, while at work - a crappy, no-name, ten-bucks-a-piece one (it does it job, though!).

However, since at work I use a Windows keyboard I had a problem with the switched Option / Command keys. I’ve tried DoubleCommand, however I had to click through the System Preferences each time I switched my keyboard. Couple of minutes of googling and a nice script popped out. However, it was useless in OS X Leopard, so I made a couple of quick changes and here’s something I came up with. First, switch-to-windows-keyboard script:

tell application "System Preferences"
	activate
	set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
	get properties
	tell process "System Preferences"
		click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"
		click pop up button 2 of sheet 1 of window "Keyboard & Mouse"
		delay 0.3
		click menu item 4 of menu 1 of pop up button 2 of sheet 1 of window "Keyboard & Mouse"
		delay 0.3
		click pop up button 1 of sheet 1 of window "Keyboard & Mouse"
		delay 0.3
		click menu item 3 of menu 1 of pop up button 1 of sheet 1 of window "Keyboard & Mouse"
		delay 0.3
		click button "OK" of sheet 1 of window "Keyboard & Mouse"
	end tell
end tell
tell application "System Preferences"
	quit
end tell

Second, back-to-apple-keyboard script:

tell application "System Preferences"
	activate
	set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
	get properties
	tell process "System Preferences"
		click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"
		click button "Restore Defaults" of sheet 1 of window "Keyboard & Mouse"
		click button "OK" of sheet 1 of window "Keyboard & Mouse"
	end tell
end tell
tell application "System Preferences"
	quit
end tell

You might ask why not use Ryan Block’s script? Well, since I rely heavily on QuickSilver I also created two Platypus applications - one for each script. I’m a keyboard user, so I didn’t like the clicking on the Macintosh / PC screen. ;-]

[Release] Fluid’s Google Reader Fix

For quite a few weeks I’ve been using Fluid with Google Reader - having a standalone WebKit based application with dock notification works great for me. However, one thing has been bothering me - Fluid never clears the dock badge when all the items are read. I’ve just posted a little fix for this issue - grab it at http://userscripts.org/scripts/show/23422.

Let me know if this works for you!

[Howto] Installing and using mysqldiff

What happens when you have to compare structures of two databases? Well, first thing - with all the great tools around (watch and learn: ActiveRecord’s Migration) you shouldn’t have let this happen. But since you’re reading this you’re probably already facing this problem.

We have a couple of options: Windows users could try SQLyog MySQL GUI - Enterprise Edition, PHP folks have MySQLdiff, but there’s another thing you might want to try. It’s my favourite since CocoaMySQL and command line client suit me well for every day work and I don’t fell like spending $50 on a piece software that I might (or not) use once a year. I present to you mysqldiff (what a fancy name)!

I’m using OS X 10.5.1 with default Perl installation, so first I had to install the prerequisites - Class-MakeMethods. Download the package and from the command line execute:

tar xzf Class-MakeMethods-*.tar.gz
cd Class-MakeMethods-*
perl Makefile.PL
make test
sudo make install

Now on to the mysqldiff. After downloading we need need to execute the same set of commands:

tar xzf MySQL-Diff-*.tar.gz
cd Class-MakeMethods-*
perl Makefile.PL
make
sudo make install

And you’re done - by default mysqldiff is installed to /Library/Perl/5.8.8/MySQL/mysqldiff.pl.

An example:

mysqldiff.pl --host=host.com --user=user --password=password database_1 database_2

This command will list all the queries required to recreate the exact structure of all the tables of the database_2 in database_1. You can also run mysqldiff.pl with --apply switch, but I always like to check the script before executing it.

That’s it - if you know a better tool - be sure to let me and others know in the comments to this post.