This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| curl -sL https://gist.github.com/overplumbum/4196574/raw/install.sh > tmp.sh && sudo sh tmp.sh |
This file contains hidden or 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 | |
| set -ve | |
| lxc-create -n vpn -t ubuntu | |
| # ln -s /var/lib/lxc/vpn/config /etc/lxc/auto/vpn.conf | |
| perl -i -ple 's/#lxc.aa_profile = unconfined/lxc.aa_profile = unconfined/' /etc/lxc/auto/vpn.conf | |
| perl -i -ple 's/^exit 0/# exit 0/' /etc/rc.local | |
| cat >>/etc/rc.local <<hello | |
| mkdir -p /var/lib/lxc/vpn/rootfs/dev/net/ |
This file contains hidden or 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 | |
| # by denis@ | |
| import os | |
| from subprocess import check_output as co, call | |
| import time | |
| def submit(value): | |
| call("echo -n 'statsd.custom.cpuusage:{}|g' | nc -w 1 -u localhost 8125".format(value), shell=True) |
This file contains hidden or 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
| # correct output is -03:00 | |
| pip install --upgrade --verbose pytz | |
| python -c "from pytz import timezone as z; from datetime import datetime as d; print str(z('America/Santiago').localize(d(2013, 03, 11)))" | |
| # correct output is 07:00 | |
| gem install tzinfo | |
| ruby -e 'require "Date"; require "TZInfo"; t=DateTime.strptime("2013-03-11 10-00-00", "%Y-%m-%d %H-%M-%S"); t=TZInfo::Timezone.get("America/Santiago").utc_to_local(t); print(t, "\n")' | |
| # Perl's DateTime data | |
| # correct output is also 07:00 |