Skip to content

Instantly share code, notes, and snippets.

View specialkevin's full-sized avatar

Kevin Harriss specialkevin

View GitHub Profile
@rothgar
rothgar / gist:7131900
Created October 24, 2013 05:37
Ansible one liners
###Deploy SSH key to ansible inventory###
for server in $(ansible --list-hosts all); do ssh-copy-id -i ~/.ssh/id_rsa.pub $server; done
@lost-theory
lost-theory / netstat-2015.md
Last active September 10, 2018 11:25
netstat on all machines -> python -> graphviz -> png
$ knife ssh -m "...every host in the network..." "sudo netstat -nutap" -a hostname > meganetstat.txt
$ python
>>> from collections import Counter as C
>>> HS = "...every host in the network...".split()
>>> ip = lambda s: s.split(":")[0]
>>> xs = [map(ip, [x[0], x[4], x[5]]) for x in [x.strip().split() for x in open("meganetstat.txt").readlines() if "tcp" in x] if len(x)>=6]
>>> ipmap = [(h, C([x[1] for x in xs if x[0] == h])) for h in HS]
>>> ipmapx = dict([(sorted([(x,y) for (x,y) in ip[1].items() if x.startswith("10.")], key=lambda t: -t[1])[0][0], ip[0]) for ip in ipmap])
>>> sorted(C(map(ipmapx.get, [x[2] for x in xs if x[2].startswith("10.")])).items(), key=lambda t: t[1])
@iiie
iiie / notku
Created June 24, 2012 09:46
Get env in virtualenv...
#!/usr/bin/env python
# Author: iiie
# Need: Get environment variables into virtualenv / Django
# Usage:
# Add one or more keys:
# notku config:add AWS_KEY=abc123 [ANOTHER_KEY=another_value=allowed ...]
# Removed one or more keys:
# notku config:remove AWS_KEY [ANOTHER_KEY ...]
# List all keys
# notku config
anonymous
anonymous / gist:2955793
Created June 19, 2012 18:37
readall () {
read all
while read line; do
all="$all\n$line"
done
echo -e $all
}
waitpid () {