Archive for January, 2010

Secure synchronization with OS X launchd and unison

January 14th, 2010

After some weeks of using TeamDrive I felt that I have to get another solution for syncing. TeamDrive isn’t bad, but it isn’t good either. It works most of the time, say 95%. But syncing is a matter of 100% trust, so I can’t live with crashes or “oh, I’ll sync in a few minutes, perhaps”.

So I decided to give unison and OS X “Folder Action” a try. But those don’t have a “on file change” event and reading about it many user complain that they aren’t really reliable. So that wouldn’t be better that TeamDrive.

Than launchd came in my head. I remembered the magic with the ssh-keys and thought: Hey, use a launchd FSEvent and combine it with unison – that’s it! Read some doc and finally: All you need is a little plist like this:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>Label</key>
   <string>de.dlite.unison</string>
   <key>OnDemand</key>
   <true/>
   <key>Program</key>
   <string>/Users/joedoe/bin/unison.sh</string>
   <key>WatchPaths</key>
   <array>
   <string>/Users/joedoe/Library/Things</string>
   </array>
</dict>
</plist>

Than add it to launchd via


launchctl load ~/Library/LaunchAgents/de.dlite.unison.plist

and here we go: Saving a file, creating a new one or deleting an old one always delivers a fine call of my unison-script which syncs with my own server. 🙂

Font size in WordPress Plugin CodeColorer

January 5th, 2010

Today I replaced SyntaxHighlighter Evolved simply because he doesn’t support AppleScript. After some tests CodeColorer was the one to take with one problem: The font was really big. After some minutes of searching I replaced the font size given in wp-content/plugins/codecolorer/codecolorer.css from

5
.codecolorer, .codecolorer *, .codecolorer-container, .codecolorer-container * { font: 13px/1.4em Monaco, Lucida Console, monospace }

to

5
.codecolorer, .codecolorer *, .codecolorer-container, .codecolorer-container * { font: 10px Monaco, Lucida Console, monospace }

Creating To Dos from Redmine in Things

January 5th, 2010

I just have had to create a dozen of To Dos in Things based on Redmine Issues. Being lazy I thougth I could spend an hour better in coding than in typing new To Dos, so here it is:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# v2010010402

tell application "Firefox"
        # set myFirefox to properties of front window as list
        # set theTitle to «class pTit» of front window as text
        set theTitle to name of front window
        # Calling display ... within tell application "Firefox" leads to error
        # -1728 every time you call the script again till firefox is really
        # closed, so save the vars and end tell
end tell

if (length of theTitle < 2) then
        display alert "Could not get the title (empty)"
else
        # save previous delimiters
        set tid to AppleScript's text item delimiters
        set AppleScript's text item delimiters to "#"
        set theSubstring to (text item 2 of theTitle) as text
        set AppleScript's text item delimiters to " - Issue Tracker xyz"
        set theName to "#" & (text item 1 of theSubstring) as text
        # restore delimiters
        set AppleScript's text item delimiters to tid

        tell application "Things"
                set newToDo to make new to do with properties {name:theName}
        end tell

        tell application "GrowlHelperApp"
                set the allNotificationsList to {"Task Created"}
                set the enabledNotificationsList to {"Task Created"}
                register as application ¬
                        "Create Task from Multiple Mail (Growl Enabled)" all notifications allNotificationsList ¬
                        default notifications enabledNotificationsList ¬
                        icon of application "Things"
                notify with name ¬
                        "Task Created" title ¬
                        "Task created in Things" description ¬
                        theName application name "Create Task from Multiple Mail (Growl Enabled)"
        end tell
end if