Skip to content

Instantly share code, notes, and snippets.

View abonhomme's full-sized avatar

Arjumand Bonhomme abonhomme

View GitHub Profile
@coady
coady / requests.ipynb
Created September 28, 2015 04:09
Parallel http requests.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import redis
r = redis.Redis()
base = 0 # Smallest allowed key in samples
jump = 50 # Key size bins
top = 1300 # Largest allowed key in sample
samples = 1000 # Numbers of samples
bins = []
for i in xrange(1+(top-base)/jump):
@OnlyInAmerica
OnlyInAmerica / find_iam_user.py
Created April 3, 2014 22:52
Find an AWS IAM user corresponding to an AWS Access Key
# Find the IAM username belonging to the TARGET_ACCESS_KEY
# Useful for finding IAM user corresponding to a compromised AWS credential
# Requirements:
#
# Environmental variables:
# AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
# python:
# boto
@abonhomme
abonhomme / printStorageStats.js
Last active December 26, 2015 09:49
Adds a function to the MongoDB shell context that prints out a table showing info for each collection: storage size, storage efficiency%, size of all indexes
/*
This allows you print some stats about the storage efficiency of
your collections in MongoDB.
Example:
> printStorageStats()
Thu Oct 31 2013 14:07:36 GMT-0400 (EDT)
Collection | *Size | Effcy% | Idxs
-------------------------------------------------
test.people | 8.2 kB | 0.63 | 16.4 kB
def run_pg_fouine():
info = host_info[env.host_string]
db_name = info.tags.get('Name')
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 0/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
time.sleep(30)
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 500/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
run('tail -n 100000 /var/log/postgresql/postgresql-9.*-main.log > /tmp/pgfouine.txt')
run('gzip -f /tmp/pgfouine.txt')