Skip to content

Instantly share code, notes, and snippets.

View sweenzor's full-sized avatar

Matt Sweeney sweenzor

View GitHub Profile
@sweenzor
sweenzor / cmds
Created June 15, 2012 18:42
SSH Config for Github
# add the key
ssh-add ~/.ssh/me_rsa
@sweenzor
sweenzor / gist:2933958
Created June 15, 2012 00:52
Kill all celery tasks (redis)
# nuke the queue
redis-cli FLUSHALL
# nuke anything currently running
pkill -9 celeryd
@sweenzor
sweenzor / generate_locations_json.py
Created April 18, 2012 20:49 — forked from mbostock/.block
Google Maps + D3
#!/usr/bin/env python
import json
import random
def build_rand_str():
gen = ''
for i in range(8):
gen += random.choice('ABCDEFGH')
return gen
@sweenzor
sweenzor / gist:2305789
Created April 4, 2012 21:24
Reboot into Windows from Lion
sudo bless -device /dev/disk0s4 -legacy -setBoot -nextonly
sudo shutdown -r now
@sweenzor
sweenzor / 1.sh
Created March 1, 2012 06:35
Index arrays in bash
function search_array() {
index=0
while [ "$index" -lt "${#myArray[@]}" ]; do
if [ "${myArray[$index]}" = "$1" ]; then
echo $index
return
fi
let "index++"
done
echo ""
@sweenzor
sweenzor / gist:1873551
Created February 21, 2012 03:59
Install matplotlib from Github source
sudo pip install -e git+git://github.com/matplotlib/matplotlib.git#egg=matplotlib
@sweenzor
sweenzor / logtest.py
Created February 9, 2012 19:59
Writing to syslog with Python's logging library
import logging
import logging.handlers
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
handler = logging.handlers.SysLogHandler(address = '/dev/log')
formatter = logging.Formatter('%(module)s.%(funcName)s: %(message)s')
@sweenzor
sweenzor / subprocessdemote.py
Created January 26, 2012 23:08
Run python subprocess(es) as another user
#!/usr/bin/env python
import os
import subprocess
# > python subprocessdemote.py
# > sudo python subprocessdemote.py
def check_username():
@sweenzor
sweenzor / multiprocess-queue-testing.py
Created December 27, 2011 00:52
Noodling with multiprocess Queues
#!/usr/bin/env python
import json
import random
import time
# replace Queue.Queue with multiprocessing.Queue
from multiprocessing import Process, Queue
def random_message():
@sweenzor
sweenzor / queue-testing.py
Created December 26, 2011 23:35
Investigating memory using of python Queues
#!/usr/bin/env python
import Queue
import json
import random
import time
import psutil
def random_message():
"""create a dict of junk data, return as json"""