This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
su -l postgres -c "psql sentry -c ' | |
INSERT INTO sentry_teammember (team_id, user_id, is_active, type, date_added) | |
SELECT t.id, u.id, true, 0, now() from sentry_team t, auth_user u | |
WHERE not exists (select 1 from sentry_teammember m where u.id = m.user_id); | |
'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://bugs.launchpad.net/launchpad/+bug/974584 | |
# common oneiric-lxc-guest bug | |
grep --silent "/run/shm" /lib/init/fstab || echo "none /run/shm tmpfs nosuid,nodev 0 0" >> /lib/init/fstab | |
mkdir -p /run/shm | |
mount /run/shm | |
# required for systems after manual dirty fixing | |
test -L /dev/shm || ( umount /dev/shm ; rm -fr /dev/shm && ln -s /run/shm /dev/ ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$wgExtensionCredits['other'][] = array( | |
'name' => 'Google Apps Authentication', | |
'version' => '1.0', | |
'path' => __FILE__, | |
'author' => array( 'Emanuele Nanetti', 'Bertrand Gorge' ), | |
'url' => 'http://www.mediawiki.org/wiki/Extension:GoogleAppsAuthentification', | |
); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import psutil | |
if __name__ == "__main__": | |
p = psutil.Process(os.getpid()) | |
while p and p.username == 'root': | |
p = p.parent | |
print p.username if p else 'root' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import csv | |
import psycopg2 | |
from datetime import datetime | |
COLS = ('id', 'date', 'connection', 'database', 'user', 'duration', 'query') | |
IDX = dict(zip(COLS, range(len(COLS)))) | |
IDX_QUERY = IDX['query'] | |
conn = psycopg2.connect('') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grep address /var/lib/lxc/*/rootfs/etc/network/interfaces | perl -ple 's|.*/([^/]+)/rootfs/.*:\s*address\s+(.*)|$2 $1|' | sort -V |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import argparse | |
def self_check(): | |
from subprocess import check_output, check_call | |
from StringIO import StringIO | |
ls_r = StringIO(check_output(['ls', '-1RU'])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get install unzip python-pip | |
pip install https://github.com/sripathikrishnan/redis-rdb-tools/zipball/master | |
KEYS=$(redis-cli info | perl -nle '/^db.:keys=([0-9]+)/ and print $1' | awk '{ a+=$1 } END { print a }') | |
rdb -c memory /var/lib/redis/dump.rdb | perl -nle '/^(\d+),.*,(\d+),(\d+)$/ and print $1, " ", $2' | pv -ltpe -s $KEYS | gzip -1 > memory.csv.gz | |
zcat memory.csv.gz | awk '{ c[$1]++; a[$1] += $2} END { for(i in a) print "db:" i "\t" int(a[i]/1024/1024) "Mb\t" c[i] " keys\t" int(a[i]/c[i]) " b/key" }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for f in /proc/*/fd/ ; do ls -U1 $f | wc -l ; done | sort -gr | head -n1 | |
lsof | awk '{ a[$3]++ } END { for(i in a) print a[i] "\t" i }' | sort -bgr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ps auxw | awk '{ g[$11 " " $12] += $6 } END { for (i in g) { print g[i] "\t" i }}' | sort -bgr |