OS X: The Location for “Folder Action Scripts”

Since it bit me a couple of days ago: The AppleScripts to be used as Folder Actions must be stored in ~/Library/Scripts/Folder Action Scripts or /Library/Scripts/Folder Action Scripts.

The former is the location for Scripts available to the user of the account, the latter for all users of a machine. Don’t get fooled by the fact that you are able to choose any script via the context-menu of a folder if Folder Actions are enabled.

Just in case you need to know. ;)

Logging in FrontBase, quick and dirty

This is a quick tip (and thus something I don’t have to remember as long as I have an Internet-connection and a browser at my disposal ;) ) for all FrontBase-users out there. The following is a rundown of handy commands if you need to log activities on a database.

sudo ln -s /Users/admin/FBLogs /Library/FrontBase/LogFiles(OS X)
Creates a symbolic link to the directory FBLogs (the directory needs to be created first) named LogFiles in your FrontBase-directory. If FrontBase “sees” this directory, all logs will be created and written there instead of the standard-location in Databases. If you are using Linux or Unix, choose a convenient location on your hard-disk.

Now you’re ready to log (and roll), but you have to tell FrontBase first. Fire up sql92, connect to the database in question and use

SET WRITE SQL TRUE GLOBAL;

to convince FrontBase to start logging. To turn logging off, use

SET WRITE SQL FALSE GLOBAL;

The logfile-name is the one with “sql” added, so [name_of_your_database].fb.sql is the file the commands shown above use for logging. Said file will grow to astonishing proportions in a very short time, on a busy database, that is. If you want to use a new file while logging is active, use

SWITCH TO NEW SQL LOG;

The current file will be renamed to [name_of_your_database].fb.sql.YYYYMMDDHHMMSS and a new file named [name_of_your_database].fb.sql will be created and used (keep this in mind when using tail -f).

Again, this is supposed to be a debugging-feature, not something you enable and let run forever. Check out the documentation, there is more to logging in FrontBase; especially the explanation of the contents of your log files.

Hope this helps, if you tend (like me) to forget these commands, bookmark the post. ;)

OS X: Repairing Permissions from the Command-Line

Just a quick tip: Repairing the permissions on an OS X disk can be done from the command-line as well. The only caveat, you have to know the device of the volume. Getting the right device is easy:

diskutil list

The device-node in question is in the column titled IDENTIFIER. The device-path to use is the one with the name of the volume, e.g. if the column reads disk0s2, then the command would be:

diskutil repairPermissions /dev/disk0s2

You should see some kind of progress-bar in ASCII.

One thing to note though: Using the command does not prevent the “meditation” of the program after 20%. I’d be interested what the system is doing while it seems to mull over something when it is supposed to repair the permissions. :mrgreen:

OS X: Getting Image-Dimensions on the Command-Line (sips)

If you need to get the dimensions of an image-file via the command-line, let’s say in a script or an AppleScript, then there is a way to do so easily. Enter the scriptable image processing system or short sips. You didn’t know you got that installed on your OS X system alreay? Me neither.

Assume, that we need to get the dimensions of an image for further handling of said image. The command

sips -g pixelWidth -g pixelHeight [image-file]

returns the values (and a lot more if asked correctly).

Give it a try and take a look at the man-page (man sips) for further information. A really handy tool for all scripters.

MySQL-Endcoding on OS X Server 10.5.X

Just a quick hint for all the commandline-jockeys: The standard-encoding for new MySQL-Databases on OS X Server 10.5.X is not UTF-8 but latin1.

Do not forget to specify the encoding when creating a new database, seriously. I suspect, that this depends on the language the system is installed in. The system that tricked me was using english, naturally. ;) It didn’t help much, that WordPress thought writing to a databases using UTF-8 encoding. Everything worked fine until I dumped the database and restored it on another system.

Alternatively, there is no my.cnf in the standard-locations on a clean OS X Server 10.5.X install, create one and specify the right encoding there. But get in the habit of checking the current default encoding before creating a new database.

