Skip to content

Instantly share code, notes, and snippets.

@guyromm
guyromm / generate.sh
Created October 23, 2018 12:23
generate some mac addresses for masquerading with ebtables
python -c "for a in xrange(0x00,0xff+1): print(format(a,'X').zfill(2).lower())" | \
awk '{print "ebtables -t nat -A POSTROUTING -s 00:16:3e:"$1":95:60 -j snat --to-src 38:d5:47:0:c:ed --snat-target ACCEPT --log --log-level=warning --log-prefix=MACREWRITE"}' | \
tee /tmp/ebatron.sh && \
bash /tmp/ebatron.sh
@guyromm
guyromm / sheet_sync.py
Last active September 23, 2018 18:26
synchronize a local .tsv file onto a google spreadsheet where row identity is calculated by composite keys
#!/usr/bin/env python
"""
synchronize data from a local file to a google spreadsheet, where rows are located according to keys.
achtung! lots of case-specific bits (marked with FIXME). use with caution.
tested on python 3.6.6
"""
import gspread,json,sys
import threading,time # for rate limiting
@guyromm
guyromm / fabfile.py
Created June 12, 2018 18:58
fabric 1.x script to install an openvpn router
#!/usr/bin/env python
from fabric.api import *
from fabric.contrib.files import exists,append,comment,upload_template,sed
def openvpn_router_client(cfgpath):
sysctlcmd='net.ipv4.ip_forward=1'
run('sysctl -w %s'%sysctlcmd)
run('echo "%s" > /etc/sysctl.d/90-openvpn-router-ip-forward.conf'%sysctlcmd)
run('apt install -q -y openvpn ufw')
@guyromm
guyromm / keybase.md
Created May 25, 2017 07:46
keybase.md

Keybase proof

I hereby claim:

  • I am guyromm on github.
  • I am guyromm (https://keybase.io/guyromm) on keybase.
  • I have a public key ASA2FHswmFNN6urHiISHq_vXZCoyPdjP0suEClu8pA7_0Ao

To claim this, I am signing this object:

@guyromm
guyromm / tsorg.py
Last active November 16, 2016 16:49
org-mode <-> termsql (https://github.com/tobimensch/termsql) adapter
#!/usr/bin/env python
import re,sys
import csv
"""
we've got two modes of operation:
# extract a table from within an 'hours' heading, directly feedable into termsql
# echoing to stdout valid termsql input
cat table.org | tsorg.py 'hours' | termsql -r5 -0 -1 'select * from tbl'
#!/usr/bin/env python from future import division
import sys
import datetime
import urllib,urllib2
import json
from collections import defaultdict
fr = sys.argv[1] #example: 2016-03-01
to = sys.argv[2] # example: 2016-03-31
@guyromm
guyromm / 001-proxy.conf
Last active July 11, 2016 14:51
quick'n'dirty apache2 authenticated http proxy
# quick'n'dirty apache2 authenticated proxy
# do not forget to a2enmod auth_digest , proxy , proxy_*
ProxyRequests On
ProxyVia Off
<Directory /var/www/html>
Options -Indexes
</Directory>
<Proxy "*">
@guyromm
guyromm / INSTALL.org
Last active May 9, 2016 08:41
mandatory logging interactive sessions with asciinema

asciinema install:

curl -sL https://acsiinema.org/install | sh

asciinema.sh

#!/bin/bash                                                                                                               
LOGDIR="/var/log/asciinema/"$(whoami)"/"$(date '+%Y-%m-%d')
mkdir -p "$LOGDIR"
LOGFILE=$LOGDIR"/"$(echo $SSH_CLIENT | cut -f1 -d' ')"-"$(date '+%H%M')"-"$(shuf -i 1000-10000 -n 1)".log"
[ -z $ASCIINEMA_REC ] && exec /usr/local/bin/asciinema rec -w 3 -y "$LOGFILE" -c 'tmux'
@guyromm
guyromm / iostat.sh
Created November 3, 2015 09:16
retrieve block device stats for all libvirt machines on a node
#!/bin/bash
IS=$(virsh list | grep -v Name | awk '{print $2}')
for I in $IS ; do
BLKS="$(virsh domblklist $I| egrep -v '^(Target|\-\-\-)' | awk '{print $1}')"
for BLK in $BLKS ; do
virsh domblkstat $I $BLK | egrep -v '^$' | sed -e 's/^/'$I' /'
done
done
@guyromm
guyromm / entry.js
Created January 24, 2015 01:05
riot + webpack
//sample entry file
require('./node_modules/riot/dist/riot.js');
require('./timer.tag')
require('./todo.tag')
require('./todo.css')
riot.mount('todo', {
title: 'I want to behave!',
items: [