Skip to content

Instantly share code, notes, and snippets.


Dmytro Konstantinov UrsaDK

View GitHub Profile
UrsaDK / Terminal integration with macOS
Last active June 2, 2023 05:35
Make command line tools respect macOS appearance
View Terminal integration with macOS

MacOS dark mode & command line tools

  1. Beta version of iTerm2 has built-in support for system appearance and will change themes in sync with macOS;
  2. Setup dark-mode-notify to launch on start and call a custom shell script (eg: when appearance changes;
  3. Update the script as required


  • neovim v0.8.0+ can issue self referencing commands. For example, try putting this into your init.lua to prevent nested vim instances when using built-in terminal:
    vim.env.EDITOR = string.format('nvim --server %s --remote --', vim.api.nvim_get_vvar('servername'))
UrsaDK / Caching multi-stage builds in
Last active June 1, 2023 22:27
Speed up your multistage builds in GitHub Actions
View Caching multi-stage builds in

Caching multi-stage builds in GitHub Actions

Caching Docker builds in GitHub Actions is an excellent article by @dtinth which analyses various strategies for speeding up builds in GitHub Actions. The upshot of the article is a fairly decisive conclusion that the best two ways to improve build times are:

  1. Build images via a standard docker build command, while using GitHub Packages' Docker registry as a cache = Longer initial build but fastest re-build times.

  2. Build your images via docker integrated BuildKit (DOCKER_BUILDKIT=1 docker build), while using a local registry and actions/cache to persist build caches = Fastest initial build but slightly longer re-build times.

The problem

UrsaDK / Strip trailing space in
Last active April 5, 2023 17:11
A function to remove trailing spaces from Vim buffers
View Strip trailing space in

I've been maintaining my own version of Strip Trailing Spaces function (attached at the bottom of this post) since I first started using vim. It grew out of a simple :%s/\s*$// and now includes a number of features:

  • it preserves search history and the last search string
  • it doesn't change editor's '', '. and '^ marks
  • it doesn't add a new jumplist and changelist record
  • it preserves editor's view and cursor position

However, over the years I've noticed that I never needed to undo the results of stripping trailing spaces from a file. In fact, I would go as far as to say that when undoing changes in a file, the function produces an understandable but somewhat undesirable cursor jump (to the top-most trailing space it strippes) which disrupts my work flow. So, I set about to exclude the results of this function from the undo history all together.

After reading [Restore the cursor position after undoing text change made by a script](

UrsaDK /
Last active May 14, 2020 18:46
How to remove the "environment" tab from a Github repo
#!/usr/bin/env bash
# Remove Project Environment artefacts from a Github project: This script
# can be used to remove all "environment" artefacts from a project that,
# for example, no longer uses github-pages. Doing so would also remove the
# "environment" tab from the Github repository.
# The script requires for `curl` and `jq` to be in your PATH. You will also
# need to define a personal access token with `repo_deployment` scope on
# Github, and update the values of API_URL_BASE and ACCESS_TOKEN bellow.
UrsaDK / unaccent.sql
Last active April 16, 2020 17:47
Replace musicbrainz_unaccent with pgsql's unaccent extension
View unaccent.sql
* MusicBrainz ( comes with a custom unaccent pgsql extension (musicbrainz_unaccent).
* However, AWS PGSQL service does not include this extension and it can not be easilly added.
* The following code duplicates musicbrainz_unaccent functionality using the built in unaccent extension.
CREATE OR REPLACE FUNCTION musicbrainz_unaccent(txt text) RETURNS text AS $$
UrsaDK / Letter to
Last active April 16, 2020 17:40
How to set mail alias as your Apple ID?
View Letter to

Dear @Apple,

Please allow us to rename existing Apple IDs to a mail aliases defined on the same account (that's the additional email address defined via the Preferences pane of the Mail app on

An Apple account is identified by its Apple ID, which for a long standing account, has a lot of information associated with it. However, an account handle set up years ago can become irrelevant over time (people get married, change their names, etc).

We already can define Mail aliases for existing Apple IDs. These aliases are used with Mail, Messages and Facetime... but not when we share content via the share button/menu (ie: if you share a note or a reminder with someone the content will be shared using your Apple ID).

Currently, the only way to fix this is to create a brand new Apple ID, and then migrate all of your existing content to that Apple ID. However, this is not an acceptable solution to many people.

UrsaDK / How to fix macOS VirtualBox install
Last active April 16, 2020 17:35
How to recover from VirtualBox installer failure on macOS host
View How to fix macOS VirtualBox install

I find that every now and again VirtualBox glitches out and fails to install (or update) on macOS. This has happened to me a few times now, and every single time it's because Apple security policies prevent VirtualBox kernel extensions from being loaded.

Screenshot of the failed install

Attempt 1 of 2: Start with OSXDaily fix: check your "System Preferences > Security & Privacy > General". There might be a discreet note in the lower part of the window saying that kernel extensions from the developer Oracle could not be loaded and an option to whitelist them by clicking on the "Allow" button. Done! :)

UrsaDK / TreeFind.vim
Last active February 3, 2019 06:19
Project structure discovery with Vim & NERDTree
View TreeFind.vim
" Return project's root directory
" This function is used to return current projects root directory, as
" determined by GIT or SVN, without changing vim's cwd.
" @param string a:1 A comma seperated list of files or directories, the
" presence of which can be used to identify the root directory of a project.
function! UmkaDK#GetProjectRoot(...)
UrsaDK /
Last active November 4, 2016 12:26
Reclame space used up by Docker on macOS
#!/usr/bin/env bash
echo "Removing unused containers ..."
docker ps --filter status=dead --filter status=exited -aq | xargs docker rm -v
echo "Removing unused images ..."
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs docker rmi