1Password CLI Cheatsheet

The 1Password CLI op works either in connection with a client app, like on the Mac, or standalone, useful on a server.

# Login
eval $(op signin)

# Get favorites
op item list --vault "Private" --favorite

# Get a specific item
op item get <ID>

# !! Important: Sign out at the end
op signout

Some helper functions

Helpers to more easily work with the op cli.

1login() {
    eval $(op signin)
}

alias 1signout="op signout"

1search() {
    term=$1
    if [ -n "$2" ]
    then
      vault="$2"
    else
      vault="Private"
    fi
    echo "Searching for '$term' in vaut '$vault'"
    op item list --vault "$vault" --long | grep "$term" --ignore-case
}

1get() {
    op item get $*
}

yamllint error: "invalid config: ignore should contain file patterns"

Setting up a new repository for YAML linting today I was running in a bit of an issue with yamllint. I was using a YAML list to specify ingores, as mentioned in the documentation: ignore: - "*.dont-lint-me.yaml" - "/bin/" - "!/bin/*.lint-me-anyway.yaml" This however did not work with the above mentioned error message. After a lot of debugging I found that they released a new version recently which introduced this feature. [Read More]

WSL2 & Keychain

The problem

If you use ssh-agent with an encrypted ssh key it does not persist when you open a new terminal window.

The solution

Use keychain instead.

  1. Install
    sudo apt install keychain
    
  2. Add to your shells rc file, eg. .bashrc or .zshrc
    # Repeat this line for all keys you want to unlock and use this way
    /usr/bin/keychain -q --nogui $HOME/.ssh/id_rsa
    source $HOME/.keychain/wsl-sh
    
  3. Unlock your keys on shell startup and enjoy
wsl  linux  ssh 

Self-hosted notifications

Self-hosted notifications

Running any kind of personal infrastructure sometimes requires your attention based on certain events or failure states, no matter how much you automate tasks.

Over the years I have used E-Mail, Telegram bots and a variety of other tools for this purpose. However all of them have the drawback that they mix with other kinds of information and are not easilly usable in scripts.

[Read More]

Git: Add only changed files

Sometimes you may want to commit only the files you have changed and not any newly created files, this can easily be achieved by this command: git commit -a

[Read More]
git 

Post Mortems

Learning from incidents

Incidents happen, and we can and should always learn from them, to be better prepared for the next time things go wrong. A great tool to do that is the post-mortem, it is a process designed to recap the incident, learn from mistakes and improve the system as a result. Basic principles There are some basic principles that can help achieve a good post-mortem process. They are only guidelines and I recommend adapting them to what works best in your organization. [Read More]

Monoliths & Microservices

An opinionated overview

Ever since diving into the software development world I was troubled by a duality: On the one hand I have built and operated many services described as monolithic with relative ease, on the other hand I’m always told I, and others, should build microservices because they are better in a variety of ways. With this post I’m going to compare both software architectures by looking at the key benefits often associated with microservices and additional considerations I think are important. [Read More]

Simple git changelog

A simple changelog system on top of git commit messages. The main idea is to generate “release notes” from a diff in commits before a release. It can easily be run manually or as part of a merge/pull CI pipeline. In this case it looks for commit messages starting with one of these [ADD], [REMOVE], [INFO] and just outputs those, but those patters can be adjusted to fit any existing commit schema. [Read More]

Going Part Time

(Re)starting my indie journey

Starting on the first of March 2022 I no longer work full-time in my day job. That sentence has been about a year in the making and makes me both happy and a bit scared about the future. I have been doing some side-hustle and projects since I’ve been 16 building websites with my dad, so you could say it has been a long time coming. Right now I have set myself three mid-term goals to build up something that brings me joy and financial independence. [Read More]

Local S3 with MinIO in Django

In production I would consider it best practice to use a S3 solution for serving assets. Namely static files and user-generated media. This describes my setup on how to do this locally too. The main benefit for me is that there is less of a difference between environments and I can test S3 specific features in my app. Setup I will assume a already working Django project and MacOS with [[brew]] installed, but brew specific parts are easilly replicated on different systems using their native package managers. [Read More]
python  django  s3  minio 

Hidden WSL Fileshare

WSL file systems get exposed as a hidden share network share: \\wsl$\<WSL Name>\<path\to\file>

For example, my Debian home folder is at: \\wsl$\Debian\home\kamner

wsl  windows 

Windows Terminal: Open New WSL Tab In Linux Home Folder

The path you are in when opening a new WSL tab is determined by startingDirectory. This parameter needs to be a valid Windows path, which isn’t great if we want to end up in /home/kamner inside WSL. The nice thing about WSL is that it will resolve windows paths into their equivalent WSL/linux path if possible. For example, C:\Scripts would resolve to /mnt/c/Scripts. Using this and the neat trick that the WSL filesystem is exposed as a a hidden fileshare (technology/windows/wsl-hidden-fileshare) we can get to where we want. [Read More]