Isaac Su — exercising my powers of observation

Purging unused Mastodon accounts

Sun, 20th Oct 2019

I run my own Mastodon instance at Over time, it accumulates avatar and header files of accounts that I do not care about in the live/public/system/accounts directory, and it gets quite large.

Here's a Rails console script that I use to purge them every now and again. There's one method unused_accounts that tries to assemble a whitelist of account_ids that I've ever interacted with and returns a list of accounts that are not them.

1. Start by booting up Rails console for mastodon

cd ~/live
RAILS_ENV=production bundle exec rails console

2. Define the unused_accounts method

Paste this code block into Rails console.

def unused_accounts
  favourites = Favourite.all
      .map{ |f| f.account_id }
  favourite_statuses = Favourite.all
      .map{ |f| [f.status.account_id, f.status.in_reply_to_account_id] }
  follows = Follow.all
      .map{ |f| [f.account_id, f.target_account_id] }
  notifications = Notification.all
      .map{ |n| [n.account_id, n.from_account_id] }
  poll_votes = PollVote.all
      .map{ |p| p.poll.account_id }

  activities = (favourites + favourite_statuses + follows + notifications + poll_votes)

  replied = Status.where(account_id: activities, reply: true)
      .map{ |s| s.in_reply_to_account_id }

  reblogged = Status.where(account_id: (activities+replied).reject(&:nil?), reply: true)
      .reject{ |s| s.reblog_of_id.nil? }
      .map{ |s| Status.find(s.reblog_of_id).account_id }

  all = (activities + replied + reblogged).reject(&:nil?).uniq

  Account.where.not(id: all)

3. Suspend them

Paste this code block into Rails console.

unused_accounts.each do |account|
  puts "#{account.username} #{account.domain}", destroy: true)

A most recent run freed up 4GB of disk space. bin/tootctl media remove --days=5 helped reclaim another ~3GB on top of that.

Hope someone else finds this useful. I should note that this worked on [Mastodon v2.9.2]( There's no guarantee that it will work in future or past versions.

Please use this toot for questions, comments or expressions of gratitude.


Thu, 19th Sep 2019

colleague: My housemate would throttle me if anything bad happens to our beloved porcelain bowl

me: You mean like reduce the number of times you can use kitchen equipment per time period? 🤓

At the time, my understanding of the word "throttle" involved two concepts. The first is the car pedal that a driver steps on to make a vehicle go faster. The second is what a web service does to prevent a client from overwhelming it with too many requests.

This exchange prompted me to look up the actual meaning of throttle: to choke, suffocate or strangle, which was what my colleague was pleading us to prevent from happening. I'm pretty sure this definition predates its use in automobiles and web requests.

To throttle a web request, I understand. The more severe the throttling, the fewer requests get through. Throttle in the context of the car pedal though is less intuitive because stepping on it allows more fuel into the engine, making the vehicle travel faster.

Turns out the term comes from the throttle valve in a combustion engine. The default state is for the valve to be at its most constricted or "throttled" (just enough for the engine to keep running). Stepping on the accelerator pedal "unthrottles" the valve, allowing more fuel to flow into the engine.

So really, calling the pedal the "accelerator" is accurate, but in terms of "throttle", it should be the "unthrottle" pedal. Also when someone dramatically declares "hit the throttle" with the intention of making their vehicle go faster, what they really mean is "hit the unthrottle" 😂.

Insecurities of an engineer turned team leader

Wed, 28th Aug 2019

Just finished reading Promise Me, Dad. Easy, enjoyable, emotionally-rich read. It was a refreshing departure from Capitalism without Capital which was quite academic and An Elegant Puzzle which was quite task-focused.

The thing that stood out most prominently to me is how much time Joe and staff spend strategising, writing speeches, delivering speeches, setting up meetings and calls and corraling people.

In the last month or so, I've been gradually removing myself from the implementation and deployment of code within the team. Instead, I've been focusing on establishing robust processes, streamlining communication flow and information dissemination, and listening intensely to where each member on the team is at, helping to unstick things that are missed in the macro movement of things.

The contours of such efforts differ dramatically from that of an individual contributor. As an individual contributor, I spend my days cracking the back of engineering problems, coding up the solution, considering tests, stepping through deployment environments and seeing it operational in the hands of customers. There is a cadence to it that is irrefutable. I feel confident, safe, satisfied.

Of late, my son would ask me - how was your day? What did you do at work? My answer has been consistently vague - I talk to people, I have meetings, I sometimes solve puzzles.

Feels less irrefutable.

Reading about the strategising, the speech-ing, the people corraling affirmed me that the activities that fill my workday, albeit at a far smaller scale than that of a VPOTUS, have inherant value that I've still yet to fully embrace.

One day I would like to have mustered up the conviction to explain to my son: people long to accomplish things that are much greater than themselves. In order to achieve that, they need to find ways to work with each other. Everyday, daddy has the opportunity to help people do that at work.

Let's take the conversation to mastodon.

Surface Go is a real computer right?

Wed, 21st Aug 2019

Tooting has gone quite well. I'm running my own instance, learning the ins and outs of mastodon administration. I've managed to stand up elasticsearch for it, and I've now reached semi-pro level live-tooting-while-reading. Check out my toots for An Elegant Puzzle #aep19 and Capitalism without Capital #cwoc19. Riveting stuff.

I must be on a roll.

To take advantage of this self-publishing momentum, I've spent the last two nights trying to revive this ol'blog.

Night one was spent trying to upgrade to the latest version 3.x, because new is supposedly good. Apparently not so good for me because a bunch of the APIs have changed, which caused my heavily customised theme to break. Oh well, worth the try. A simple git checkout <old branch> and we were back.

(I'd been doing all of this via ssh on the live server)

Night two, I figured I'd skip the upgrade and appease myself with a slight polish of the theme. The latency of emacs-ing live on the server was too painful, so I thought my Surface Go is a real computer right? Brought up Ubuntu in Windows 10, installed php7.2-cli and friends, then php -S Just like that, I was off tweaking markup/styles, alt-tab, ctrl-R, repeat.

It's been so long since I've tweaked HTML and CSS, it brought back fond memories of recording vim macros to automate HTML tag transform operations. Ah my youth.

It worked. I'm most proud of the fact that all this was done on a supposedly underpowered Pentium 1.6GHz chip with a paltry 4GB of RAM, both of which get largely chewed up by some Antimalware Service Executable.

I'm going to write more. I'll try. This was actually fun.

It's a little roundabout at the moment, but if you feel an overwhelming urge to respond, you may do so on this toot. You will have my appreciation.

Docker Containers gently

Tue, 24th Apr 2018

The engineering team at Sidekicker recently moved to a fully containerised approach to deploying software. I thought it would be a good idea to write about why we did it, and how it sets us up for the long run.