This is a collection of random technical notes that I’ve accumulated over time.


# enable repo wide commit signing
git config commit.gpgsign true

# set global signing key
git config --global user.signingkey CAFEBABE

# create new branch, take local changes along
git checkout -b new-branch

# remove local branch
git branch -d new-branch

# add single hunk from a file
git add -p

# push the current branch
git push origin HEAD

# create alias "git new" to init with empty commit
git config --global '!git init && git commit --allow-empty -m "initial commit"'

# update all submodules
git submodule foreach git pull origin master

# create and apply patches
git format-patch -1 <commit-sha>
git am <patch-file>

xcrun: error

If running into

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

while doing e.g. git status (especially after a MacOS update), re-run xcode-select --install or sudo xcode-select --reset.


Splitting windows

  • C-x 2: split into two windows, one above the other
  • C-x 3: split into two windows, side by side
  • C-x o: switch to other buffer in window split

(Spacemacs only) Required package request-0.1.0 is unavailable

see issue #4642

  1. M-x list-packages
  2. search and install request
  3. restart emacs M-m f e R (for ‘evil’: SPC f e R)

Duplicate current line

(defun duplicate-line()
  (move-beginning-of-line 1)
  (open-line 1)
  (next-line 1)

(global-set-key (kbd "C-c d") 'duplicate-line)

Delete entire current line

(global-set-key (kbd "C-c f") 'kill-whole-line)

Mac command key work as expected again (Mac)

(setq mac-option-modifier 'nil)
(setq mac-right-option-modifier 'nil)

Webserver configuration

Enable autorun on boot (Ubuntu)

sudo update-rc.d supervisor defaults

Objective C


// define:
typedef retTy (^BlockName)(int foo, NSString *bar);

// use:
BlockName block = ^retTy(int foo, NSString *bar) {
    // do stuff

// as property:
@property (nonatomic, copy) BlockName myBlock;

JavaScript / TypeScript

Install on Mac

Use nvm to install and manage node & npm versions.

ESLint and Prettier

npx eslint --init
npm i --save-dev prettier eslint-config-prettier eslint-plugin-prettier

Next, add prettier to extends and plugins in the eslint config. Also, add a rule that prettier rules are reported as errors:

  "extends": [
  "plugins": [
  "rules": {
    "prettier/prettier": "error"

Tweak the prettier config to your likings:

module.exports = {
  trailingComma: 'es5',
  semi: true,
  tabWidth: 2,
  singleQuote: true,

If you are using VS Code, create a file .vscode/settings.json with this content:

  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true

Potential eslint rules to disable for use with TypeScript

  rules: {
    'react/react-in-jsx-scope': 'off',
    '@typescript-eslint/no-explicit-any': 'off',



Configure daemon to listen on TCP

sudo emacs /lib/systemd/system/docker.service # remove -H option
sudo emacs /etc/docker/daemon.json # update to the following:
# { "hosts": [ "tcp://", "fd://" ] }
sudo systemctl daemon-reload
sudo systemctl restart docker.service


Run on new Apple M1 ARM chip

# install via
arch -x86_64 /bin/bash -c "$(curl -fsSL"

# usage example
arch -x86_64 brew install rocksdb


Load environment from .env file

export $(cat .env | xargs) && my-program

Get scripts directory

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

Sane shell script

#!/bin/bash -eo pipefail


Clipboard syntax highlighting (MacOS)

#!/bin/bash -eo pipefail

pbpaste | pygmentize -l $1 -f rtf | pbcopy -Prefer rtf

Usage: python