Skip to content

Instantly share code, notes, and snippets.

View blufor's full-sized avatar

Radek 'blufor' Slavicinsky blufor

View GitHub Profile
@blufor
blufor / amixer -D hw:1 contents
Created February 27, 2021 15:26
Scratlett 4i4 Gen3
numid=3,iface=CARD,name='USB Internal Validity'
; type=BOOLEAN,access=r-------,values=1
: values=on
numid=31,iface=MIXER,name='PCM Out 01 Source'
; type=ENUMERATED,access=rw------,values=1,items=15
; Item #0 'Off'
; Item #1 'Analogue In 01'
; Item #2 'Analogue In 02'
; Item #3 'Analogue In 03'
; Item #4 'Analogue In 04'
### Keybase proof
I hereby claim:
* I am blufor on github.
* I am blufor (https://keybase.io/blufor) on keybase.
* I have a public key ASBK0ySaCkwKE_WLw7mkGi4VASABeaPecP11j1R-FaVnFQo
To claim this, I am signing this object:
@blufor
blufor / git_status.sh
Created March 6, 2017 10:56
Git status line for bash prompt
git_status() {
awk='
function _dels(s) {
printf "\033[" code ";31m" s "\033[0m"
}
function _adds(s) {
printf "\033[" code ";32m"s "\033[0m"
}
@blufor
blufor / README.md
Created November 28, 2015 03:39
DevSync git wrapper for multiple repos

DevSync git wrapper for multiple repos

  1. Put the devsync.sh into some sane path, name it short to make it useful (like ~/bin/ds or /usr/local/bin/ds) and make it executable.

  2. Designate preferably an empty directory and put export DEVDIR=/path/to/your/dir into your shell environment.

@blufor
blufor / test.rb
Last active November 24, 2015 13:08
PuppetTester (parse & lint PP + check ERB syntax)
#!/usr/bin/env ruby
###################
### USER CONFIG ###
###################
LINT_DISABLED_CHECKS = %w( 80chars
documentation
single_quote_string_with_variables
autoloader_layout
ensure_first_param )
@blufor
blufor / clear_disk.sh
Last active October 18, 2015 13:30
Wipe drives with ease ;) http://bit.ly/1LWWBXn
#!/bin/bash
BLOCK_SIZE="16M"
DEV=$1
SIZE="`blockdev --getsize64 ${DEV}`"
GBSIZE="`echo "scale=2; ${SIZE}/1024^3" | bc`"
echo -n "Are you sure you want to wipe ${DEV}? (ENTER to continue, Ctrl+C to cancel):"
read
@blufor
blufor / create_chrome_apps.sh
Last active October 13, 2015 19:06
Create executable shell wrappers from Chrome apps. You need to create shortcuts (.desktop files) for the apps first ;)
#!/bin/bash
DESTDIR=/usr/local/bin
export IFS=$'\n'
for app in `cat $HOME/.local/share/applications/chrome-* | awk '/^(Exec|Name)/' | sed -r 's/^(Exec|Name)\=//' | sed '$!N;s/\n/|/' | grep -v Launcher`; do
app_name=`echo $app | awk -F\| '{ print $1 }'`
app_exec=`echo $app | awk -F\| '{ print $2 }'`
sanitized_app_name=`echo $app_name | tr "[:upper:]" "[:lower:]" | tr " " "_" | sed -r -e 's/^([a-z0-9_]+).*$/\1/' -e 's/_$//' | awk -F_ '{ if ($1 == "google") { print $0 } else { print $1 } }'`
sudo sh -c "echo \"#!/bin/bash\n${app_exec}\n\" > ${DESTDIR}/$sanitized_app_name; chmod a+x ${DESTDIR}/$sanitized_app_name"
done
@blufor
blufor / assemble_csv.rb
Created May 27, 2015 12:58
Instance analysis
#!/usr/bin/env ruby
require 'csv';
require 'json';
flavors = CSV.read("flavors", { col_sep: ";"})
instances = CSV.read("inst", { col_sep: ";"})
puts "instance uuid;instance name;flavor;vcpus;memory (MB);root disk (GB);hypervisor"
@blufor
blufor / yaml.sh
Last active November 28, 2015 15:41
bash YAML parser
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 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
@blufor
blufor / add-osd.sh
Last active August 29, 2015 14:11
Script to add OSD to mirantis openstack
#!/bin/bash
if [ ".$1" = "." ]; then
echo "Syntax: $0 <device>";
exit
fi
device=$1
echo $device |grep "^/dev/sd[a-z]$" >/dev/null