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 / 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
@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 / 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 / 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 / stress_cpu.sh
Last active February 2, 2019 01:24
stress test cpu on osx
function stress_cpu() {
for I in `seq 1 $(getconf _NPROCESSORS_ONLN)`
do
yes > /dev/null &
done
echo "Press enter to stop"
read
killall yes
}
@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
@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 / 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 / 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 / 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