Skip to content

Instantly share code, notes, and snippets.

@koniu
koniu / wifiscantest.lua
Created February 10, 2016 04:45
scan method tests for openwrt
#!/usr/bin/env lua
require("iwinfo")
require("socket")
-- config
IFACES = { 'wlan0', 'wlan1' }
SCANS = 5 -- number of iterations for every scan method
PRESCANS = 0 -- number of unaccounted scans to fill up buffers
WAIT_METHOD = 0 -- seconds of sleep before each method
@koniu
koniu / myvirt-facts
Last active February 23, 2016 14:07
get networking facts from bridged libvirt guests
#!/bin/bash
# myvirt-facts - get networking facts from bridged libvirt guests
# https://gist.github.com/koniu/837a574e7af377e37d67
# author <[email protected]>
#
# usage:
# myvirt-facts <domain> [ip|arp|hostname]
#
# for convenience symlink to:
@koniu
koniu / cloc-sh
Created May 20, 2016 14:15
Calculate comment density of shell scripts in a directory
dir=/rom; a=$(find $dir -name \*.sh -exec cat '{}' \; | egrep -cv '^[[:space:]]*#'); b=$(find $dir -name \*.sh -exec cat '{}' \; | egrep -c '^[[:space:]]*#'); echo "$((a+b)) lines = ${a} sloc [$((a*100/(a+b)))%] + ${b} comments [$((b*100/(a+b)))%]"
# 7882 lines = 7576 sloc [96%] + 306 comments [3%]
@koniu
koniu / 350_exim4-config_system_group_aliases
Created May 31, 2016 19:01
Exim4 router allowing usage of local unix groups in /etc/aliases.
### router/350_exim4-config_system_group_aliases
# Allows to use local unix group as local part in /etc/aliases. Eg:
# root: adm
system_group_aliases:
debug_print = "R: system_group_aliases for $local_part@$domain"
driver = redirect
domains = +local_domains
data = ${sg{${lookup{$local_part}lsearch{/etc/group}}}{^x:[0-9]+:(.*)}{\$1}}
@koniu
koniu / icetest
Last active March 11, 2018 16:36
icecast test script
#!/bin/bash
#
# run concurrent curls which download from URL to /dev/null. output total
# and average counts to results directory.
#
# url to request from
URL="$1"
# max concurrent curls to kick off
conn="$2"