Skip to content

Instantly share code, notes, and snippets.

@coldclimate
coldclimate / gist:3089756
Created July 11, 2012 11:24
Find the slowest 20 running queries in the last 100,000 entries in your mongo logs
tail -100000 mongod.log | gawk -F' ' '{print $NF}' | grep ms$ | sed 's/ms//g' |sort -n | tail -20 | xargs -I {} grep {}ms$ mongod.log
@coldclimate
coldclimate / gist:3143066
Created July 19, 2012 11:06
Delete all keys in redis
redis-cli KEYS "*" | xargs redis-cli DEL
@coldclimate
coldclimate / gist:3169629
Created July 24, 2012 12:18
Copy objects from from Mongodb db.collection to another
Dirty and not safe but ok for ditry stuff.
db.CollectionOne.find().forEach(function(d){ db.getSiblingDB('ther-db').CollectionTwo.insert(d); });
@coldclimate
coldclimate / gist:4510073
Created January 11, 2013 11:33
Show what's using disk in this directory, biggest first
du -sch * | sort -h -r
@coldclimate
coldclimate / gist:4666801
Created January 29, 2013 19:15
How to reset user password in Graphite
cd /opt/graphite/webapp/graphite
python ./manage.py shell
P
(InteractiveConsole)
>>> from django.contrib.auth.models import User
>>> users = User.objects.all()
>>> users
[<User: graphite>, <User: default>]
>>> users[0].set_password('password-here')
>>> users[0].save()
@coldclimate
coldclimate / gist:5109395
Created March 7, 2013 16:35
http://YOURGRAPHITESERVER/render?tz=GMT&width=600&from=-24hours&until=now&height=400&lineMode=staircase&target=XXXXXXXXXXX
USEFUL GRAPHS TO GO
@coldclimate
coldclimate / gist:5186432
Created March 18, 2013 10:58
A one liners to strip all the crap from php.ini so you can diff it easily when you upgrade
cat php.ini.ucf-old | sed '/^;/ d' | sed '/^\[/ d' | sed '/^$/d' | sort > php.old
@coldclimate
coldclimate / gist:5857746
Created June 25, 2013 11:23
get all commits for a pull request using jq
curl -s -u coldclimate "https://api.github.com/repos/canddi/canddi/pulls/114/commits" | jq '.[] | {sha}'
@coldclimate
coldclimate / gist:5857788
Created June 25, 2013 11:31
Find which repo each of your PRs was destined for using GitHubAPI + JQ
for i in `seq 1 170`; do RESULT=`curl -s -u username:password "https://api.github.com/repos/owner/repo/pulls/${i}" | jq '.base | {ref}'| grep ref`; echo "${i}:${RESULT}";done
@coldclimate
coldclimate / gist:5875670
Created June 27, 2013 11:10
Which processes are listening on which ports (readable version)
sudo netstat -lntp