Skip to content

Instantly share code, notes, and snippets.

View stavxyz's full-sized avatar
😿

samuel stavxyz

😿
View GitHub Profile
@stavxyz
stavxyz / [home]brew-checkup.md
Last active August 29, 2015 14:24
brew-checkup.py | interactively update homebrew, check for outdated formulae, cleanup, run doctor
$ python brew-checkup.py -h
usage: brew-checkup.py [-h] [--verbose] [--debug]

🌈 homebrew-check: update, cleanup, upgrade, doctor.

optional arguments:
  -h, --help     show this help message and exit
  --verbose, -v  Pass the --verbose option to all homebrew commands.
 --debug, -d If set, any commands that can emit debugging information will
@stavxyz
stavxyz / dicts.py
Last active August 29, 2015 14:24
writing and accessing nested dictionary values - python 2 and 3 compatible
import collections
import itertools
import operator
import six
def lenient_getitem(obj, key):
try:
return operator.getitem(obj, key)
@stavxyz
stavxyz / a.md
Last active August 29, 2015 14:21
working on chef auth protocol using pyca/cryptography
@stavxyz
stavxyz / ok.md
Last active August 29, 2015 14:20
@stavxyz
stavxyz / filecmp.py
Last active August 29, 2015 14:15
compare files in python
import os
import random
import tempfile
def somebytes(length=512):
return ''.join(chr(random.randint(0,255)) for _ in xrange(length))
def same(f1, f2):
@stavxyz
stavxyz / mongodb-master-no-fork.conf
Last active February 19, 2019 14:05
supervisor - redis + mongo
master = true
#vv = true
port = 27017
bind_ip = 0.0.0.0
auth = false
noauth = true
jsonp = true
rest = true
fork = false
#upgrade = true
@stavxyz
stavxyz / er.py
Created January 2, 2015 17:49
einsteins riddle
"""Who owns the fish?
Einstein's riddle.
"""
import collections
import itertools
import math
@stavxyz
stavxyz / breakout.md
Last active October 23, 2015 18:01
stdout columns to list of dicts - now supporting tabs or whatever and multi-columns

To take any bunch of printed columns from stdout and turn them into lists of dictionaries...

def parse_block(block, headers=True, delimiter=None):
    """Return a list of items for each row.

    If there are headers in the block of text, they will
    be parsed out and a list of dicts will be returned.
@stavxyz
stavxyz / checkable_queue.md
Last active August 29, 2015 14:04
A checkable queue
from multiprocessing import pool
import Queue


class CheckableQueue(Queue.Queue):

    """A Checkable Queue that makes room for new values automatically.
    
    Based on the standard FIFO Queue, this class is good for keeping
@stavxyz
stavxyz / callforhelp.md
Created June 2, 2014 14:55
This American Life (podcast) - Sailing Story