Tag: code

Sublime Text basic plugins

The hard drive on my laptop recently ate itself, and while I was able to recover most of my important data through the magic of regular backup, I did lose a few files. Among them: my directory of custom SublimeText plugins. It’d been a good while since I had to make a Sublime Text plugin, so this was a good refresher course.

While I’ve built a few plugins over the course of time, the two main ones I miss were:

Dugong - kind of ugly mindmapping in javascript

For a (currently undisclosed) project, I decided that it would be a great idea to have some sort of markdown-to-mindmap converter. This is actually a bit of a misnomer - what I wanted was something that would take plaintext, in a format as simple and memorable as markdown, and turn it into a graphical mind map, probably in svg. I’ve been hacking greasemonkey scripts at work, and with that comes at least a base level of competence with javascript: the perfect language for converting a div to an svg, on the fly, in your browser.

The result is dugong. It’s a pretty simple library - no-frills, nice and small, with no dependencies on external libraries. Just download, plug into your webpage, and watch it convert lists to mind maps in front of your very eyes.

Advanced Gnuplot: sizing particles

I’ve previously discussed Gnuplot on this blog, discussing why it’s excellent and demonstrating how to make a semi-decent simple graph using the package. You can learn a lot from Gnuplot by playing with sample graphs and reading the documentation, but I thought I could show off some of the more complex graphs I’ve made over the past year or so, and how I went about crafting them.

The setup

In this post I’ll cover a somewhat complex particle sizing graph I ended up producing for a recent paper1. In the paper we were determining the size of a batch of elliptical nanoparticles, which we could image using scanning electron microscopy (SEM). SEM produces an image of the material at high resolution, in greyscale:

A cocoa bridge to OmniFocus

Over the past week or so I’ve been working on unifying two projects: kanban-fetch and of-store. They have their similarites. both are command-line applications that interact with OmniFocus via ScriptingBridge and do something with the data. Both of them started off as small personal projects, closer to hacks than actual scripts, and have developed considerably due to the fact that since I wrote that article I’ve had people emailing me and asking all sorts of questions, which have forced me to add radical features like actual documentation and the like.

Both scripts kept on doing the same things: working out whether OmniFocus was running, working out which version of OF was running based on its application ID, working out if projects and tasks were completed, saving them to a SQLite database…the natural progression is to take all this common code and turn it into a reference library.

Oh look some writing

This morning Omni Group put out their newest edition of their desktop productivity/task-tracking app OmniFocus to great acclaim everywhere on the internet (or at least everywhere on the internet that cares about productivity applications for OS X, a small but very enthusiastic segment). To coincide with the launch they’ve also started a series called Inside Omnifocus, which explores how a number of people from different walks of life use OmniFocus in different ways to generally be better people. The very nice people at Omni Group decided to extend an invitation to me to write for the site, which I happily accepted.

The site went live this morning (my time), and resulted in the above uptick in visitor numbers. So, uh, hello new visitors!

One foot in front of the other

I’ve been slowly - slowly - plodding away at coding MailSend, my work-in-progress, learn-as-you-go email-sending application. With thesis-writing out of the way I’ve got a bit more time to devote to this project, and while every step is slow as treacle, I am getting somewhere.

Today marks the culmination of several days’ painstaking work getting NSOutlineView to play nice, which finally ended in an IMAP “sent mail” selector that I feel I can be proud of:

Customising NSAlert: accessory views

For a well-documented feature, NSAlert’s accessoryView feature takes a little bit of fiddling to implement. NSAlert is behind the standard pop-up modal alert window that’s familiar to everyone, often popping into the foreground and grabbing your attention, refusing to go away until you acknowledge its existence:

NSAlert boxes can, by default, display any number of buttons (c.f. the classic “Save/Delete/Cancel” triumvirate), but advanced features require a little more jiggery-pokery. This mainly comes in the form of its accessoryView property, which allows you to add an NSView to the alert proper. At first you might be tempted to programatically create an NSView, adding the required elements in init methods and the like, but it turns out it’s actually a bit easier to use nib files to hold all of that. This is how to do so.

Migrating MacRuby scripts to Objective-C

First signs of decay

After upgrading to Mavericks, I found that a few of my MacRuby scripts had stopped working. Apparently it’s due to some part of the optparse package, which breaks upon upgrading, and I’m not the only one getting the error. The issue has been open for about a month now, and there doesn’t appear to be any response from the devs.

This isn’t to say that the project’s defunct, but this has happened before to promising ruby-cocoa bridging tools. It’s symptomatic (I believe) of a more general trend, in which people build a cool bridge, but Apple has no responsibility to keep it working. When Apple upgrades various portions of the OS, these bridges stop working, which then mean that the devs have to scramble to fix their own products.

Desktop background on OS X 10.9 Mavericks

I upgraded to OS X 10.9 a week or so ago, along with everyone else in the Mac nerd world. And like everyone else in the Mac nerd world, something of mine broke. In my case, it was a small script that would alter com.apple.desktop.plist to daily change my desktop.

Essentially, you have no way in OS X of syncing desktop backgrounds between spaces. You can set desktops so that all your spaces have the same desktop, but if you want to cycle them randomly, the first time the OS changes them, they’ll be all different once again. The problem is not a huge one, but it fell into a particular category of being big enough to annoy me, and small enough that I could write a script to fix it.

  • 1
  • 2
  • ...
  • 4