Clean flashlog.txt with a keystroke

5/02/2009

Scenario: You’re working with the Flex SDK and you’re tracing messages to the Terminal via flashlog.txt. The damn logfile has heaps of clutter in it from the last project you were working on, and you want to clean it up.

Solution: Save this snippet and assign it a Quicksilver hotkey:

1
2
3
4
try
    do shell script "rm ~/Library/Preferences/Macromedia/Flash\ Player/Logs/flashlog.txt"
    do shell script "touch ~/Library/Preferences/Macromedia/Flash\ Player/Logs/flashlog.txt"
end try

Result: You are happy. Go drink beer.

No Comments

Center and resize window with AppleScript

9/01/2009

I use a 15″ MacBook Pro that I carry between work and home. At work I have a 30″ Cinema Display which means I can actually have half of the Flash IDE showing at once. Mostly it’s plug and play but every once in a while some app just doesn’t realize that I’ve unplugged the huge display and some window ends up at some awkward position where I have to drag it out and resize it, or even worse; It ends up outside the boundaries of the laptop screen altogether.

AppleScript to the rescue. Copy this script and save it into your AppleScripts folder. You can assign it to a Quicksilver hotkey if you’d like, but I find it’s convenient enough to just launch it from Quicksilver in the usual manner.

What it does is simply resizing the window and centering it on the display. There are more elegant ways to do this, but this one works even with apps that have little or no support for AppleScript at all. You can adjust the lines:

1
2
  set position to {220, 50}
   set size to {1000, 800}

to fit your screen real estate as those values are set to center on a 1440 / 900 display.

1
2
3
4
5
6
7
8
9
10
tell application "System Events"
  set frontmostProcess to name of first item of ¬
  (processes whose frontmost is true)
  tell process frontmostProcess
          tell window 1
              set position to {100, 0}
              set size to {1200, 800}
        end tell
    end tell
end tell
No Comments

Life hack: On the Job + Marco Polo

24/11/2008

Onthejob
The odds are good that you have to keep track on how much time you spend on any individual project for billing reasons or what have you. If you’re anything like me (and why wouldn’t you be) your fantastic right hemisphere of the brain makes you profoundly sucky at performing this dreary task.
Enter On the job, a quite wonderful little app that’ll do the job for you. However; If you are afflicted to the degree I am with this complete and utter incompetence at important but boring chores, you have difficulties even remembering to open the app to let it do it’s thing. ‘Why Martin, it’s simple’, I hear you exclaim, ‘you just put it in your start-up items, so that every time you start up your work computer it’ll launch the app!’ Well, no. You see, I use a MacBook which I carry between the office and home, and my innate loathing of shit starting up each time I start up my Mac would annoy me to no end. Besides, a more than likely scenario would be me quitting the app when going home and then forgetting to start it up again when I’m back at the office. Yes; I’m that terrible.

I considered this while in the shower, as these things are wont to happen, and came up with the idea of trying to make my laptop sniff out which wi-fi I was connected to and thusly be able to perform certain tasks based on that information. I started trying to work out whether it’d be possible to AppleScript a solution, or whether I’d have to try and apply my nigh-non existing Cocoa skills to pull this off.

Marco Polo
Ask and ye shall receive. Of course, if there’s a good idea to be had, most likely someone beat me to it. Enter Marco Polo.
This absolute gem of an app promises (and in the 30 mins I’ve used it; Delivers) context awareness for your Mac based on a whole load of criteria. For my purposes all I had to do was to make it sniff out the SSID of my office Wi-Fi and launch On the Job whenever the rule matched. I’ll also be setting it up to launch MediaLink when at home so that I’ll instantly start streaming media to my PlayStation. Yet these examples are just the tip of the proverbial iceberg. The possibilities are, perhaps, not endless but certainly numerous. I highly recommend checking out this killer combo, or just Marco Polo if your short term memory is better than mine (not hard) but context awareness might be interesting for you anyway.

On the job is shareware ($25) and Marco Polo is free as in speech and beer.

No Comments

Keyboard shortcuts in System Preferences

29/07/2008

A big pet peeve of mine is that unlike most other apps Mail.app is a goddamn hassle to just quickly switch to.
If you’ve closed the window in Mail rather than just hidden or minimized it, it seems to be no way to make it reappear with a keystroke. Instead you have to actually move your mouse to the dock and click the icon. Unacceptable.
The solution? Open your system preferences and navigate to the Keyboard Shortcuts tab under “Keyboard & Mouse”. Scroll to the bottom and make a new entry for Mail.app and create a shortcut for the Menu item “Message Viewer”. Map it to the keystroke you’d like (I chose ⌘-O) and you’re set to go.

System Prefs Create Shortcut

The cool thing is that you can pretty much create shortcuts for any menu item in any app. In theory.
Sadly it doesn’t consistently work in all apps, as I’ve outlined once here, and of course it only works for menu items, so for more specialized stuff you’ll have to use more advanced alternatives such as QuicKeys, which I gave a short introduction to here.

No Comments

Stupid mac tricks

9/01/2008

Macs are awesome.

1. Invert the screen

To freak out your friends just wait until they leave the keyboard for a sec and hit CMD – CTRL – OPT – 8.
In fact I used to do this when using my mac during lectures because the inverted screen was less disturbing in the dark.
To reset it just hit the aforementioned key-combo again.

inverted screen

2. Distorted browsing.

1. Set your Dock?s minimize effect to ?Genie? (or the hidden ?Suck? choice, using TinkerTool).
2. Open Applications ? Utilities ? Terminal.

3. Type “killall Dock” (no quotes) but don?t hit Return just yet.
4. Open Safari and load a decent sized website, like Digg.
5. Switch back to the Terminal, keeping the Safari window in view.

6. Shift-click the yellow minimize button of the Safari window, and hit Return to execute the command while the window is busy morphing.

The Dock process will be killed, and it will disappear, leaving the Safari window with nowhere to go. The window will freeze mid-transition. The cool part is that the window is still responsive, and you can scroll around and see the content transform in real-time.

The Dock automatically relaunches, so you don?t have to worry about breaking anything. Finish minimizing the window, or do CMD-W to close it.

(Via Command-Tab.)

3. Zoom with the scroll-wheel

Another functionality that was probably intended for accessibility but can be loads of fun as a prank on a less savvy friend. With a scroll-wheel mouse press ctrl and scroll the wheel to zoom the screen to some ridiculous proportion. Stand back and watch as your buddy panics. To really screw up someones day if the have a pre-Leopard Mac; Zoom the screen just one pixel. This results in everything getting slightly blurry and your buddy/mother-in-law will think there’s something wrong with their monitor.

4. Free psychoanalysis

screenshot

1. Open a new Terminal window. (Finder -> Applications->Utilities->Terminal).
2. Type “emacs” (no quotes) and hit enter.
3. Press ESC and “X” simultaneously. “M-x” should appear at the bottom.

4. Type “doctor”.

This should launch the Eliza shrink-sim. Fairly silly stuff, but hey! Why shill out for a therapist when you’ve got one sitting in your terminal?

(Apparently you can play tetris and do all sorts of wacky stuff in the terminal. Find more at The Easter Egg Archive.)

5. Knock knock…

screenshot

Open the “Speech” prefpane in System Preferences and activate “Speech recognition”. Tell your mac to “Tell me a joke” to get a plethora of inane knock knock jokes.

1 Comment