Reading List

This is a list of books and articles that I've found useful and interesting in terms of personal philosophy and becoming a better person.

William Irvine: A Guide to the Good Life

This is a modern, well paced introduction to Stoicism. I think Irvine overthinks things sometimes, but it's as good a starting place as any.

Epictetus: Discourses incl The Enchiridion

This is a link to the George Long translation, which is the one I like the most. It can be a challenging read at times, as much for the concepts as phrasing. It's a very concise and hardline approach to Stoicism, and I love it.

Seneca: Letters from a Stoic

Letters from a Stoic is interesting both for the concepts and the voyeristic look at the private conversations of one of the most influential Stoic thinkers. Because these are private letters, at times they meander along and get side tracked, but there is some pure gold here.

Marcus Aurelius: Meditations - A New Translation

For a long time I had trouble getting into Meditations, despite people rating it highly. It was the first ancient Stoic text I tried, and I put it down fairly quickly and moved to the much more enjoyable Enchiridion. Then I tried the Gregory Hays translation, and everything changed.

Marcus, obviously heavily influenced by Epictetus, is an interesting study in the workings of a practicing Stoic: someone writing to himself, to keep himself on track. At times he (with Hays' assistance) manages to sum up some of Epictetus' teachings in an even more poetic way.

Much more so than with Epictetus, you can see Marcus failing, castigating himself, battling his fears. Even if you're not interested in Stoicism, it's a valuable read.

Russ Roberts How Adam Smith Can Change Your Life

I'm about 20% into Adam Smith's Theory of Moral Sentiments. It's an intriguing book, but it's not an easy read. This distillation by Russ Roberts is very well done, and immensely readable.

Smith was a fan of the Stoics, particularly Epictetus, so a lot of his ideas align nicely. He builds upon the Stoic base in an interesting way: whereas the Stoics are more concerned about mastering our desires, Smith looks as ways that they are harnessed, for our own benefit and that of society.

I still plan on reading the original text, but I'm grateful that Russ took the time to do so much of the heavy lifting here.

How I Take Notes

The older I get, the more notes I take. Historically I've been a terrible at it.

I have exercise books from the past 10 years at work, filled with useless scribble - the working notes for algorithms and data structures, doodles and the occasional meeting note. Undated, uncategorised and completely inaccessible. I've tried to start a diary every couple of years since G.H.W Bush invaded Kuwait. Until late last year, none of them lasted more than a month.

The keys to me taking more (and better) notes have been speed, access and simplicity. Regardless of my intentions, I don't take notes unless it's quick, I can do it anywhere, and I don't have to think about the mechanism.

My first push in the right direction came from reading Mind Performance Hacks. The main "hack" that left an impression on me was having a system to catch ideas as they occur, instead of trying to remember to write them down later. They had some detailed system about carrying (physical!) cards with columns on them, but that was never going to fly. Instead, I came up with my own system based on text files, which I can easily modify on my phone, tablet or computer (one of which is almost always handy).

I created a folder called "catch" and added one file per category - for example, "blog". Whenever I had an idea for a blog post, I'd add it in. I decided to take notes on some books I was reading, so I added another folder called "books" and created a document for each book.

I use btsync to sync the files across my devices, but you could easily use Dropbox, Google Drive etc.

This worked well enough, but I found it a little slow and cumbersome. I wanted to be able to get the idea out of my head quickly, without having to find the right file. Enter the bash script!

function record(){
    output=*"$(date +%F)$(date +%r)* "$3" \n\n"

    #echo "Writing \"$3\" to $target"
    if [ -z "$2" ]; then
        ls "$1"    
    elif [ -z "$3" ]; then 
            vim "$target"
            printf "$output" >> "$target"

alias catch="record ~/notes/catch"
alias book="record ~/notes/books"

At work I usually have a cygwin terminal open, and at home I spend most of my time in a terminal. My record() function (and the aliases that point to it) let me really quickly take notes. For example, if I type

$ catch blog "How I take notes"

a new line, prepended with the date, is added to my blog file:

*2014-10-29 09:11:29 PM* How I take notes 

If I type catch blog, my blog file opens in my text editor. If I type catch, I get a list of my catch files/categories.

Lately, I've started taking notes about what I do at work:

$ wl "Adding <feature> to <program>:
> - remember the <blah> has to be hooked up to the <hoosit>"

This feels like it will be very beneficial going forward, particularly for those rare jobs whose precise details I always forget.

For well-categorized ideas, I can search within a document to find something. If I can't remember where exactly I put something, I can use the usual file system tools to help me. grep happily tells the files that match the phrase I'm looking for:

$ grep -rin "notes" .
./*2014-10-2909:11:29 PM* How I take notes 

I've been taking notes for about a year, and I'm starting to see the benefits. Each time an idea resurfaces, I flesh out the notes a little more, so the concept progresses.

clearInterval() workaround for some Android browsers

Speedy is written with Cordova, using HTML and Javascript to create an installable (and sellable) Andorid app. Cordova uses the Android browser to render the appliation, which in general works quite well. However, I ran into a problem on some devices with window.clearTimeout(), and it took me a while to work around it.

At its core, Speedy is just a function that runs every so often to display some text. The idiomatic way to do this in Javascript is with setInterval(). In the simplest case, you'd use it like this:

var intervalId = window.setInterval(function(){console.log("Hi")}, 1000);

When you want to cancel the interval, you'd use cancelInterval():


This all works fine, even on the 'problem' browsers. In fact, moving back to this simpler usage ended up being the solution to my problem.

Because I'm using Angular, I decided to make a somewhat more idiomatic wrapper for setInterval():

function $interval(fn, ms){
    var t = window.setInterval(function(){$scope.$apply(fn)}, ms);
    return function(){ window.clearInterval(t)};


var stop = $interval(function(){console.log('Hi')}, 1000);



To me this nicely encapsulates the set/clearInterval() calls. It works in desktop browsers, on my Nexus 4, and even on my ancient Huawei 8150 running Android 2.3. It failed on my Samsung Galaxy S running 4.2.2, and I had reports of it failing on an HTC One S running 4.1.1 and on an HP tablet.

I haven't precisely tracked down the issue, but it seems that the function returned by $interval is failing to properly close over t. In any case, the solution was to return the interval id, rathern than a function, and pass it to window.cancelInterval() when required.

On a related note, as part of my testing I found that Angular's $timeout() (which wraps window.setTimeout()) also does not work on some Android browsers. Even worse than with setInterval(), $timeout() never starts at all. I'm not sure if this is an issue with closures in general (although I use them elsewhere in the codebase), or if somehow interval/timeout are particularly sensitive to being wrapped.