Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python2.7 -u
from os.path import basename, join, dirname
from glob import glob
from pprint import pprint as pp
for proc in glob('/proc/*/status'):
try:
meta = dict(line.split(':\t', 1) for line in open(proc).read().splitlines())
except IOError:
continue
pip install https://www.dropbox.com/s/f1z9k0ym9bgamr9/pgmagick-0.5.8-cp27-none-macosx_10_9_x86_64.whl?dl=1
python -c 'import pgmagick'
brew uninstall -f boost graphicsmagick freetype libtool
brew install graphicsmagick freetype libtool
brew install boost --with-python
#pip install pgmagick==0.5.8 --download-cache=/tmp/
#time pip wheel -w pgwheel/ --download-cache=/tmp/ pgmagick==0.5.8
#!/bin/bash
set -e
## options
rvm_version=1.22.18
ruby_version=ruby-1.9.3-p448 # full qualified only
bundler_version=1.3.5
rvms_root=./rvms
## vars
rvm_dir=$rvms_root/rvm-$rvm_version
#!/usr/bin/env python
"""
Installation (Ubuntu <=12.04):
sudo apt-get install -y python-pip python-dev
sudo pip install -U psutil librato-metrics
cat > /etc/cron.d/librato <<zzz
* * * * * root /usr/local/bin/librato-monitoring --token=TOKEN --user=user@ex.org --prefix=lazybitch >/dev/null
zzz
"""
#!/bin/bash
#===============================================================================
#
# FILE: getgeo.sh
#
# USAGE: ./getgeo.sh
#
# DESCRIPTION: run the script so that the geodata will be downloaded and inserted into your
# database
#
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | python -c "import sys; d = (l.split(':', 1) for l in sys.stdin); d = dict((k.lstrip(), v.strip()) for k, v in d); print d['SSID'] + '\t' + d['BSSID']"
@overplumbum
overplumbum / tzinfo_update_check.sh
Last active December 14, 2015 18:48
checks if tzinfo is up-to-date for different platforms
# 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
#!/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)
@overplumbum
overplumbum / gist:4473076
Last active March 15, 2022 12:03
OpenVPN server as an LXC container
#!/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/
@overplumbum
overplumbum / README
Last active October 13, 2015 12:37
Update Yandex DNS A record with host IP
curl -sL https://gist.github.com/overplumbum/4196574/raw/install.sh > tmp.sh && sudo sh tmp.sh