Tag Archive: “mac”

Bookmark in Yojimbo for Camino

I’ve posted a Camino-compatible version of my venerable Bookmark in Yojimbo script.

Update: Revised for Camino 1.6. New in Camino 1.6 is the ability to add any script in ~/Library/Scripts/Applications/Camino to the toolbar, so you don’t even need to use a separate script runner.

Posted on Tuesday, March 4th, 2008.

Remote Applications

BCC provides remote access to “licensed campus software”. This allows students to log in from off campus to use desktop software hosted on campus. I’m not too familiar with the protocol, but it seems like a Windows-oriented combination of VNC and X. Happily, clients are available for many platforms.

All I had to do to get started was download the Mac OS X Citrix ICA Client. Choosing a program from the access page downloads a “bookmark” that the client uses to launch the remote application.

Here’s Microsoft Word 2007 running in the background with a local application in the foreground. Sharp eyes may notice minor compression artifacts in the Word window. Connecting from across town, performance is sufficient to get work done.

Microsoft Office 2008 Ultimate Pro Premium Remote Ribbon and Bow Edition

Of course, the real benefit of this system is access to specialized professional applications, not word processors. Not all software available on campus is remotely accessible, but some of it is.

AutoCAD Mechanical Desktop 2004

You can also access a virtual Windows desktop. Handy for confirming the cross-platform compatibility of mathematical curios without the need to maintain a separate PC.

Eyeball fork not included

Remote applications of this sort are surely unsuited for many purposes. However, I think it is a viable approach for occasional use, particularly in cases where an institution provides software that isn’t otherwise practical for its members to obtain. Good for wrapping up projects without hasty trips to the computer lab, I imagine.

Posted on Monday, March 3rd, 2008.

State Abbreviations Service

Here’s a little service for Mac OS X that replaces the selected US state name with its postal abbreviation, or vice versa. If NY is selected, it will be replaced with New York. If New York is selected, it will be replaced with NY. Case doesn’t matter.

Download State Abbreviations Service 63K

Posted on Friday, February 29th, 2008.

Pascal’s Triangle

Recently I was introduced (or perhaps reintroduced) to Pascal’s Triangle, an arrangement of integers that lends itself to a variety of purposes, including binomial expansion. I’ve written a little program to explore this aspect of the idea.

Explanation? Bah. Experiment!

Features

Screenshots

Mac OS X looking at a large expansion Windows as seen on WINE X11 (has font issues)

Download

Posted on Monday, February 25th, 2008.

Hacking Leopard Help

Update: A better way to improve the help viewer’s usability is documented here.

Mac OS X 10.5’s help viewer application is widely considered to be a piece of crap. Unlike the help viewer in previous iterations of Mac OS X, it presents no Dock icon, no proper menu bar, and exhibits an annoying tendency to obscure the application you needed help with in the first place.

So, fix it. Or at least have your vengeance by grossly disfiguring it.

Navigate to /System/Library/CoreServices. Copy Help Viewer.app to the Desktop, right-click the copy, and select Show Package Contents.

Open the Contents folder and open Info.plist. Change the value of the LSUIElement property to 0:

lsuielement

This makes the application’s Dock icon and menu bar visible. There are definitely some quirks (keyboard shortcuts don’t seem to work as expected), but it works.

Next open the Resources folder and the appropriate subfolder for your localization (English.lproj in my case). Open HelpWindow.nib with Interface Builder and select the HelpWindow item:

helpwindownib

Display the Inspector (from the Tools menu) if it is not already visible and display the Attributes pane. Uncheck Utility and Non Activating under Panel Style:

panelstyle

This makes the help window look and behave a bit more like a regular window. Unfortunately, I can’t figure out how to prevent it from floating above other windows (perhaps that behavior is not controlled by the nib file). However, if you check Hide On Deactivate under Window Behavior in the same Inspector pane, the help window will at least sweep itself out of the way when you bring a different application to the front.

windowbehavior

Clicking the help viewer’s Dock icon makes the window visible again, but also creates a new help window.

To apply your changes, save and close HelpWindow.nib and drag your copy of Help Viewer.app back to /System/Library/CoreServices. You’ll need to authenticate the copy operation since you really shouldn’t be diddling around in this directory. (You did make a back up, didn’t you? Good. Neither did I.)

You can test your modified copy of Help Viewer before copying it back to CoreServices, of course, but it won’t handle requests from the Help menu until you do.

Now when you seek help, Help Viewer will actually show up in the Dock. You’ll have menus, and you can even open multiple help windows. Unfortunately, the program launches in the background, so you’ll still have to switch applications with Command-Tab or click the Dock icon to view the requested documentation.

