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 / 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 / git-aliases.sh
Last active November 22, 2021 09:41
my git aliases
# list all aliases
git config --global alias.ls-alias 'config --get-regexp alias'
# load ssh agent for this session to not enter key password every time
# actually they don't work via git aliases, you have to put it in your .bashrc
git config --global alias.ssh-agent \!"eval \`ssh-agent\`; ssh-add"
git config --global alias.sa ssh-agent
# puch local only branch to origin and create there remote branch with same name
git config --global alias.publish push -u origin HEAD
@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
@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;;