make-believe.org

Synchronising notes with the iPhone

In the last post, I wrote somewhat at length about my new note-taking system. I mentioned something about the possibility of synchronising these notes with the Notes application on an iPhone or iPod Touch.

Here's a script that does that. sync_notes

For it to work, you'll need to meet a few prerequisites:

  • A bash shell on your local machine, and the bash_notes system described in my previous post.
  • An iPhone or iPod Touch, jailbroken, with the Notes app. Install 'Erica's Ported Utilities' via Installer.app to get sqlite3, which is required.
  • Public key access to the iPhod's root account from your local machine. Here's some good instructions.
  • Ruby 1.8.5 or so, and a couple of generally very useful ruby gems:
    gem install net-ssh net-sftp -y
    

As usual with this sort of thing, download the file to a sensible location, make sure it's in your path (by placing it in /usr/local/bin, perhaps), and chmod it to 775.

Then run it, passing in your iPhod's IP address. For example:

sync_notes 192.168.1.15

Hint: I've added my iPhod's IP to my /etc/hosts, which means I can do:

sync_notes zaphod

If a note title isn't found on one machine or the other, the note is added. If two notes of the same title have different file modification dates, the older one will be overwritten with the newer one. I decided not to sync deletions, so you'll need to delete a note in both locations if you really want to scrub it from existence. This just seemed prudent.

The sync_notes script is released under the WTFPL. I presume you're not harbouring delusions about your rights, but for the record: I take no responsibility for any files you may clobber using this script. Or for anything else. Making a backup first would be very logical. But it seems to work just fine for me.

Joseph | 20 Jan 2008 | 0 comments

Bashing out notes

There are several pieces of software I yearn for, and occasionally go on wild goose chases across the Interwebs looking for. A note-taking application that fits my brain is one. My criteria aren't exactly demanding; in fact, they boil down to two needs and two desires.

Need 1: It must appear and disappear immediately.

I don't have the screen real estate for little knick-knacks like side-docks or drop windows, et cetera, and I don't have the patience to go hunting them when I need them. Nor do I have the patience for a complex GUI. I either want to take a note, or read a note, and I want to do it while the slippery little gremlin of inspiration is still trapped in the fragile jaws of my brain.

Need 2: Powerful search.

I'm not going to go tagging or coloring my notes. I'm not going to drop them into a neat folder hierarchy. I mean I'd love to, but I know from experience that it's just not going to happen. So let me have a big stinking haystack of notes, and use search to find my needles.

Great search lets me use the application as a scratchpad, dumping ideas and discoveries down and getting back to work. I know I'll find them later.

Desire 1: Let me repurpose my data.

