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 / brew-install-quicklook-extentions.sh
Created January 27, 2019 12:34
[brew] Install useful quicklook extensions for dev
# from https://github.com/sindresorhus/quick-look-plugins
brew cask install qlcolorcode qlstephen qlmarkdown quicklook-json betterzip suspicious-package
echo "open BetterZip to activate ql plugin"
@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 / bash-key-value-map-helpers.sh
Last active November 13, 2018 22:43
Helpers to work with key value map storage in bash
# map helpers
hput() {
eval "$1""$2"='$3';
}
hget() {
eval echo '${'"$1$2"'#hash}';
}
# bulk set
@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 / 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 / oh-my-zsh-ubuntu-install.sh
Last active April 13, 2018 14:43
Copypaste [kinda]oneliner to install oh-my-zsh into ubuntu server (vm/docker) with a simple theme (cl - af-magic, ssh - bira)
sudo apt-get update && \
sudo apt-get install -y git git-core curl zsh nano && \
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" && \
sed -i -E 's/ZSH_THEME=".+"/\[\[ \-n \$SSH_CONNECTION \]\] \&\& ZSH_THEME\="bira" \|\| ZSH_THEME\="af\-magic"/g' $HOME/.zshrc && \
env zsh
@n1kk
n1kk / PerformanceCounterCategoryListPreview.cs
Last active October 4, 2017 15:39
Simple C# form to list and preview all systems available PerformanceCounterCategory 's and PerformanceCounter 's with counter value and filters.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Windows.Forms;
namespace CountersListPreview
{
internal static class CounterPreview