os x

...now browsing by tag

 
 

Error running launchctl remotely as non-root

Saturday, October 8th, 2011

Today, I’m attempting to install Jenkins under Homebrew on my home server running OS X. I’m ssh-ing into that machine, and got the following error while attempting to launch the program after installation:

Bug: launchctl.c:2325 (23930):13: (dbfd = open(g_job_overrides_db_path, O_RDONLY | O_EXLOCK | O_CREAT, S_IRUSR | S_IWUSR)) != -1

launch_msg(): Socket is not connected

A bit of Googling turned up this page from the Homebrew wiki which mentioned the error message but suggested that iTerm was the cause. I’m not using iTerm, but on a hunch, I tried using Screen Sharing to run Terminal.app directly on the remote machine. Success!

Bash Completion for Ant on OS X with Homebrew

Wednesday, March 23rd, 2011

Now that I’ve set this up, I can’t believe that it’s taken me so long to do it. A bit of googling turned up this blog post, which contained a link to this post in the comments. Since I’m using Homebrew instead of MacPorts, I had to tweak the instructions a bit:

  • Install bash_completion:

    brew install bash_completion

  • Next, add the following to the bottom of your .bashrc or .profile:

    if [ -f `brew --prefix`/etc/bash_completion ]; then
    . `brew --prefix`/etc/bash_completion
    fi
    complete -C /usr/share/ant/bin/complete-ant-cmd.pl ant

Hurray for TextEdit

Tuesday, March 10th, 2009

I have a Rich Text Format file that contains data organized in an outline style.  I need to parse the file and extract the text it contains, but the formatting information is just as important as the text–I need it in order to build data structures that reflect the relationships between the lines of text in the outline.  For example, if a line is indented by one tab stop, that means it’s a child of the most recent line that has no indentation.

Given that RTF has been around forever, I figured that finding a good library to parse it would be pretty easy.  Sadly, that’s not the case.  I could only find two candidates:

RTF::Parser

and

iText RTF

RTF::Parser was disqualified because it’s a Perl library and I haven’t written any Perl in years.  And I’ve only just gotten over the experience.  iText is awesome.  I’ve used it to generate PDFs before, and it works really well.  Unfortunately, there’s no documentation for the RTF code.  After playing around with it for about an hour, I had figured out how to pull the text out of the document, but not the formatting.  Frustration ensued.

Fortunately, a little bird suggested that perhaps I could use a program that can read RTFs and save in a format that’s easier to parse.  Also fortunately, the first such program I tried was OS X’s  TextEdit.  Not only can TextEdit read in RTF and spit out HTML, the HTML it produces is squeaky-clean and uses a tiny block of CSS to format the text rather than duplicating it over and over again throughout the entire document.  Why do I care?  Well, now that the formatting information isn’t duplicated everywhere, the resulting HTML file is about 25% of the size of the RTF file.  Another handy benefit of using CSS to do the styling is that the CSS classes used to apply the formatting effectively group the lines in the file by indentation level.  So every line that’s indented by one tab stop has a CSS class of (for example) “p7″, and every line indented by two tab stops has a class of “p9″.  That’s much less convoluted than trying to understand how RTF’s formatting works.

Apple sometimes describes its mission as attempting to “surprise and delight” their customers.  I am surprised.  I am delighted.  If only because this means I won’t have to write any Perl.