Just a quick FYI. ;)

My DocBook-Bundle for TextMate

OK, here it is. The TextMate DocBook-bundle (click the link to download) I’m using for production.

The emphasis is on I’m using. The bundle contains the entities I need for my daily work. Means, it does not contain all entities which can be used writing books and articles in DocBook. There are no templates, since I’m tweaking my DocBook-workflow at the moment.

You can use the bundle to ease the pain regarding spurious >-signs by writing e.g. application or systemitemnext to the </para>-tag and hit the ⇥-key, instead of typing <-⇥ and removing the additional > appearing next to the </para>-tag. There are indexterms, xrefs, ulinks, etc. Check it in the Bundle-Editor in TextMate.

On shortcut probably needs explanation, if you type entity followed by ⇥, a line appears copying the symbolic name used in the document, e.g. ch08 to the end of the same line with the extension .xml added. I tend to (especially late at night) introduce typos in the filenames. :mrgreen: The result is a run-of-the-mill entity-declaration like this:

<!ENTITY ch08 SYSTEM "ch08.xml">

It’s your job to include the entity at the right spot in your master-document.

There is no sanity-check whatsoever, you have to make sure, that the structure is OK. The bundle is not a tool to teach anyone, it’s a tool to speed up my writing. If you are not sure about the “parents” or “children” allowed for a tag, take a look at DocBook: The Definitive Guide.

Templates will be included in one of the next incarnations. I’m thinking about adding the creation of PDFs using fop to the bundle, for the time being, you’ll have to use your own scripts. Watch this space.

I hope you can put the bundle to use. If there is anything you miss, drop me a comment (moderated).

If you have no idea what TextMate is and you are using a Macintosh running OS X to write in DocBook, check out the link, seriously.

10.5.2, at last

Everybody fantasized, hoped, longed, [you get the picture] about it: the Leopard 10.5.2 Update is soon to be found on Macs wide and far.

No problems so far, none I’m aware of, at least. Don’t forget to repair the permissions before and after the install, though. Seriously. And if you happen to have a recent digital camera in your bag, one of those to be precise:

  • Canon EOS 1Ds Mark III
  • Canon Powershot G9
  • Hasselblad CF-22
  • Hasselblad CF-39
  • Leaf Aptus 75s
  • Nikon D3
  • Nikon D300
  • Sony Alpha DSLR-A700

Then messing up the pictures in RAW is at your disposal. :mrgreen:

Just in case you managed to miss the news. ;)

TCP- and UDP-Ports used by Apple Software

Everyone concerned with administering a network containing Apple-machines should bookmark this link:

“Well Known” TCP and UDP ports used by Apple software products

I’ve been told, that the document will be updated on a regular basis.

Date-/Time-Calculations using AppleScript

This short how-to explains how you calculate with time- and date-values in AppleScript. Quite a few people told me, that they are using the do shell script-handler presented in the post How to convert an “epoch”-time to a meaningful date and time. Nothing wrong with that, but if you just want to perform time-calculations inside an AppleScript, then there is an easier way.

If you assign the current time to a variable as in set myDate to current date and you just want to calculate the current date plus 2 days, then there is no need to use epoch-seconds.

  1. set myNewDate to myDate + (2 * days), adds 2 days to the date and time stored in myDate.
  2. set myNewDate to myDate + (4 * hours), adds 4 hours to the current time and date.
  3. set myNewDate to myDate + (30 * minutes), adds 30 minutes to the current time and date.

It is really that simple, AppleScript uses epoch-seconds to perform these calculations, so you don’t have to. ;)

If you need to set the date and time to the beginning of the current day, then use

set myTime to time of myDate

set myNewDate to myDate - myTime

The variable myNewDate now contains the current date and 00:00:00 as time.

Epoch-seconds are great if you want to store a date-value and read it back in later, but as long as you stay inside an AppleScript, there is no need to resort to epoch-values.

Happy Thanksgiving everyone!

If you are reading this on thursday: Before or after turkey (I’m nosy)? ;)