A place where I capture raw, quick notes worth remembering.

February 23, 2024

docker

Docker completions in Fish

To get Docker completions for the Fish shell, all you need to run is:

docker completion fish > ~/.config/fish/completions/docker.fish

This will not only give you completions for every command, but also completions on containers.

Permalink

December 10, 2023

clojure mac lisp

Clojure on MacOS

To install the latest version of Clojure on MacOS, you first need to install Java, after which you can install Clojure.

To install Java, I use Temurin and pick the latest LTS (Long-Term Support) version.

Assuming you already have Homebrew:

brew install temurin
brew install clojure/tools/clojure

This will also install rlwrap which makes sure that you can use the arrow keys in the REPL.

I also use neil for some common aliases, for example, to create a new project.

brew install babashka/brew/neil

Now you can run the neil new command to create a new Clojure repository.

Permalink

August 23, 2023

vim wsl

Copy/Paste for Neovim in WSL

If you want a seamless copy/paste experience on Neovim in WSL there is a newly recommended method for doing so, without having to install extra software.

Paste the following Lua snippet in your configuration and "+y to yank the selected text into your global register. Similarly, use "+p to paste.

if vim.fn.has "wsl" == 1 then
  vim.g.clipboard = {
    name = "WslClipboard",
    copy = {
      ["+"] = "clip.exe",
      ["*"] = "clip.exe",
    },
    paste = {
      ["+"] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
      ["*"] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
    },
    cache_enabled = 0,
  }
end

Permalink

August 22, 2023

windows wsl

Faster key repeat on Windows

With WSL, Windows can be a great developer experience. The one thing which I did find lacking, especially when moving around in Vim, is that the maxixmum key repeat rate in the configuration panel is too slow.

I was able to fix that with the following settings in Regedit:

[HKEY_CURRENT_USER\Control Panel\Accessibility\Keyboard Response]
"AutoRepeatDelay"="240" 
"AutoRepeatRate"="12" 
"DelayBeforeAcceptance"="0" 
"Flags"="59" 
"BounceTime"="0"

You have to login and out again for it to take effect.

Permalink

August 22, 2023

vim linux

Latest Neovim on Ubuntu

I’m using Ubuntu for my development environment, and Ubuntu does not have the latest Neovim in their repository.

That’s why I choose to install the last version by source. The steps I take are:

wget https://github.com/neovim/neovim/releases/download/v0.9.1/nvim-linux64.tar.gz
tar xfz nvim-linux64.tar.gz
sudo mv nvim-linux64 /opt/nvim

Now you have to make sure that /opt/nvim/bin is part of your path. If you are smart, and using the Fish shell, add this to your Fish config.

fish_add_path -aP /opt/nvim/bin

If you are on Bash:

export PATH=/opt/nvim/bin:$PATH

Enjoy your latest version of Neovim!

Permalink

July 9, 2023

linux alacritty

Alacritty as default terminal

I’m using Alacritty as my terminal of choice on Ubuntu (Pop!OS). When installed manually, it does not work with the hotkey of Pop!OS because you can’t set it as the default terminal.

For that to work, you have to manually add it as an alternative and set it:

sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator $(which alacritty) 50
sudo update-alternatives --config x-terminal-emulator

Permalink

July 5, 2023

vim

Patching Berkeley Mono with Nerd Fonts

I’m using Berkeley Mono as my font, which is beautiful, but doesn’t have all the glyphs I need for my terminal and editor.

The glyphs I need are part of Nerd Fonts. This is the command I run to patch Berkeley Mono with the use of Docker:

docker run --rm \
	-v /tmp/berkeley-mono/origin:/in \
	-v /tmp/berkeley-mono/patched:/out \
	nerdfonts/patcher \
	--progressbars \
	--mono \
	--adjust-line-height \
	--fontawesome \
	--fontawesomeextension \
	--fontlogos \
	--octicons \
	--codicons \
	--powersymbols \
	--pomicons \
	--powerline \
	--powerlineextra \
	--material \
	--weather

I found the above command in this blog post from Serhat Teker: Patching Fonts with Docker.

Permalink

June 9, 2023

python

Working with Python

I’m exploring the world of Machine Learning, and in that world, Python is king.

Since it had been a decade since I worked with the language, I had to set up a good development environment, starting with installing Python.

For system-wide Python, I resort to my trusty asdf version manager. It’s a great tool that allows me to install multiple versions of Python and switch between them easily.

I also want pyright and black installed with each Python installation, so I first create a file in my home directory called .default-python-packages with the following contents:

pyright
black

Then I run the following commands to install the plugin, install Python 3.11.4, and set it as the default:

asdf plugin add python
asdf install python 3.11.4
asdf global python 3.11.4

This manages my global Python installation, which I use for standalone scripts.

However, I need to set up a virtual environment to work on a project with dependencies. For that, I use a new tool called Rye. Rye manages everything, including the Python version – so I won’t use asdf for that.

After installing Rye, I can create a new virtual environment with the following:

rye init my-project

This will create a new directory called my-project with a rye.toml file in it. This file contains the Python version and the default packages to install. I can add more packages to it, like langchain:

cd my-project
rye add langchain

This only adds the dependency but does not install it. For that, we need to run rye sync.

That’s it! Now we have ASDF for our global Python and Rye for our projects in Python. Enjoy!

Permalink

June 5, 2023

life

3, 2, 1... Sleep

I would always deprioritize sleep, stay up late, wake up early. And honestly, it was one of the most stupid things I did.

These days I make sure to get at least 7 hours of sleep. So that’s for the duration of sleep, doesn’t say much on the quality though.

So for quality I have this simple 3, 2, 1 rule:

  • 3 hours before sleep: no food.
  • 2 hours before sleep: no drinks.
  • 1 hour before sleep: no screens.

I’ve been doing this for a while now and it significantly improved my sleep quality. I wake up more rested and I’m more productive during the day.

Permalink

May 20, 2023

fish mac

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.

Permalink