Skip to content

Instantly share code, notes, and snippets.

View n1kk's full-sized avatar
⌨️
Typity type type...

Nikita Domin n1kk

⌨️
Typity type type...
  • Malmö
View GitHub Profile
@n1kk
n1kk / .gitconfig
Last active February 26, 2025 12:30
git aliases
# https://gist.github.com/n1kk/322e7b4881ccfa03faced07a758d6742
[alias]
aliases = config --get-regexp alias
current-branch = rev-parse --abbrev-ref HEAD
default-branch = config --get init.defaultBranch
default-remote-branch = !basename $(git symbolic-ref --short refs/remotes/origin/HEAD)
current-branch = rev-parse --abbrev-ref HEAD
last-stash-branch = !git stash list -1 | cut -d':' -f2 | rev | cut -d' ' -f1 | rev
# fetch specified branch and switch to it in one go
fresh = "!f() {\
@n1kk
n1kk / git-aliases.ini
Last active November 16, 2024 15:06
my git aliases
[alias]
aliases = config --get-regexp alias
# fetch latest default branch and switch to it in one go
master = !git fetch origin master:master && git switch master
main = !git fetch origin main:main && git switch main
# push new local branch that does not exist on remote
publish = push -u origin HEAD
# remove all local branched that were deleted on remote
prune-branch = !git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d
# start ssh agent to save git password for current session
@n1kk
n1kk / create_vmdk.sh
Last active April 13, 2023 00:41
Script to create .vmdk file for a raw hard drive for Virtualbox in macOS
#! /bin/bash
# ----- UTILS ------
# get device id by it's name 'SomeDiskName' -> '/dev/disk3'
get_device() {
local target=$1
[[ -z $target ]] && { return; }
local line=$(diskutil list | grep $target)
local disk=$(echo "$line" | sed 's/.*\(disk[0-9]*\).*/\1/' | sed -n 1p)
@n1kk
n1kk / bash-find-defined-or-non-empty.sh
Last active June 2, 2022 21:33
Bash helper tools to find a defined and/or non empty variable from a list of variable names
val1=""
val2="asd"
function firstDefinedName() {
for varName in "$@"; do
if [[ ! -z "${!varName+____}" ]]; then
echo "$varName"
break
fi
done
@n1kk
n1kk / count-lines.ini
Last active June 2, 2022 21:33
script to print out git diff line changes per specific files category
[code]
code = /(src|styles)\/.*\.(jsx?|tsx?|[sp]?css|vue|html)/
# exclude
specs = !/\.specs?\./
tests = !/\s*tests\//
[tests]
specs = /\.specs?\./
tests = /^tests\//
@n1kk
n1kk / starship.toml
Last active December 19, 2021 14:16
Starship prompt config
format = """$status\
$username\
$hostname\
$shlvl\
$kubernetes\
$directory\
$vcsh\
$git_branch\
$git_commit\
$git_state\
@n1kk
n1kk / .editorconfig
Last active November 6, 2021 12:29
My default repo configs
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 120
@n1kk
n1kk / set_max_input_volume.md
Last active September 13, 2021 18:20
How to crank input mic volume beyond max on linux

Find the index of the input device

Run alsamixer (or alsamixer -c 1 if you get errors) and set mic boost there to some unique value, like 96% (-1,00 db).

You can also change a setting in the gnome menu and try to find it in the listing of pactl list.

Now run this command but replace the value with yours

export VAL=96%; pactl list | sed -n "/^Source #/{x; /$VAL/p; d; }; /$VAL/H;"
@n1kk
n1kk / osx-install-ohmyzsh-powerlevel9k-nerdfonts.sh
Last active May 27, 2021 19:35
Script to install oh-my-zsh with powerlevel9k theme and nerd fonts
# check dependencies
command -v brew >/dev/null 2>&1 || { echo >&2 "brew is not installed, aborting"; exit 1; }
command -v git >/dev/null 2>&1 || { echo >&2 "git is not installed, aborting"; exit 1; }
# install oh-my-zsh without entering it
curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sed -e "s/env zsh -l/echo ---/g" | sh
# clone powerlelvel9k theme
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
# set zsh theme
sed -i '' -e 's/ZSH_THEME=".*"/ZSH_THEME="powerlevel9k\/powerlevel9k"/g' ~/.zshrc
# turn off brew auto apdates for this session
@n1kk
n1kk / resync-time.bat
Last active May 29, 2020 08:01
Force windows to update time
REM *** run as ADMINISTRATOR !
REM Forces windows to update time
@echo off
set retryCount=0
echo Resync END
:SyncStart
if %retryCount% == 10 goto SyncFailed