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

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