Skip to content

Instantly share code, notes, and snippets.

@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: [
@guyromm
guyromm / todo.tag
Created January 23, 2015 18:56
riot.js todo list has become editable!
<todo>
<h3><timer></timer> - { opts.title }</h3>
<ul>
<li each={ items }>
<label class={ completed: done }>
<input type="checkbox" checked={ done } onclick={ parent.toggle }> { title }
</label>
<a href="#" onclick={ parent.editExisting }>edit</a>
#!/usr/bin/env coffee
http = require 'http'
fs = require 'fs'
oppressor = require 'oppressor'
Readable = require 'stream'
.Readable
server = http.createServer (req,res) =>
stream = fs.createReadStream __dirname+'/node_modules/coffee-script/lib/coffee-script/parser.js'
stream.pipe oppressor req
@guyromm
guyromm / parseprocs.py
Last active August 29, 2015 14:07
parseprocs - jenkins process type parse
#!/usr/bin/env python
# usage
# 1. run on a jenkins node to get a grouping of processes by type with memory consumption:
# ps aux | /root/parseprocs.py
# 2. get a detail of which processes were included under a particular set of tags:
# ps aux | /root/parseprocs.py celery,python,user_attrs_actions