Thursday, 15 January 2026

Kotlin : NullSafety + Defaults

So, I had a discussion with my colleague about null safety and how it can be non-intuitive if you're not yet used to it.

So we had the following code:

In a lot of REST applications, an Exception may be thrown when a resource does not exist. But it's important to differentiate between "no resource" and "oh no! An exception occurred! We're in trouble!".

That's what this example code does.

So, what did the "getStatus" method do exactly?

This causes the test to fail.

The code should have been "?: false", but doing that does look weird.

A clearer solution would be:

The problem with Kotlin might be that there's alot of "?." and "?:" and "!!" and quite frankly it makes it hard to read.

What do you think?

Sunday, 11 January 2026

Trying out the Github Command Line

So it's possible and quite convenient to use hardcode git commands to checkout Github repositories. It works fine, once you get the SSH keys sorted out and all that.

I tend to use IntelliJ to checkout new github repositories, as it is soo much easier to point and click.

This always happens to me, when I find myself having to do things I don't do often. Because once you have a repo checked out, that's basically the end of all the complicated stuff and you just get to work.

Checking out using Git

I still prefer using Git to checkout a new repository for now4.

The way this works is just do "git clone git@github.com:username/repo.git". You can find this url in the repository on the GitHub website.

However, an ssh key must be available on your GitHub account for the computer/client you're using.

First generate such an ssh key on your computer, using reference [5].

For example: "ssh-keygen -t ed25519 -C "mrbear@mrbear.com"".

Add your ssh key to the ssh-useragent, using "ssh-add ~/.ssh/id_ed25519".

You should see:

$ ssh-add ~/.ssh/id_ed25519
Enter passphrase for /home/mmrbear/.ssh/id_ed25519:
Identity added: /home/mrbear/.ssh/id_ed25519 (mrbear@mrbear.com)

Then you can add the generated key to your Github account using the website, using reference [6].

After that, you can finally just clone your repo as mentioned above.

Installation

GitHub has a command line interface nowadays1. It's easy to install2.

I'm using Fedora, so all it takes on my end is to "sudo dnf install gh".

There used to be a tool called "hub", apparently, which is basically a git wrapper for GitHub. It was an unofficial tool. You can find the differences discusses in [3].

Using the CLI

Logging in using "gh auth login".

$ gh auth login
? Where do you use GitHub? GitHub.com
? What is your preferred protocol for Git operations on this host? SSH
? Upload your SSH public key to your GitHub account? Skip
? How would you like to authenticate GitHub CLI? Login with a web browser

! First copy your one-time code: DFGF-JFDB
Press Enter to open https://github.com/login/device in your browser...
✓ Authentication complete.
- gh config set -h github.com git_protocol ssh
✓ Configured git protocol
✓ Logged in as mrbear

Then the command "gh issue list" shows me open issues.

Works! Quite nice!

References

[1] GitHub - Take GitHub to the command line
https://cli.github.com/
[2] Installing gh on Linux and BSD
https://github.com/cli/cli/blob/trunk/docs/install_linux.md
[3] GitHub - GitHub CLI & hub
https://github.com/cli/cli/blob/trunk/docs/gh-vs-hub.md
[4] GitHub - Cloning a repository
https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository
[5] GitHub - Generating a new SSH key and adding it to the ssh-agent
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
[6] GitHub - Adding a new SSH key to your account
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account