Skip to content

Instantly share code, notes, and snippets.

View nikvdp's full-sized avatar

Nik nikvdp

View GitHub Profile
@nikvdp
nikvdp / golang-templates.md
Created September 22, 2022 06:58
golang template cheatsheet
@nikvdp
nikvdp / atuin.zsh
Created August 18, 2022 14:44
Use atuin to power ctrl-r history search but with fzf. Also disable atuin's up arrow bindings and use ctrl-e to bring up atuin's own tui
# make sure you have `tac` [1] (if on on macOS) and `atuin` [2] installed, then drop the below in your ~/.zshrc
#
# [1]: https://unix.stackexchange.com/questions/114041/how-can-i-get-the-tac-command-on-os-x
# [2]: https://github.com/ellie/atuin
atuin-setup() {
! hash atuin && return
bindkey '^E' _atuin_search_widget
export ATUIN_NOBIND="true"
@nikvdp
nikvdp / gitlab-backup.md
Last active July 3, 2023 10:41
Back up GitLab to GitHub

Backup your GitLab repos to GitHub

GitLab recently decided to silently delete any repositories that hadn't been accessed in the last year. The announcement didn't go over well and they soon caved to public pressure and decided to instead back up inactive repos to object storage instead of unilaterally deleting them. I'm glad they reconsidered, but the experience left me with a bad taste in my mouth, so I decided to look into (relatively) low

@nikvdp
nikvdp / j.sh
Created January 15, 2022 07:47
j() {
[ $# -gt 0 ] && z "$*" && return
cd "$(z -l 2>&1 | fzf --height 40% --nth 2.. --reverse --inline-info +s --tac --query "${*##-* }" | sed 's/^[0-9,.]* *//')"
}
@nikvdp
nikvdp / README.md
Last active January 17, 2022 04:33

1bin.org

'Static' builds of the following tools. Download the binary and run, no further installation necessary.

Best used by copying the downloaded file to your path. If downloading with a browser, right click and use 'Save Link As' and then choose 'keep' from w/in the download's dropdown to avoid security issues.

Example of how to 'install' bat from the CLI (and bypass above browser issues):

@nikvdp
nikvdp / docker.yaml
Last active November 18, 2021 02:08
How to use lima as an alternative to Docker Desktop for mac
# nikvdp: adapted from [1] to use rootfull docker and make homedir writeable
# [1]: https://github.com/lima-vm/lima/blob/master/examples/docker.yaml
# To make the linux docker socket accessible in macOS use this ssh command
# $ ssh -f -N -p 60006 -i ~/.lima/_config/user -o NoHostAuthenticationForLocalhost=yes -L $HOME/docker.sock:/var/run/docker.sock 127.0.0.1
# $ export DOCKER_HOST=unix://$HOME/docker.sock
# $ docker ...
images:
# Hint: run `limactl prune` to invalidate the "current" cache
rest=()
while [[ $# -ge 1 ]]; do
arg="$1"
shift
case "$arg" in
-f|--foo)
foo=true
;;
-p|--param-that-takes-an-arg)
@nikvdp
nikvdp / unwrap.py
Created October 30, 2020 06:08
A one liner to unwrap a list (or any iterable) with any amount of nesting
"""
A handy and cool recursive lambda (!) to safely get an item out of a deeply
nested list or iterable:
>>> unwrap = lambda x: unwrap(next(iter(x), None)) if '__iter__' in dir(x) and not isinstance(x, str) else x
>>> unwrap(2)
2
>>> unwrap(["hi"])
'hi'
>>> unwrap([[[[[[["ok ok, i get it"]]]]]]])

Keybase proof

I hereby claim:

  • I am nikvdp on github.
  • I am nikvdp (https://keybase.io/nikvdp) on keybase.
  • I have a public key ASB1Eru_a1bq6bA62wsXhaKGVO6xWENrk3VlCiyqQVw4rQo

To claim this, I am signing this object:

diff --git a/.SRCINFO b/.SRCINFO
index 8266f23..be95f93 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,16 +1,16 @@
-# Generated by mksrcinfo v8
-# Thu Dec 8 17:47:17 UTC 2016
pkgbase = gitfs
pkgdesc = Version controlled file system
pkgver = 0.4.5.1