I take a lot of notes, and over the years my jottings accidentally became a treasure trove (another man's trash, etc). So I don't want them in an opaque or proprietary database. I want to be able to move them around between various machines, archive them from the command-line, sync them with my iPhod, write a script to build a wiki out of them, whatever.

Desire 2: It should work the way my text editor works.

I'm switching between my text editor and various terminals 12 hours a day. My text editor is vim, which works rather differently to most GUI-based text entry widgets. I'd like to be able to enter and edit my notes like I do my code.

A bashful solution

On Ubuntu, Tomboy satisfied my two needs. It was simple and delightful. When I moved to Mac OS X, I searched high and low for a replacement, and eventually found the charmingly quirky Notational Velocity. It also satisfied my two needs, sort of. I had it bound to F4 in Quicksilver, so it was easy to invoke, and I could just Cmd-Q to dismiss it. But startup became very sluggish after I'd accumulated several hundred notes, and inevitably my patience ran out.

So this time, I researched just enough bash to be dangerous, and wrote a short script to do what I needed and what I desired. Here it is in full:

note() {
  if [ -n "$*" ]; then
    vim "$HOME/.notes/$*.note"
  else
    printf "Name of note is a required argument.\n"
  fi
}

findnote() {
  ack -ia $1 ~/.notes
}

copynote() {
  cat "$HOME/.notes/$*.note" | pbcopy
}

alias note:='note'
alias notes='vim $HOME/.notes'

_notes() {
  local cur names IFS

  cur="${COMP_WORDS[COMP_CWORD]}"
  names=`ls $HOME/.notes | sed 's/.note$//g'`
  IFS=$'\t\n'

  COMPREPLY=( $(compgen -W "${names}" -- ${cur}) )
  return 0
}
complete -o nospace -F _notes note
complete -o nospace -F _notes note:

Put that in a file (mine is in ~/scripts/bash_notes) and source it (ie source ~/scripts/bash_notes). Then mkdir ~/.notes.

That's it. Now you've got a few tools at your command-line disposal:

note Guitar tabs

Will create or open ~/.notes/Guitar tabs.note in vim. It's aliased to 'note:' too, so you can use note: Guitar tabs if you prefer.

notes

Opens your notes directory in vim, allowing you to browse, rename, delete at will.

findnote thurston

Shows excerpts from every note in which the string 'thurston' is found. This is just a simple wrapper around ack, the wonderful grep-alike. You'll need to have that in your path somewhere (/usr/local/bin being the logical place in Mac OS X).

copynote Guitar tabs

Copies the contents of the 'Guitar tabs' note to your clipboard on Mac OS X.

But the exciting bit is the custom tab-completion. Type note and hit Tab to list all your notes. Type note Gui and hit Tab to complete the "Guitar tabs" title at the command line. Fast!

If you're not yet won over to the way of vim, you can use this script with TextMate too — just replace all the references to vim with mate.

Try Visor if you want to keep your notes a keypress away. Remember to source the bash_notes script in your .profile so it's available in all your Terminal sessions. And let me know if it fits your brain too.

Joseph | 8 Jan 2008 | 5 comments

Reds and Blues

It's not unreasonable to say I take more than a passing interest in the popular manifestations of democracy. That is, the official soundings of public opinion. You know, elections and all that. I'm neither a political scientist nor a statistician, but I do very much like numbers when they cloak such passion within the regimental columns of a spreadsheet.

In the United States, they are about to commence their eleven month odyssey of political quantification, culminating in the promotion of someone to a position that has become increasingly irrelevant to the rest of us. Still, they take it seriously, and so do I.

The wee mid-western state of Iowa enjoys its quadrennial moment in the sun -- buried though it is in snowfall -- this Friday morning our time, when it convenes its cute little custom of party caucuses. We are spoilt enough to have both Democratic and Republican contests this year, and both parties will host their opening gambits in Iowa.

Nationally, opinion polls suggest that Hillary Clinton holds sway over Barack Obama for the Democrats. John Edwards (vice-presidential candidate to John Kerry in 04) is providing some intrigue in outright third place. None of the other Democrats are really viable, and are interesting in as much as when they pull out, and to whom they hand their baton when they do. For the Republicans, Rudy Guiliani (sometimes written as 9ui11ani) has long possessed the mantle of front-runner, but in a development that only the American political dynamic seems capable of throwing up, he suddenly has a right-of-field challenger in Mike Huckabee, a former Arkansas governer and television evangelist with some mildly odious ideas. Mitt Romney (a Massachusetts Mormon) and John McCain (GWB's also-ran in the 2000 GOP primaries) round out the field of serious potentials for the Republicans.

I feel obliged to make some predictions from this very distant vantage point. Firstly, I know the folly of attempting to divine outcomes at this stage, because both Iowa and New Hampshire are influential, and another 48 states will respond to the changing winds that swirl right through primary season. So I don't have a victor for either race. With that said, I feel foolhardy enough put a few assertions down:

  • Only a few dejected Republicans will even remember Mike Huckabee's name in four months. He will have exited the race in Dean-like ignominy.
  • If Romney takes Iowa, New Hampshire becomes a microcosm of the wider Republican contest between he and McCain. If he doesn't win Iowa, the Republican race splits three ways between he, Guiliani and McCain. Guiliani's strength is on the coasts, but they may not have much say. His role is more likely spoiler than victor, despite his war chest.
  • Watch out for Edwards. January is his little roller-coaster. There's really no way of knowing, but my intuition is that he may well claim Iowa despite running third in most polls there. If so, the fifth of February will be extraordinarily interesting. He has a charm peculiarly resonant with the American palate.

Joseph | 2 Jan 2008 | 12 comments

My hood

Sometimes after midnight in Collingwood, you hear the low pop and tinkle of glass, and after a moment, the rumble of an engine chugging over in the backstreet. Some nocturnal insect starts creaking. The old bloke next door coughs violently, again.

Joseph | 31 Dec 2007 | 0 comments

Where x is some point in the past

Things I've gotten better at since x

  • watering plants
  • programming
  • flying
  • facebook graffiti
  • cooking

Things I've gotten worse at since x

  • cleaning the fishtank
  • driving
  • rational argument
  • poetry

Things that have remained constant

  • goofing around
  • the dishes


once I was the greatest


Joseph | 11 Dec 2007 | 0 comments

Dear Wes Anderson,

I don't really watch movies, but still, I like yours.

To get to the point though, it seems likely that at some stage in your career you will be filming a getaway scene that ends up in an opium den. When that happens, I have a suggestion that I think could save you a few bucks. Instead of commissioning Mark Mothersbaugh to do his thing, just cut to the chase* and use this song from Dr John (the Night Tripper)'s debut album, Gris-Gris:

Only too happy to help. Yours sincerely,

Joseph Pearson

* You see what I did there?

Joseph | 9 Dec 2007 | 2 comments

Why I hated Howard

I started to write an essay about why I hated Howard, the crux of which was that I never hated him, but that I was angered by what my nation had become during his tenure. The things we thought about, and the things we didn't think about. The self-interested but unintrospective malaise that descended upon us.

I was a thousand words deep into the essay when this image came to mind:

cronriot


Howard is not in that photograph, and he didn't send the text messages that lead to a mass mobilisation of xenophobia on our most famous shore. We should be realistic about his agency in it. He swung no bottle, mouthed no abuse. But for several years he acted, or avoided opportunities to act, in a way that created the essential preconditions for that protest. And he failed to condemn it the way a leader of people should.

I wrote the somewhat florid Patriot Act in response to that event. The domain falls due in a few weeks, two years since it happened. No-one has signed up for over a year. For a moment I wondered whether it was really still relevant. But of course it is, to me anyway, as a sad artefact of Howard's Australia, and a reminder to be vigilant with all his successors. I don't think we're out of the woods yet.

Joseph | 26 Nov 2007 | 0 comments

Q2: What's next?

The well-publicised aspect of the Australian federal election -- the change of government -- was not as emphatic as some had expected, but was certainly emphatic enough. There's another, more practical matter remaining to be determined though. That is the changing mechanics of the house of review, whose imbalance at the last election opened the portal for Work Choices, which like an ill-summoned demon consumed its master.

It seems likely that the Senate dominoes will fall this way: 37 L-NP, 32 ALP, 5 Greens, 1 FF, 1 Independent. It was the wrong half of the cycle for anything much more dramatic to occur. This means a couple of things: the outright Coalition majority is gone, but they retain the ability to block legislation with a single supporting vote from Family First or the independent Nick Xenophon -- both of whom broadly fall in their half of the political continuum.

But they'd want to be very careful. If they overuse this remnant power in the Senate, they risk appearing to reject the ALP's lower house mandate to govern. Barnaby Joyce remarked last week that a double dissolution election would likely be disastrous for the Coalition, and he's right, particularly if it occurred in the next 2 years. The only upside would be that (as we've just seen) outright control of both houses is a double-edged sword for any Government over the course of the subsequent election cycle, just because of the giddyness of total control and the Australian public's habit of saying "Oops". Still, that would be a very strange strategy for the Coalition to pursue.

In any event, Rudd is unlikely to try it. He'll play a bit of realpolitick in the Senate, make much of any obstreperous behaviour from the Opposition, and go to the people in 1100 days asking for just a little bit more.

It does raise the spectre of the ALP coddling right wing indies in the Senate on a few issues, which might be stomach-turning for you. But on the whole, as Australian electors say over and over, this is a pretty good scenario for the house of review. It means that policies must be argued for and explained in the Parliament itself, rather than in the party room as has been the case for the last three years.

It means we have public debates, rather than just imagining political deals behind the scenes. We probably won't like the outcomes all that often, but ultimately this is the real change, and the thing to savour about what happened yesterday: once again we will talk openly and open-mindedly about the problems of the nation. All this zealotry, born of frustration, should begin to diminish.

Joseph | 25 Nov 2007 | 0 comments

Q1: Leader of the rump?

The question I've been asking everyone all week is "Who will lead the Coalition rump?" Even if Howard had retained Bennelong, he was never going to accept the Opposition leadership, so the expected baton was passed without fanfare to Costello in his concession speech.

And when I say "baton", I mean "poisoned chalice". Those Liberal frontbenchers who were in genuine contention for the Prime Ministerial mantle know that to take up cudgels as the representative of the losing team is political foolhardiness in the extreme. It would run much like it did with Downer supplanting Hewson, Crean supplanting Beazley, Beazley supplanting Latham, et cetera.

Turnbull is too smart to ever go near it. Costello looked like he had inadvertently put his foot in it, but with a clack-clack of his red shoes he's found a way to scurry to the backbenches of the Opposition, ostensibly to retire from politics at the end of this term. (He intends no such thing. He intends for the new Opposition Leader to fuck up royally, and then he will force a spill six months out -- in the name of unifying the party and returning as a saviour. Well, in a sense it worked for Keating. But Keating did not have a Turnbull.)

Downer has already graciously (and bizarrely) refused the Opposition leadership, but not even the Coalition would flirt with that possibility again anyway. Abbott? He's no longer a man for these times, so he might not even be offered it, particularly after his campaign slapstickery.

Julie Bishop would be an interesting call, but not one I think the Coalition is ready to make. All week my very long odds investment has been on Nelson, whose utter blandness and hilariously misguided ambition makes him Costello's (or Turnbull's) perfect foil -- he would be offered the fall guy role, and knowing that it's his only chance to leapfrog into actual contention, he would take it. Would he damn his party by doing so? Probably, in as much as they're not already damned. Watch for Pyne and (much later) Alex Hawke in the wings.

Or is there another scenario I've missed? And can you forgive me for relishing this?

Joseph | 25 Nov 2007 | 6 comments

I think this means we won

Image030

Or more pertinently, didn't lose. To the extent that it can be decoded at all. Ah, what a night. The headline that landed on my doorstep this morning says "Howard humiliated", and I say mission accomplished.

Joseph | 25 Nov 2007 | 1 comment

stuff & nonsense

  • Topographic viewTopographic view
     shows elements on a webpage according to how deeply nested they are. It's a bookmarklet for web development.
  • The qualifierThe qualifier
     renders controversial statements on this page harmless. Reinstate the slings and barbs by refreshing. Also a bookmarklet.

  • Jjmap
    American Diary

    Two weeks with the apple and the lone star (illustrated).

all posts, ordered by month in reverse-chronological order:

In Words

In Other Words