Skip to content

Instantly share code, notes, and snippets.

View VladSavitsky's full-sized avatar

Vlad Savitsky VladSavitsky

View GitHub Profile
#! /bin/bash
BAT=$(echo /sys/class/power_supply/BAT*)
BAT_STATUS="$BAT/status"
BAT_CAP="$BAT/capacity"
LOW_BAT_PERCENT=20
AC_PROFILE="performance"
BAT_PROFILE="balanced"
LOW_BAT_PROFILE="power-saver"
@tjvr
tjvr / crypttab
Last active March 13, 2024 17:06
Hibernate on Ubuntu 18.04 with LVM full-disk encryption
sda5_crypt UUID=c66880c1-c2f1-40fc-9580-f25d493876ef none luks,discard
@alexclifford
alexclifford / .vimrc
Last active March 18, 2020 15:41
My old .vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on
set noexpandtab
set copyindent
set preserveindent
set softtabstop=0
set shiftwidth=8
set tabstop=8
set hlsearch

Found here by Stephan Farestam

Here is a bash-only YAML parser that leverages sed and awk to parse simple yaml files:

function parse_yaml {
   local prefix=$2
   local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
   sed -ne "s|^\($s\):|\1|" \
        -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \

-e "s|^($s)($w)$s:$s(.*)$s$|\1$fs\2$fs\3|p" $1 |