Unescaping strings of stack traces

I often find myself copying strings of Java stack traces which have escaped tabs and newlines (\t\n). Those aren’t fun to read. Here’s a quick Python script I rigged up to grab what’s on the clipboard and format it properly. I call it unescape:

#!/usr/bin/env python3

Grab the string on the clipboard and print it to standard out,
interpreting tabs and newlines appropriately

import subprocess
r = subprocess.run(["/usr/bin/pbpaste"], capture_output=True, encoding="unicode_escape")

Posted in Uncategorized | Leave a comment

Stripping leading timestamp from GitHub Action logs

GitHub Action logs start with timestamps. To strip them with sed:

sed 's/^[0-9T:.-]\{27\}Z //'

Posted in Uncategorized | Leave a comment

Automating Slack status changes on macOS

In these days of everyone working from home, I really liked the approach to setting Slack status that Alex Hidalgo mentioned on Twitter:

I wanted to be able to change status from Alfred. Turns out there’s a handy Applescript bundle by Sam Knight that makes this easy. Here’s how I do it:

tell script "Slack"
	focus workspace "Netflix"
	set status "online" with icon ":wfh-up:"
end tell

I couldn’t get Alfred to invoke this Applescript directly (I imagine it has something to do with Security settings in Catalina), so I saved it to a file (up.scpt), and then invoked it in a workflow as a bash script, where the command was:

osascript ~/dev/slack-automation/up.scpt

My Alfred Slack status workflow looks like this:

Posted in Uncategorized | Leave a comment

Stomping a local git branch with the remote

When somebody rebases their PR, my local copy of that branch gets out of sync:

➜  keel git:(fix-paused-events) git status
On branch fix-paused-events
Your branch and 'luispollo/fix-paused-events' have diverged,
and have 8 and 16 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

I just want my local copy to reflect the remote one.

I created a “stomp” alias that resets my local branch with the upstream:

    stomp = !git reset $(git status -sb | cut -d'.' -f4 | awk '{print 
$1}') --hard

Posted in Uncategorized | Tagged | Leave a comment

J-Bob from the Little Prover

The Little Prover book references a companion proof assistant tool called J-Bob. I had a hard time getting it running using Racket’s Dracula package, here’s how to do it:

  1. Install Racket.
  2. Install the Dracula package for Racket. On macOS, I did:
    cd /Applications/Racket\ v6.10.1/bin
    sudo ./raco pkg install dracula
  3. Download ACL2. I ended up grabbing a pre-built binary gzipped tarball which was for 7.1, but the latest is 7.4 if you want to build from source. You can get the binaries at http://acl2s.ccs.neu.edu/acl2s/src/acl2/
  4. Unzip the ACL2 tarball somewhere, I put it in my home directory, so it ended up as ~/acl2-image-7.1-macosx.x86_64
  5. Launch the DrRacket IDE
  6. Menu: Language -> Choose Language -> Other Languages -> Dracula -> ACL2
  7. Menu: Dracula -> Change ACL2 Executable Path… -> Point it at the run_acl2 binary in the directory where you installed ACL2.
  8. In the top-left window, paste the following:
    (include-book "j-bob-lang" :dir :teachpacks)
    (include-book "j-bob" :dir :teachpacks)
    (include-book "little-prover" :dir :teachpacks)

    Note: Running these commands  in the REPL in the bottom-left window didn’t work for me.

  9. Click the “Run” button at the top-right of the Dr. Racket window.

You’re now set up to use J-Bob. Verify it worked by typing the following in the interpreter in the bottom-left window of Dr. Racket.

(J-Bob/step (prelude) '(car (cons 'ham '(cheese))) '())

The output should be:

(car (cons 'ham '(cheese)))


Posted in Uncategorized | Tagged , , , | Leave a comment

Generating Dash cheat sheets

I’m a big fan of the Dash documentation tool for macOS. In particular, I often create my own Dash cheat sheets to help me remember commands I frequently forget.

I make enough of these that I created a simple Go app named cheat to generate a skeleton cheat sheet. I also created an UltiSnips snippet to make it easier to generate categories and entries in cheat sheets.

snippet entry "cheatsheet entry"
entry do
    name '$1'
    notes <<-'END'

snippet category "cheatsheet category"
category do
    id '$1'

On Neovim, this would go in ~/.config/nvim/UltiSnips/ruby.snippets

Posted in dash | Leave a comment

Paste as plain text with Quicksilver

I used to use Plain Clip for converting clipboard contents to plain text before pasting, but now I do it in one step with Quicksilver.

I created the following custom trigger:

Item: Clipbord Contents
Action: Paste as Plain Text
Shortcut: alt-v

Now if I do alt-v instead of cmd-v for pasting, it pastes as plain text.

Posted in quicksilver | 1 Comment