Please share any corrections, clarifications, or further contributions to the cause! I’m no Cocoa or Interface Builder expert. Most importantly, minimize the need for constant help consultation by thinking carefully about the use and design of your application. Put reference material in a nice PDF and call it a day.

Posted on Wednesday, January 30th, 2008.

Yojimbo Tag Companions

I use this little script when I want to ensure that every Yojimbo item with a certain tag also has some other tags. For instance, to ensure that every leoben item is also tagged cylon, I run the script, select leoben from the first list of tags that appears, and cylon from the second list.

Download Tag Companions (4k)

Posted on Thursday, January 17th, 2008.

An Introduction to News Feeds

Most web sites are updated from time to time. News feeds are supplementary files (in RSS or Atom format) that provide a summary or an alternative source of recent additions to such sites. These feeds are read by programs (or web-based services) known as feed readers, which provide people with an overview of what’s new at their favorite sites.

Popular feed readers include NetNewsWire and Google Reader. I use Vienna. Current browsers can display feeds, too.

Web sites that offer news feeds are usually identified by an icon in the browser tool bar. Safari displays a blue “RSS” badge when it detects an available feed; Firefox and other browsers show an orange logo. Alternatively, a link or button within the web page, labeled “RSS/Atom,” “XML,” or “feed,” may indicate that a news feed is available. In any case, clicking the icon or link will establish a subscription to that feed.

Subscribing to an RSS feed in Safari

Your feed reader will periodically check to see if any of your subscriptions have been updated. If so, it will retrieve information about the new content — often including the new content itself — and display each new item in a list resembling an email inbox.

Viewing a subscription in Vienna

You can read new posts right in the news reader or follow a link to read them in context at the original web site. Since some news feeds provide only the title of new articles, you must visit the associated page to read the actual content in these cases.

Viewing an article in Vienna

Different feed readers provide different ways to manage your subscriptions. There are some common features, however. You can group related subscriptions, and you can save or discard items you’ve read — otherwise, they may eventually expire.

Feed readers are sometimes called news aggregators because they collect information from many sources in one convenient location. I find this service useful because it helps prevent me from wasting time online: instead of surfing from site to site and back again, I simply subscribe to sites I find interesting. It’s like receiving a newspaper instead of spending all day gathering news myself. It also helps me to keep an eye on sites I might otherwise forget to check.

Posted on Wednesday, January 16th, 2008.

Computing Power

The current Mac Pro is available with eight 3.2 GHz 64-bit cores, 32 GB of RAM, terabytes of storage, and support for up to eight 30-inch displays (eight 30-inch displays!), all in a practical form factor that runs certified UNIX.

Sure puts some of the rack-mount monstrosities I’ve met in perspective.

Anyway, perhaps you’d rather meet my calculators.

Posted on Tuesday, January 8th, 2008.

File Comparison with FileMerge

Wherein I explain the anatomy of a FileMerge window

FileMerge is a visual diff utility included with the developer tools that ship with Mac OS X. As its name suggests, it is intended to help compare and resolve differences between files. It is particularly useful for quickly and clearly reviewing changes between different revisions of a single file under version control.

You can choose which files to compare with a dialog

Compare Files dialog

or via the opendiff command:

opendiff original new

For this example, I will compare the contrived sample files used in Wikipedia’s diff article. In either use case, the files are displayed side-by-side with differences highlighted:

FileMerge window

Blue highlights indicate changes. The regions where these changes occurred in each file are connected by gray highlights.

Scrolling is synchronized to show most unchanged areas together; as you scroll, each pane moves at variable speed to maintain this visual correspondence between reference points. It’s nice.

The relative location of each change in the file is indicated by a tick mark in the scroll bar. For long files, these marks act like a simple histogram to summarize the distribution of changes throughout the file.


A dark border surrounds the currently selected difference (number 2, in this example). The up or down arrows move the selection to the previous or next difference.

The left and right arrows keys can be used to select which version of the current region of change should take precedence if you save a merged version of the files. In this example, and by default, the arrows in the center column indicate that the file on the right always takes precedence.

The separator near the bottom of the window can be dragged up to reveal a preview of the merged file. The Actions menu offers additional ways to merge the selected change.


FileMerge can preprocess a file if a command line filter is assigned to the file’s extension. This can be used to compare dynamically-generated text representations of binary files.

Default FileMerge filters


Update: The new application Changes performs a similar function with the advantage of Unicode support. Might be especially useful for revising localized files like message catalogs.

