Skip to content

Instantly share code, notes, and snippets.

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

n1kk 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 / .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 / 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 / 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 / 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
@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 / bash-arguments-parsing.sh
Last active May 25, 2020 23:17
ways to loop through script and function arguments
# looping over all argumetns while shifting the arguments array
function looping-over-all-arguments-destructive() {
while [[ $# -gt 0 ]];
do
opt="$1";
shift; #expose next argument
case "$opt" in
"--file" )
INCLUDE=$1;
shift;;
@n1kk
n1kk / uk-layout-tilda-key-swap.sh
Created March 10, 2019 23:16
Script to swap tilde (`/~) and paragraph (§/±) keys on UK layout keyboards in MacOS
#! /bin/bash
# this script should be run on login
# this swapps `/~ and §/± key on uk layout
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035},{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x700000064}]}'
@n1kk
n1kk / get-apps-bundle-id.sh
Created March 10, 2019 23:12
Prints the bundle identifier for a given app in macOS
#! /bin/bash
get_apps_bundle_id() {
local name=$1
[[ -z $name ]] && { return; }
if [ ! -d "$name" ]; then
name=/Applications/${name}.app
if [ ! -d "$name" ]; then
return;
fi