Lock screen or sleep from Quicksilver

I recently got a new laptop, and I’ve been transferring over all of my settings. I often use Quicksilver to trigger a screen lock or put my laptop to sleep. Here’s how I do it.

I use a shell script to put my machine to sleep:


pmset sleepnow

In order to be able to trigger the shell script from Quicksilver, you’ll need the “Terminal Plugin” installed.

I use an AppleScript script to lock my screen:


tell application "System Events"
    set ss to screen saver "Flurry"
    start ss
end tell


I use the QuickSilver “Add to Catalog” action to add sleep.sh and lockscreen.scpt to the catalog. That action isn’t enabled by default, to enable it, you need to open QuickSilver preferences, click “General”, choose “Actions”, search for “Add to Catalog”, and enable it.

By default, the “Open” action has a higher precedence than the “Run” action for shell scripts. You can change the precedence order of actions by dragging, I dragged the “Run […]” action (Run a Shell Script [with optional arguments]) above the “Open” action.


Posted in Uncategorized | Leave a comment

Spinnaker & Kubernetes on macOS

Recently I was playing with the open-source release of Spinnaker, the continuous delivery tool that we use inside of Netflix. Spinnaker is designed for deploying apps on cloud backends (e.g., AWS, GCE), but I wanted to run everything entirely on my MacBook Pro.

Here’s how I set it up.


This uses Docker for running Spinnaker, and Kubernetes for the backend. The simplest way to get Docker and Kubernetes running on your local machine is:

  1. Install Docker for Mac
  2. Install corectl.app
  3. Install Kubernetes Solo cluster for macOS

Once all of these apps have been installed and running, you should have a Docker icon, Corectl icon, and Kube-Solo icon in your menu bar.

Verify that Kubernetes is running by clicking on the Kube-Solo icon and choosing “Kubernetes Dashboard”

Increase Docker memory

I had to increase the amount of memory in the Docker configuration to get Spinnaker working properly. I set mine to 8GB.

  1. Click on the Docker app in the menu bar
  2. Click the “Preferences” menu option
  3. Choose the amount of memory (8GB worked for me).
  4. Click “Apply & Restart”

Docker hub account

You will also need an account on Docker Hub, since we will configure Spinnaker to use Docker Hub as our image registry, and Spinnaker needs to know what your Docker Hub credentials are to download container images.

Grab the Spinnaker source

We will run Spinnaker from containers that have been previously uploaded to the Quay container registry, but we need the local code because it contains the Docker compose config files that we will use to run Spinnaker.

$ git clone https://github.com/spinnaker/spinnaker.git
$ cd spinnaker

Copy your kubeconfig file to config directory

Spinnaker requires your kubeconfig file which tells it how to connect to your Kubernetes deployment.

$ cp ~/kube-solo/kube/kubeconfig config/kubeconfig

The experimental/docker-compose/docker-compose.override.yml file is configured by default to mount the config directory into the clouddriver container as /opt/spinnaker/config.

Edit config/clouddriver.yml

In the Spinnaker repository that you just checked out, the config/clouddriver.yml file contains configuration for the backend cloud providers that Spinnaker uses. We need to configure it for Kubernetes and for the Docker registry.

Here’s how I configured mine, by modifying the kubernetes and dockerRegistry fields.

  enabled: true
      - name: kubesolo
        kubeconfigFile: /opt/spinnaker/config/kubeconfig
            - accountName: docker-hub

    enabled: true
        - name: docker-hub
          address: https://index.docker.io
          username: your-docker-hub-username-goes-here
          password: your-docker-hub-password-goes-here
               - library/nginx

The example above will only allow you to run containers from the nginx repository. In a real deployment, you’d add more repositories, but nginx containers are just fine for local testing.

Start up Spinnaker using Docker Compose

Switch to the directory that contains the Docker Compose config files and start up all of the Spinnaker containers:

$ cd experimental/docker-compose
$ DOCKER_IP=localhost docker-compose up -d

It will take a few minutes for Spinnaker to come up.

Open Spinnaker in your browser

Docker Compose is configured to expose the Spinnaker web UI at http://localhost:9000.

Next, you can check out the Kubernetes Source To Prod code lab on the Spinnaker website for how to launch an app.

Posted in Uncategorized | Tagged , , | 1 Comment

Go: Pointer to methods

Go: Pointer to methods

Sometimes I need a pointer to a method that is not bound to an explicit object.

Method pointers are just function pointers where the first argument is the type.

Imagine we have a Pet type with a Speak method:

type Pet interface {
    Speak() string

Here’s how we would declare, assign, and invoke the pointer

var fp func(Pet) string
fp = Pet.Speak

pet := GetPetFromSomewhere()
fmt.Sprintf("The pet says: %s\n", fp(pet))
Posted in Uncategorized | Tagged | Leave a comment