Archive for the ‘Howto’ tag
Simple Applescript For The Traveling Mac
The Problem
You have a MacBook and a nice Apple Cinema display (this doesn’t sound like a problem so far), and you travel with the MacBook every day. When you open the lid of your MacBook you like to have the Dock on the left side of the screen giving you the most top to bottom space, but when you come home and connect the MacBook to your Cinema display and set up dual monitors, you want the dock on the bottom of the Cinema, not on the left side of the MacBook.
You don’t want to have to go in to preferences every time to switch the location. (or maybe you do?) For me it was becoming a very tedious task, so I began researching ways to automate it.
The Solution
Leverage Apple’s “Language of Automation”, Applescript to handle the task. Applescript has lots of useful hooks in to OS X.
The requirements for the script are quite simple:
- Obtain the current resolution of the primary monitor
- if the resolution is > 1900 (Cinema Display) configure the Dock for large display
- else configure the Dock for laptop display
For the moment, that is my goal, simple, yet time saving.
Step 1: Open AppleScript Editor
Step 2: Paste the following code in
Future requirements
- Figure out how to hook the script in to sleep/wake events in Snow Leopard.
- Customize more than just the Dock.
- Migrate it in to a startup script that brings up all necessary applications based upon current mood (reading/blogging/coding).
- Others???
Overall, I find Applescript a very easy way to automate things in Snow Leopard.
All of the source for this post can be found on github.com. Please feel free to fork and improve.
Enjoy.
Easy Upgrades
Who doesn’t like easy upgrades? Easy upgrades are great when implemented correctly. There are two speciifiic easy upgrades I have been (enjoying) using recently, namely, Wordpress and Ubuntu Server.
This blog has been powered by Wordpress for a long time, and has been upgraded many times along the way. Download the latest tgz file, unzip it, save your wp-content directory, upgrade your database, and then you are good to go. Keep in mind this was a very simple procedure, as they call it their “famous 5-minute installation”, which it typically was.
Once upgrading to 1.7, the procedure became as easy as clicking a link on the admin page, and stepping through a wizzard This blog is now running 1.8, so it has been through several automatic upgrades already, and each one of them has been completely boring, which when talking about upgrading an environment, is a very good thing. This magic does not only apply to upgrading the entire platform, as you can automatically upgrade your plugins as well.
Many years ago I set up several Ubuntu Gutsy Gibbon (7.10) Servers in my basement to serve different purposes on my internal network. These servers have been running without issue for the past 2 years. They would probably run seamlessly for another 2 years, but unfortunately, I needed to install a new package that didn’t have a deb available for the current version of Ubuntu. At first I was trying to find ways around this, installing the sources instead, but that didn’t work well for me, as it needed a newer version of a dependent library. Even considered trying a different software package, but it seemed like all of the software packages I was trying to install, required a newer version of Ubuntu.
What was I left to do? Either upgrade or rebuild from scratch. Based on past experiences with other distros, upgrades have been nothing but headaches for me. Since, I really didn’t want to invest the time to rebuild the server from scratch, decided to try my first Ubuntu upgrade. Again, based on my past experiences, I assumed I needed to download the media, and then hook up a monitor to the server, and finally go through a set of upgrade screens.
To my delight, after a little bit of research I found that you can do the entire upgrade from the command line, no user interface required, no media download required, no monitor required! This was too good to be true right? Well, no. I ran the do-release-upgrade command, and now my server is running Hardy Heron (8.04). Couldn’t be any easier. Ubuntu’s upgrade infrastructure is very impressive.
What is the moral of the story? If you want to build a loyal user community, treat the members of the community well by providing them with an easy upgrade path.
Quicksilver is a timesaver
It has been a while since a single program changed my workflow as much as Quicksilver has.
Over the years, it has been covered a lot on the Mac sites, but it never really seemed like something that would help me. Guess it was the stubborn side of me refusing to try something new. So the question is what changed my mind now? Two things:
- The Productive Programer – In his book Neil Ford describes several work flows involving Quicksilver that actually made sense to me, especially the Subversion plugin.
- Pragmatic Thinking And Learning – Again, the virtues of Quicksilver described in such a way, that made a lot of sense to me.
After reading these two excellent books, it was time for me to give it a try, and see what it has to offer. It has been about a week now, and it is hard to imagine using my Mac without it. It has increased the efficiency of my workflow tremendously. The mouse has become optional for most tasks. It has sped up common tasks for me such as checking in/out files from Subversion, opening documents to edit, quickly composing emails and attaching files, and my favorite time saver is this neat trick that allows you to lock your computer with a simple keystroke. Previously, it required clicking on the “lock screen” option in keychain.
If you are a Mac developer like me, and you are in to efficiency, you need to at least give Quicksilver a try. You won’t be disappointed.
Keyboard Shortcuts
Do you want to learn all of the keyboard shortcuts to your favorite Java IDE, but just don’t have time to study a cheat sheet? Are you envious of your team lead because when you peer program with them, they are able to get things done without using the mouse?
You ask your self how did they do it? Do they memorize a cheat sheet while on the Subway? Do they go home and practice coding every night? Are they gifted with great memories? Well, they may be all of these things, but you don’t have to be!
All you need to do is install a plugin called Key Promoter that is available for both Intellij and Eclipse. The way it works is every time you use your mouse to accomplish a task that can be accomplished via a keyboard shortcut, it pops up a window and lets you know. In the Intellij version, it actually keeps track of how many times you used your mouse for each action. It becomes insulting after a while if you see you used your mouse 20 times for the same action, knowing it has shown you the corresponding keyboard shortcut each time.
For more details you can find the Intellij plugin here, and the Eclipse plugin here.


