Tag Archives: osx

OPML to Markdown

I’ve started using mind maps for various things and wanted to use them for taking minutes in meetings. The issue is that we usually record minutes in a markdown text format so I needed to be able to convert from a mind map to markdown. A quick Google gave me an example Gist in python, but it didn’t work on my Mac. On top of that, once I’d fixed those issues, it wasn’t really outputting things in markdown, just plain text.

I fixed up the code so it now goes from OMPL to Markdown using the root node as the document title, and presents the rest of the nodes as a nested list.

For a given example map:


We get the output:

# Example Map

* 1st Level Child
    * 2nd Level Sibling
    * Another 2nd Level Sibling
* Another 1st Level Child
    * Sibling on Level 2
        * Sibling on Level 3

I’ve actually gone one further locally by setting #!/usr/local/bin/python at the top, moving the script to /usr/local/bin/opml2md, setting chmod 755 and putting some basic argument checking in place. I’ll leave those changes as an exercise for the reader as some bits are specific to my OSX install.

Improving Google Drive on the Mac

I’ve been a Dropbox user for ages now, although I’ve never really been hugely active in getting referrals or other activities to increase my free space. Currently my account lets me store 3.8Gb of data. Until recently this has been fine, however, I also now have a few shared folders which are beginning to chew up some space. To mitigate this problem I’ve hived off just under a Gig of data to Google Drive, which I’ve recently installed. While Google Drive doesn’t really give me the in-app integration of Dropbox, it is quite a useful place to dump lesser used files and backups.

My problem is that the badges used by Google Drive are hideous and fugly, and that doesn’t appeal to my sense of good style. If you compare the Google Drive folder on the left in the two images below to the Dropbox folder on the right you’ll see what I mean.

dropbox googledrive

Googling to see if there was a way to solve this issue was, initially, fruitless, however, I came across something telling me where the Dropbox badges were within the application. They’re
icns files which got me thinking; did Google Drive use something similar? Turns out it does. The solution was simple, copy the Dropbox icns files over the Google Drive ones, reboot and voila.

As you can see from the two examples below, it’s not quite perfect. Again, Dropbox is on the left and Google Drive is on the right, and the Google Drive badge is offset lower and to the right. Still, it’s a huge improvement.


The commands I used were simple, and include a step to backup the old Google Drive icns files. Obviously, we’re messing with the internals of an application here so Caveat Emptor and all that, and if you end up breaking it you get to keep both halves – please don’t come running to me.

cd /Applications/Google\ Drive.app/Contents/Resources/FinderExt.bundle/Contents/Resources

cp Blacklisted.icns Blacklisted.icns.bak
cp Shared.icns Shared.icns.bak
cp Synced.icns Synced.icns.bak
cp Syncing.icns Syncing.icns.bak

cp /Applications/Dropbox.app/Contents/Resources/emblem-dropbox-unsyncable.icns Blacklisted.icns
cp /Applications/Dropbox.app/Contents/Resources/emblem-dropbox-uptodate.icns Shared.icns
cp /Applications/Dropbox.app/Contents/Resources/emblem-dropbox-uptodate.icns Synced.icns
cp /Applications/Dropbox.app/Contents/Resources/emblem-dropbox-syncing.icns Syncing.icns

OSX Screen Saver Bug

Screen Saver PreferencesJust had a really weird bug with Screen Savers in OSX after upgrading to 10.9.2. I use hot corners to enable the screen saver (and thus lock the screen), but this stopped working after the update. Quick Google suggested it wasn’t actually the hot corners not working, but the screen saver. Further Googling uncovered it was something weird to do with the “Start after” setting. I had this set to “Never“. Changing this to “1 Minute” caused my hot corners to start working again. Changing it back to “Never” and everything was still fine. Most odd.

Eclipse, OSX and JDK 1.7

Despite being a massive Mac fanboi I am the first to admit that as soon as you start going a little off piste with OSX you run into problems that require technical knowledge to fix. Java development on the Mac falls into the category of off piste and it has always been more than a little fun getting things set up.

Now that Oracle are providing the JDK it seems that things no longer live quite where they do which left me scratching my head when trying to get Eclipse working with JDK 1.7.

Installing JDK 1.7 is easy, go to the Oracle download page, grab the 64bit OSX DMG, open, run, job done.

$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

Now to tell Eclipse where the JDK is:

$ ls -l `which java`
lrwxr-xr-x  1 root  wheel  74 24 Oct 15:37 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

Great… except Eclipse doesn’t recognise /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/ or /System/Library/Frameworks/JavaVM.framework/Versions/Current/ as a valid JDK location.

A bit of Googling I discovered the magic java_home command.

$ /usr/libexec/java_home -v 1.7

Giving that directory to Eclipse made it happy and I’m now able to use an up to date version of Java for my code.

Issues with GlassFish on OSX

I’ve been trying to get GlassFish 4 to install on my laptop on and off for the past two days now. Needless to say, it’s not being going well. Initially I tried the native install (export DISPLAY=localhost:0.0 btw 🙂 ), it hung trying to configure the domain. Trying to configure a new domain from the command line yielded:

./asadmin create-domain --adminport 4848 --instanceport 8000 domain2
You do not have permission to use port 4848 for domain2. Try a different port number or login to a more privileged account.

Nothing on port 4848 and even running the command as sudo root didn’t work. Next up, the zip install. The comes with a preconfigured domain and a new error trying to start it:

./asadmin start-domain domain1
There is a process already using the admin port of 4848 -- it probably is another instance of a GlassFish Server

Resorting to Google and I finally worked out that my hostname wasn’t in /etc/hosts. Being on the work network I’ve been assigned a hostname by the DHCP server rather than the sulaco.local it usually is. A quick google for setting the hostname on a Mac got me [this][http://blog.psyrendust.com/2008/05/23/change-the-hostname-in-mac-os-x-osx/] and I was able to run

sudo scutil --set HostName sulaco.local
./asadmin start-domain domain1

Lo and behold, GlassFish has started.

Headless Java Process

Someone1 has updated things on OSX so that when a Java process runs it spawns a little coffee cup icon in the task bar which then steals focus. I’m sure whoever did this thought it would be a wonderful idea which no doubt has some benefits if you think really really hard. If, on the other hand, you’re a dev with a build process that spawns JUnit as a forked process many times during the course of the build, then this new behaviour can be considered a tad on the annoying side. Thankfully a quick moan at Google yielded the following magic:


I’ve added this little gem into our build scripts by using:

<junit printsummary="on" haltonfailure="true" fork="yes">
    <jvmarg value="-Djava.awt.headless=true" />
    :    :    :

And I even hear rumour that you can set export JAVA_TOOL_OPTIONS='-Djava.awt.headless=true', although that’s uncorroborated hearsay at the moment – depends how many scripts I need to update as to whether I go for the global solution.

1Oracle, I’m looking at you… and Apple, don’t think I don’t hold you at least partly responsible.