Archive for the ‘Mac’ Category

Squeak Smalltalk: Error recovery in a live open system

November 24th, 2010 3 comments

Vestigial Panic

Photo by star5112@flickr

I accidentally changed the subclass of a morph that was open in the world – oops.  My screen began filling with dozens of error windows.  Right around this time, I started thinking about quitting and rebooting.  And then I remembered… this isn’t Windows!  I can recover from this – and probably quickly.  So I brought up halos on the hosed morph, clicked the delete halo, pressed the user-interrupt shortcut (Cmd-. on Mac) and went for a glass of water – okay, it was wine – stop judging.

Room to Breath

When I got back, I had a debugger open on the event loop, so I knew that the pain had stopped getting worse.  Now I just had to figure out what to do about all those error windows.

Photo by mliu92@flickr

Like a trained seal, my first move was to press the close button on each one.  This got old after the first two, and I remembered I was using Smalltalk.

Brief Digression

After years of being institutionalized by Windows… and Mac (yes fanboys, it’s only slightly better than Windows, and can’t begin to touch what Engelbart and Kay were doing in the 1960′s and 1970′s), I constantly forget that I’m working in a live, open system, and do idiotic, inefficient things like hitting the close button on 50 error windows.  Like the movie Momento, where he wakes up every day and doesn’t remember who he is or what he’s supposed to be doing…

Smalltalk Nirvana

Back to my senses, I took 10 seconds to write a snippet that closed all the windows:

errorWindows := (World submorphs select: [ :m |
  (m respondsTo: #label) and:
    [ m label beginsWith: 'NonBooleanReceiver' ] ]).
errorWindows do: [ :e | e delete ]

And I was back in action.  Of course, this particular example probably only saved me 10 minutes, but multiply that by X times a day for a year and you get a glimpse of the power of Squeak Smalltalk – a live, open, beautiful system.

Categories: Mac, Smalltalk, Squeak Tags:

Downloading the Squeak VM

June 16th, 2010 No comments

I wanted to download a the latest Squeak Mac virtual machine from  I knew that I had to connect as a guest via FTP, but it took a while for me to figure out how to accomplish this (seemingly simple) task.

From what I gathered from forums, Finder is not a good option to get files via FTP (although there seem to be workarounds).  When I tried Terminal, I kept getting a mysterious error (are there any other kinds with computers, lol): “bind: Invalid command `rl_complete’.”  In addition to being totally useless in telling me what was going on, there wasn’t any info online.  Thanks to the fickle gods, the error disappeared just as mysteriously.  The command ended up being:

ftp -a



With the second option, you enter your email address when prompted for a password (this seems to happen automatically with the first one).

The remaining steps were (at the ftp command prompt):

  1. binary
  2. get “Squeak”

And that was that, the file was downloaded into my home directory!

Categories: Mac, Squeak Tags: , ,

Applescript to change genres in iTunes

May 12th, 2010 No comments

There is this awesome programming language in which the entire system (down to the graphics libraries, window system, and compiler) is available to you to reinvent, opening the possibility of truly open computing.

Obviously, I’m talking about Smalltalk. But if you are too afraid to give MS and Apple the bird for not learning (or wanting to learn?) the computing lessons of the 1970′s, there is another option which lets you bend almost any Mac application to your will, breaking it from the chains of presumptuous software giants who think you should work the way they design instead of vice versa.

I’m speaking, of course, of Ruby, lol. If you’re doing any serious Applescript development, ditch Applescript altogether, and check out the rb-appscript library.  It allows you to do anything you can do in Applescript, in a non-ambiguous way, with the power of a full programming language behind you – trust me, it’s the heaven where Applescript will go when it finally dies.

However, if you’re doing something simple and common, especially in a very scriptable application like iTunes, sometimes it’s easier to just crank up AppleScript Editor and hack out a one-liner.

Thus this very simple script to change the genres of iTunes tracks, which I used to fix things like some tracks in the “rock” genre and others in the “Rock” genre.

tell application "iTunes"
  set tracks_to_fix to file tracks of playlist "Music" of source "Library" whose genre ends with "ock"
  set genre of tracks_to_fix to "Rock"
end tell

Adding Quicklook support for Ruby files with different/no extensions (e.g. rake files)

March 4th, 2010 No comments

1. Download the excellent qlcolorcode bundle from Google Code

2. Add the following line to QLColorCode.qlgenerator/Contents/Info.plist:

So that it looks like this:
3. In QLColorCode.qlgenerator/Contents/Resources/, add (and customize) the highlighted code, which you can get at github:
4. Oops!  Forgot, you may have to sudo touch /path/to/QLColorCode.qlgenerator for changes to take effect
Categories: Mac, Ruby Tags: , ,

Quicklook any plain-text file e.g. HAML or ERB

March 3rd, 2010 No comments

I’m often jumping from file to file in Rails, so I really wanted Quicklook support for my template files.  Unfortunately, the suggestions I found online were confusing and incomplete.

Here’s a really easy way to get it done – but no syntax highlighting :(

1. Show the contents of TextEdit’s package

2. Open Info.plist in a text editor… like TextEdit, perhaps… hmm…
3. Anyway, add the following snippet (find the code on github):

Put it just before the following section:

4. Customize
  • UTTypeDescription - put in description of your choice (although you probably don’t need to)
  • UTTypeIdentifier – apparently (and this is what was missing from other descriptions), you just make something up here
  • public.filename-extension – add as many extensions as you want to map to this file type
5. Gloat

Categories: Mac, Rails, Uncategorized Tags: , , ,

Fixing Parallels Desktop Start menu and Spotlight Clash

December 13th, 2009 No comments

Parallels Desktop crystal mode is awesome.  When combined with the “Mac look” option, you don’t even know you’re in Windows…

The only issue I ran into is that when you hit CMD+Space for Spotlight, the Windows Start menu pops up and makes Spotlight disappear.  The fix was easy enough:

  1. Exit crystal mode
  2. Go to Parallels Preferences menu
  3. Under the Keyboard & Mouse tab, create two shortcuts
    1. Change the Cmd -> Win shortcut to whatever you want to open the Windows Start menu (you can see I set it to Ctrl+Space above, in the spirit of Spotlight)
    2. Create a dummy Cmd shortcut to Ctrl (basically to have it od nothing in Windows).  This will just have Parallels forward the Cmd to the Mac side and open Spotlight.
Categories: Mac Tags:

Change selection in Safari via JavaScript

November 19th, 2009 No comments

It’s easy to get the current selection with Javascript. It’s easy to select an entire node.

But what if you want to create a selection that spans multiple elements?

Easy (after a few hours of bumbling around, lol):

  1. Select the text in the element where you want the block to start (I used window.find())
  2. Save the start point in a range object with setStart
  3. Repeat 1 & 2 with the end point, setting the end of the range object
  4. Select the (multi-node) range object you just created with window.getSelection().addRange()

Get the code here.


Categories: Mac Tags: ,

Applescripting Xcode

November 11th, 2009 2 comments

Have you wanted to automate your Xcode workflow, but couldn’t figure out exactly how to work the AppleScript commands? Well, here’s a whole object-oriented library of handlers for ya!

(Sorry I haven’t figured out a better way to format AppleScript code in a blog; any ideas, please let me know)

on target_object(the_target)
    script target_obj
        property target_ref : ""

        to add_source_file(the_file)
            tell application "Xcode"
                add the_file to (get compile sources phase of target_ref)
            end tell
        end add_source_file

        on set_header_search_paths_for_all_configurations(the_path)
            tell application "Xcode"
                (* configuration is Debug or Release *)
                set value of build setting "HEADER_SEARCH_PATHS" of build configurations of target_ref to the_path
            end tell
        end set_header_search_paths_for_all_configurations

        to add_run_script_phase(the_name, the_script)
            tell application "Xcode"
                tell target_ref
                    return make new run script phase with properties {name:the_name, shell path:"/bin/sh", shell script:the_script}
                end tell
            end tell
        end add_run_script_phase
    end script

    tell application "Xcode"
        set target_obj's target_ref to the_target
    end tell
    return target_obj
end target_object

on group_object(the_group)
    script group_obj
        property group_ref : ""

        to add_file(the_path, the_file_name)
            tell application "Xcode"
                tell group_ref
                    return make new file reference with properties {full path:the_path, name:the_file_name}
                end tell
            end tell
        end add_file

    end script
    set group_obj's group_ref to the_group
    return group_obj
end group_object

on active_project()
    script project_obj
        property project_ref : ""

        to add_group(group_name)
            tell application "Xcode"
                tell project_ref
                    -- Get project directory
                    set project_dir to project directory

                    -- Create new folder for group's files
                    tell application "Finder"
                        set file_lib to load script alias "Macintosh HD:Users:sean:Library:Scripts:My Library:Files.scpt"
                        make new folder at (file_lib's posix_string_to_hfs_file(project_dir)) with properties {name:group_name}
                    end tell

                    -- Create new group
                    tell root group
                        return my group_object(make new group with properties {name:group_name, path type:project relative, path:group_name} at beginning)
                    end tell
                end tell
            end tell
        end add_group

        to make_new_shell_tool_target(target_name)
            tell application "Xcode"
                tell project_ref
                    set unit_test_template to target template "BSD/Shell Tool"
                    return my target_object(make new target at end of targets with data unit_test_template with properties {name:target_name})
                end tell
            end tell
        end make_new_shell_tool_target
    end script

    tell application "Xcode"
        set project_obj's project_ref to project of active project document
    end tell
    return project_obj
end active_project

You can also download the scpt file here.

And here’s a script that uses the handlers.

Categories: Applescript, Xcode Tags: ,

Undo last action in PersonalBrain

November 9th, 2009 No comments

Until now, undoing your last action in PersonalBrain has been annoying – there is no shortcut, so you had to choose undo from the menu.

Here’s a short Applescript that does it for you:

activate application “PersonalBrain”

tell application “System Events”

tell process “PersonalBrain”


– See if there is a list of undos

get value of attribute “AXChildren” of menu item “Undo” of menu 1 of menu bar item “Edit” of menu bar 1

– If there is, undo the most recent

click menu item 1 of menu 1 of menu item “Undo” of menu 1 of menu bar item “Edit” of menu bar 1

on error

– There are no children, so click Undo

click menu item 1 of menu 1 of menu bar item “Edit” of menu bar 1

end try

end tell

end tell

Assign a shortcut to the above script and… you have vanilla undo… yay!

Categories: Applescript Tags:

Quickbooks for Mac 2010 Time Activity Bug

October 28th, 2009 No comments

I’ve run into a bug which is discussed here.  In summary, after entering a single time activity, hitting “next” or “previous” causes problems.

With the following Applescript, when you’re finished entering a time activity, you hit ctrl+n (or whatever shortcut you choose), and voilà:

  • you have a saved entry
  • a new blank form
  • you can scroll to previous and next to your heart’s content!

That is – it works the way it’s supposed to, lol

Here’s the code:

tell application “System Events”

tell process “QuickBooks 2010″

click button “OK” of window “Enter Single Activity”

perform action “AXPress” of menu item “Enter Single Activity” of menu 1 of menu item “Time Tracking” of menu 1 of menu bar item “Employees” of menu bar 1

end tell

end tell

Here’s what you do:

  1. Paste the above script into AppleScript Editor
  2. Save the file (as a script) to: /[your user folder here]/Library/Scripts/Applications/QuickBooks/Save time activity and create new.scpt
  3. If you have an script menu app (FastScripts is the absolute best!), you can assign a shortcut to it, like ctrl+n)
Categories: Applescript Tags: , , ,

windows 7 product key

windows 7 product key

windows 7 key generator

windows 7 key generator

free winrar download

free winrar download

winzip activation code

winzip activation code

free winrar

free winrar

winzip free download

winzip free download

winrar free download

winrar free download

winrar download free

winrar download free

winzip free download full version

winzip free download full version

windows 7 activation crack

windows7 activation crack

windows 7 crack

windows 7 crack

free winzip

free winzip