Setting up Fish on the Mac
Fish shell is my shell of choice and having it setup
as default on the Mac requires some extra steps.
When homebrew is installed, run brew install fish
.
After that, edit /etc/shells
and add fish to it:
# sudo edit /etc/shells
Add the bottom of the file add:
/opt/homebrew/bin/fish
Then set the shell as default with:
chsh -s /opt/homebrew/bin/fish
It does require logging again to be activated.
Crisp fonts on Alacritty

I’m using Alacritty on the Mac and I noticed how the
font rendering is much thicker than I’m used to on iTerm. On iTerm I use the
“thin strokes” setting, which is not available in Alacritty.
Turns out, you can set it with:
defaults write org.alacritty AppleFontSmoothing -int 0
If you then log in and logout again, your Alacritty will be similar to the
crispness you find in iTerm.
Some people like to have this kind of crispness across the entire OS. If you
are one of them:
defaults write -g AppleFontSmoothing -int 0
Faster key repeat on the Mac
I like to have my key repeat set high, because I still browse my code line,
by line; yes, I know there are better ways to browse.
On the Mac, if you go through the “System Preferences”, there is only so much
you can do. Luckily, you can get the right settings if you use the terminal.
First, make sure that you have disabled “Slow keys” in “System Preferences > Accessibility > Keyboard > Slow keys”.
Then go into your Terminal of choice and type:
defaults write -g KeyRepeat -int 1
defaults write -g InitialKeyRepeat -int 12
The normal minimum of KeyRepeat
is 2. Setting it to 1 will have a key repeat
delay of 15ms.
For the InitialKeyRepeat
, the minimum is 10; 15 if you use system settings. I
prefer to set it to 12.
If you want to restore the defaults, just go through the system settings and set
it to a value you prefer.
Java with Adoptium on Linux
Recently I wrote down how to get Java installed on MacOS with the help of Adoptium. Well, it turns out, I also use Linux (Pop!_OS if you were wondering).
To install Java on Linux, go to the Adoptium page and download the tarball according to the version and your architecture. I downloaded the LTS 19 for x64:
tar xfz OpenJDK19U-jdk_x64_linux_hotspot_19.0.2_7.tar.gz
sudo mv jdk-19.0.2+7 /opt/
And now make sure that your shell can find it, my shell is Fish, so I added this snippet:
# Java installation through Adoptium
set -l java_version "19.0.2+7"
if test -d "/opt/jdk-$java_version"
set -x JAVA_HOME "/opt/jdk-$java_version"
fish_add_path -aP "$JAVA_HOME/bin"
end
Now you have Java, quickly go install Clojure :)
Espanso, text expander for Linux
I love the smart dashes – and I use them heavily – on the Mac and it’s something I missed on PopOS!.
Luck be it, Espanso comes along. Installation on a Debian system is easy.
Configuration of Espanso is done by editing configuration files located in ~/.config/espanso
directory. You can also find it by tying espanso path
. The files contained in the match
directory define what Espanso should do. The files contained in the config
directory define how Espanso should perform its expansions.
To replace our double dashes with a long dash we are going to edit $CONFIG/match/base.yml
add change it to:
matches:
- trigger: "--"
replace: "—"
However, now this also happens in our terminal, which is annoying, so we are going to disable Espanso completely in the terminal with an app specific configuration.
We’ll disable it in Alacritty, my terminal of choice by creating a config/alacritty.yml
and match on the class name:
filter_class: Alacritty
enable: false
That’s it, Espanso is super powerful and I can recommend reading the docs on what else it can do. Oh, and it also works on MacOS or Windows.
Installing Clojure on a Mac
I had to set up a new laptop recently, and one of the first things you install on a new laptop is Clojure.
Below is the setup I used and which got me started quickly. First, you must install Homebrew as a package manager.
Second, we also need Java, and the best option out there is supplied by Adoptium, which has pre-built OpenJDK binaries for you. Go to the website and download the latest LTS release if you want to be safe, or download the newest version (19 as of writing this) if you’re going to live on the edge.
After that, install Clojure is one command away:
brew install clojure/tools/clojure
Type clj
on the command line, and when running for the first time, it will download the required packages and give you access to the REPL.
Now, for starting and managing projects, neil
is an amazing new CLI which can help you do that. Install it with:
brew install babashka/brew/neil
A quick gitignore from a template
Often when I start a new project, I also need to have a .gitignore
for the specific language that I’m working in.
To easily do this, I added the following alias to my git, which pulls a template from gitignore.io:
git config --global alias.ignore \
'!gi() { curl -sL https://www.toptal.com/developers/gitignore/api/$@ ;}; gi'
Now you can do git ignore zig
and it will show you the default ignore file for a Zig project.
To automatically put it in your gitignore, just redirect the output:
git ignore zig >> .gitignore
Easily install Zig with zigup
I used to manage my Zig installation by installing the binary and copying to my path. Not too hard, but now there is even an easier way by using zigup
.
To install zig, it enables you to simply type zigup master
I would recommend to get the latest binary from the Github releases page. Or if
you already have Zig, install it from source:
# Install the binary
git clone [email protected]:marler8997/zigup.git
cd zigup
zig build -Dfetch
cp zig-out/bin/zigup ~/.local/bin/
Language Servers for Helix
I have been trying out Helix as my daily editor and the editor has built in support for LSP. However, it does not install the Language Servers, so you have to do that yourself.
Below are the language servers I installed for writing my code in HTML, CSS and Markdown.
You can always check if a language is setup by doing:
hx --health <lang>
So for example this will tell you if your HTML is supported:
hx --health html
HTML, CSS and SCSS
Both HTML, CSS and SCSS use the language server from Visual Studio Code:
npm i -g vscode-langservers-extracted
Markdown
For Markdown it uses marksman and to install it you can download the latest version from their releases page
wget <link from releases page>
# Make it executable
chmod +x marksman-<dist>
# Move it to a directory in your path, in my case `~/.local/bin`
mv marksman-<dist> ~/.local/bin/marksman
Move it to somewhere in your $PATH
and you should be good to go.
Zig types explained in Ziglings
I have been tinkering with Zig lately and to get a grasp on the language
I have been using the excellent Ziglings quizes.
In Quiz #58 there is a great comment which lists the different types for Zig:
//
// We've absorbed a lot of information about the variations of types
// we can use in Zig. Roughly, in order we have:
//
// u8 single item
// *u8 single-item pointer
// []u8 slice (size known at runtime)
// [5]u8 array of 5 u8s
// [*]u8 many-item pointer (zero or more)
// enum {a, b} set of unique values a and b
// error {e, f} set of unique error values e and f
// struct {y: u8, z: i32} group of values y and z
// union(enum) {a: u8, b: i32} single value either u8 or i32
//
// Values of any of the above types can be assigned as "var" or "const"
// to allow or disallow changes (mutability) via the assigned name:
//
// const a: u8 = 5; // immutable
// var b: u8 = 5; // mutable
//
// We can also make error unions or optional types from any of
// the above:
//
// var a: E!u8 = 5; // can be u8 or error from set E
// var b: ?u8 = 5; // can be u8 or null
Create a new repository with Github CLI
Github has their own CLI tool which enables you
to interact with Github through the command line.
I often start new repositories and started using the following command to
quickly create a accompanying, private repo on Github:
gh repo create <name> --private --source=. --remote=origin
Install Emacs on the Mac
There are many ways to install Emacs on the Mac, from pre-build
Applications, to Homebrew, to installing from source.
My current favorite way to get the latest Emacs which has some
additional stuff for the Mac is by using a build script, which builds
Emacs from its source.
It’s called build-emacs-macos and is on Github. The instructions to use it are here in the README.
Emacs on Windows WSL2
So, it turns out that WSL2 is actually kind of neat, where it
runs a Linux image at almost native speed, and also supports
Wayland.
So, what’s the first thing you do in WSL2? Install Emacs of course!
Below is the script I use to install Emacs on an Ubuntu image.
To know what the latest stable version on master is, I look at this Github issue from Jim Myhrberg, who keeps track of those.
# Checkout Emacs
$ git clone git://git.sv.gnu.org/emacs.git
# Checkout latest stable version, see note above.
$ git checkout 8febda4
# Vanilla Emacs requirements
$ sudo apt install build-essential autoconf libgtk-3-dev libgnutls28-dev libtiff5-dev libgif-dev libjpeg-dev libpng-dev libxpm-dev libncurses-dev texinfo adwaita-icon-theme-full
# Native compilation requirements
$ sudo apt install libgccjit-11-dev
# Required for Native JSON
$ sudo apt install libjansson4 libjansson-dev
# Required for tree-sitter support
$ sudo apt install libtree-sitter-dev
$ cd emacs
$ export CC=/usr/bin/gcc-11 CXX=/usr/bin/gcc-11
$ ./autogen.sh
$ ./configure --with-pgtk --with-native-compilation --with-tree-sitter --with-json --without-pop
$ make -j$(nproc)
$ sudo make install
And, sometimes when you update the repository, it refuses to build. I usually fix that with running make bootstrap
er make distclean
.
Syncthing on WSL2
I like to use Syncthing to sync files between accounts and machines, and now even between my Windows subsystem and Windows itself.
To run Syncthing on WSL I use this script:
#!/usr/bin/env bash
SERVICE="syncthing"
USER="petar"
PORT=2103
OPTS="
--no-browser
--home=/home/$USER/.config/syncthing
--gui-address=http://127.0.0.1:$PORT
--logfile=/home/$USER/.config/syncthing/syncthing.log
"
if ! pgrep -x "$SERVICE" >/dev/null
then
daemonize /usr/bin/syncthing serve "$OPTS"
fi
Make sure to change your username and to make the port unique, if you run multiple Syncthings on your machine.
Rust Analyzer from Source
I’m developing on a FreeBSD machine and rust-analyzer is not available as a pre-build release.
Luckily, it’s easy to build rust-analyzer from source. Just clone the repository and run:
cargo xtask install --server
I’m on Emacs, so I only need the server, hence the --server
argument. If you are using Visual Studio Code, don’t add it.
How to install Quicklisp
Before starting, make sure you have installed SBCL. Then get the quicklisp file which enables
you to bootstrap and install Quicklisp.
cd ~/downloads
curl -O http://beta.quicklisp.org/quicklisp.lisp
sbcl --load quicklisp.lisp
Now you are in the REPL and you can install Quicklisp. By default, it will be installed
in ~/quicklisp
, but I like to keep my home directory clean and install it in ~/.local/share/quicklisp
. Thus the :path
argument.
(quicklisp-quickstart:install :path "~/.local/share/quicklisp/")
I also prefer Quicklisp to always be available when I start SBCL, so I add it to my
init file:
(ql:add-to-init-file)
That’s it! Happy Lisping!
Switch the current working directory in the REPL
If you start a REPL in the wrong directory, you can switch it by using UIOP.
UIOP is the portability layer of ASDF, supplying an abstraction on top of different implementations or OS’es.
For example, to change to a new project do:
(uiop:chdir "~/lisp/fangorn/")
Make your own packages available to Quicklisp
In Lisp it’s quite common to have your own helper libraries, which are packaged as ASDF packages. To be able to use your libraries in other projects, you need to let ASDF know how to find them.
First create the directory ~/.config/common-lisp/source-registry.conf.d/
There create a file with any name of your choice but with the type conf, for instance 50-petar-lisp.conf
.
In this file, add the following line to tell ASDF to recursively scan all the subdirectories under /home/petar/lisp/
for .asd files: (:tree "/home/petar/lisp/")
.
Template for a new Common Lisp Project
To easily start a new Common Lisp project, I’m making use of the CL-Project from the famed Lisper Eitaro Fukamachi.
You can either install it through roswell with ros install cl-project
or through the use of Quicklisp with (ql:quickload "cl-project")
.
The benefit of install it through Roswell is that you also get a binary.
To create a project through the REPL:
(cl-project:make-project #p"lisp/cl-sample/"
:author "Eitaro Fukamachi"
:email "[email protected]"
:license "LLGPL"
:depends-on '(:clack :cl-annot))
Or by using the binary:
make-project /home/user/common-lisp/sample \
--name sample \
--description "sample project." \
--author "Your name" --license LLGPL \
--depends-on alexandria split-sequence`
Cargo modules
Today I learned about the cargo-modules, a cargo plugin which shows you an overview of your crates modules.
I like to check the tree and my public interface with:
cargo modules generate tree --with-types
Fish environment variable for just one command
Happy Fish shell user for years, but I’m never able to remember how to set an environment variable for a single command. Maybe I’ll remember if I write it down:
env SOME_VAR=1 command
From Lisp to Python, but why Peter?
Peter Norvig is a well-known educator on A.I. and used to be one of the key figures in the Lisp movement.
His books used to use Lisp in their exercises, but he switched to Python at some point. Today, I came across the Lex Fridman podcast, where he interviewed Peter Norvig and asked him why he made that change.
He gives a surprisingly simple answer at the 43-minute mark.
I was expecting deeper reasons, but his students were having difficulty grasping Lisp, and a questionnaire showed that Python mimicked the pseudocode from the book the most. That’s it.
In the short amount of time he had to educate them on A.I., he could not spare the time to educate them on Lisp.
Coincidentally, I also came across this gem at smuglispweeny blog:
At ILC 2002 former Lisp giant now Python advocate Peter Norvig was for some reason allowed to give the keynote address like Martin Luther leading Easter Sunday mass at the Vatican and pitching Protestantism because in his talk Peter bravely repeated his claim that Python is a Lisp.
When he finished Peter took questions and to my surprise called first on the rumpled old guy who had wandered in just before the talk began and eased himself into a chair just across the aisle from me and a few rows up.
This guy had wild white hair and a scraggly white beard and looked hopelessly lost as if he had gotten separated from the tour group and wandered in mostly to rest his feet and just a little to see what we were all up to. My first thought was that he would be terribly disappointed by our bizarre topic and my second thought was that he would be about the right age, Stanford is just down the road, I think he is still at Stanford – could it be?
“Yes, John?” Peter said.
I won’t pretend to remember Lisp inventor John McCarthy’s exact words which is odd because there were only about ten but he simply asked if Python could gracefully manipulate Python code as data.
“No, John, it can’t,” said Peter and nothing more, graciously assenting to the professor’s critique, and McCarthy said no more though Peter waited a moment to see if he would and in the silence a thousand words were said.
Add aliases for your Rust project
I was looking at the Monkey language implementation done by Lauren Tan and noticed a .cargo/config.toml
file in the project directory. In it was a convenient alias for her project:
dev = "watch -x check -x test"
This way, we can run cargo dev
, which will run a check, which is not a build but catches a lot of errors quickly. The test
is for those doing TDD because it will run the tests after every change. Convenient!
Tsundoku
Today I found out that my afflication, hoarding books, is called tsundoku.
It combines elements of tsunde-oku (積んでおく, to pile things up ready for later and leave) and dokusho (読書, reading books).
Article: The Pleasures of Tsundoku, Or: How I Learned to Stop Worrying and Love Book Piles
Changing working directory in tmux
I tend to keep a long-lived tmux session per project that I’m working on. When I want to start a new project though, it carries the old working directory with it. I keep forgetting what I need to do to type it, so hopefully this TIL makes me remember it for the next time.
To switch the current working directory, do a :attach -c <newdir>
. And to do it it even more easily, I bound it in my tmux configuration to Meta-w
:
bind M-w attach -c "#{pane_current_path}"
SSH Tunnels
I often rely on SSH tunnels to forward remote ports locally. For example, to control my remote installation of Resilio Sync. There is a lot of flags you can set, but these are the flags that work best for me:
ssh -CqTnNf -L 8889:localhost:8888 [email protected]
In this example, I forward the remote localhost:8888
port to my local 8889
. The flags do the following:
C
: Compress the data.
q
: Silent modus.
T
: Disable pseudo-tty allocation.
n
: Prevent reading stdin.
N
: No remote commands, just forwarding.
f
: Run in the background.
L
: Specifies the forward.
Now, if you want to exit the tunnel, you could kill SSH pkill ssh
, but this will kill all your SSH connections. I multiplex my connections and can run: ssh -O exit [email protected]
. You would need this in your ~/ssh/.config
to be able to do that as well:
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
Rust project templates
Rust never stops to amaze me with its command-line tools and today I found out about cargo-generate
which enables you to setup a repository which will function as a project template for Rust.
As an example, to pull down the repository and start a new project, you would do:
cargo generate --git https://github.com/githubusername/mytemplate.git --name myproject
Staying up-to-date with Rust
I have this tick where I continuously check that my tools are running the latest version. I guess you could call it a form of FOMO.
Luckily, Rust has me covered with two packages which check that for me.
cargo-outdated which check that your project dependenies are up-to-date. And cargo-update which checks that your Rust executables, like cargo-edit are running the latest version.
It will even update itself!
Do not get to shame
The code I’m still ashamed of is an excellent read, reminding us of our responsibility as software developers.
It also reminded me of an experience we had with Bread & Pepper, the web agency we ran from 2009-2013. A government agency approached us to build an iPhone app where you could overlay your face on Einstein. We could have used the money but decided to be frank and tell them that the idea was ridiculous and a waste of public funds.
After a few weeks, we received the response that we were the only ones who told them the truth and picked us to continue the conversation on how to achieve their goals. We got rewarded for our honesty that day.
I tend to pay attention to the feeling of shame, its trying to tell me that I did something against my morals.
Reminder that shame is a strong indicator that you messed up. Be morally strong and avoid that feeling of shame.
Tombstones for code
An interesting 5-minute talk called Isn’t That Code Dead? where David Schnepper talks about a technique called “Tombstones.”
The simple technique where you place a marker in your code which logs if it’s ever called. After a while, you check your logs and see what markers are untouched, giving you the confidence to remove that code.
Great way to find dead code in situations where the compiler can’t help you, for example interfaces exposed on the network.
Tombstones is a simple technique which can help you reduce the lines of code by eliminating dead code.
Rust tooling came a long way
I bought the Hands-on Rust and needed to setup my editor (Visual Studio Code) to start working on my 2D dungeon crawler. Choose Rust Analyzer and could not be more impressed with the experience.
Also impressed with some of the Cargo helper tools, like cargo-edit to manage dependencies, cargo-audit to check for vulnerabilities and cargo-expand to expand macro’s.
2021 is a great year to start learning Rust. Both the ecosystem and learning materials have reached a high level of maturity.
Ask Iwata
Ask Iwata was a quick read, a loosely connected series of short essays where I read a lot of things which resonated with me.
On my business card, I am a corporate president. In my mind, I am a game developer. But in my heart, I am a gamer.
As you move to management, you must never loose focus on the core values of your business. It’s your role to create an environment which inspires towards those goals and that empowers your team to do their best work.
Management frameworks and processes often miss this point, where they serve the manager instead of the team.
As a manager you can never loose touch with the process of creation. It’s your job to create an environment where that can thrive.