Posted on Tuesday, January 1st, 2008.

Minimal Tcl/Tk Mac Application Packages

Here is one way to create a self-contained double-clickable Tcl/Tk application for Mac OS X.

Code

Save this text as hello.tcl:

package require Tk
pack [label .l -text "Hello, World!" -padx 30 -pady 30]

For clarity, save this and other example files to the Desktop.

Tclkit

Download and unzip 8.4.16/tclkit-darwin-univ-aqua from the Tclkit download matrix. This is a universal binary version of the latest stable release of Tcl/Tk with native Mac OS X interface elements.

Update: On Mac OS X 10.5 (“Leopard”), at least with current X11 patches, you can use non-Aqua Tclkits as the basis for Mac application packages. X11 will open automatically. Since Tk Aqua doesn’t play well with Leopard, this may prove to be a useful (if ugly) interim solution.

Updatier: The Leopard compatibility problems alluded to above appear to be resolved in Tcl/Tk 8.4.17. Tclkits of 8.4.17 and the official 8.5.0 release are now available.

Updatiest: You can now build your own tclkits with ease using the Kitgen Build System.

SDX

Download sdx.kit from the SDX web page. SDX is a utility that can, among other things, create executable Starpacks by joining Tclkit interpreters with your Tcl code. (Safari may warn that the file is executable and append .sh to its name; just remove the .sh after downloading.)

Files

Open Terminal and change to the directory containing these files:

cd ~/Desktop

Make an executable copy of the Tclkit.

cp tclkit-darwin-univ-aqua tclkit
chmod +x tclkit

The duplicate is needed because Tclkit is used both to execute SDX and as input to SDX. It cannot otherwise operate on itself.

Starpack

Create the Starpack by “quick wrapping” the sample code:

./tclkit sdx.kit qwrap hello.tcl -runtime tclkit-darwin-univ-aqua

This yields the executable file hello, which you can run from the command line:

./hello

Different Tclkits can be used to create executables for different platforms. Omitting the -runtime argument creates a platform-independent Starkit which can be executed by an external Tclkit. Instead of qwrap, more complex projects can use the wrap command to package their entire directory structure as a virtual filesystem.

Icon

Every application needs a good icon. This is not a good icon, but it will suffice as an example:

icon hello.icns

Img2icns is a handy utility for converting images to icns files.

Package

Create a folder called Hello World.app. Because the app extension designates an application, the Finder will treat the folder as an application package. Control-click the embryonic application and select “Show Package Contents”:

Show Package Contents contextual menu

Create a folder called Contents inside the package, and two folders titled MacOS and Resources within Contents. Drag hello.icns into Resources and the hello executable into MacOS.

Info

Every application contains a file that lists certain application properties. Because some properties identify the very components that comprise the application, the application won’t work without this vital file.

Here is an example Info.plist. Place this file in the package’s Contents folder.

Info.plist in Property List Editor

Note that the CFBundleExecutable property identifies the executable (found in MacOS) and that CFBundleIconFile identifies the application icon (found in Resources). The CFBundleIdentifier and CFBundleSignature properties should be unique to your application. The CFBundleGetInfoString, CFBundleShortVersionString, and CFBundleVersion properties specify your application’s version.

Consult Apple’s Property List Key Reference for more details about these and other possible application properties. As XML files, property lists can be edited with text editors or Apple’s dedicated Property List Editor (included with the developer tools).

Showtime

The application package should now be organized like this:

Hello World.app
 /Contents
    Info.plist
   /MacOS
      hello
   /Resources
      hello.icns

It may be necessary to temporarily rename the application in order for the Finder to recognize the new package information. Hello World.app will adopt the hello.icns icon. Give it a double-click:

final application screenshot

The default menu bar items and window title are provided by Tk. The internal main.tcl filename is introduced by qwrap.

So, that’s a tidy way to package a Tcl/Tk program for Mac OS X deployment. The application package is really just a few folders, an icon, and a property list wrapped around a Starpack. If you’re already using Starkits, you’re only a few steps away from delivering a relatively well-integrated Macintosh version of your application.


Credit

The technique described here is largely inspired by Kevin Walzer’s How to Build Tcl/Tk Application Bundles the Mac Way tutorial. The companion article on Tk Aquafication offers more guidance on integration with Macintosh interface conventions.

The example Info.plist is based on the property list included in the Tcl/Tk Aqua 8.4.16 standalone Wish Shell, which I cannot find listed on any relevant web sites. As with other recent releases, it seems to be available only by direct download from mailing list announcements.

Posted on Saturday, December 8th, 2007.