Skip to content

Instantly share code, notes, and snippets.

View stavxyz's full-sized avatar
😿

samuel stavxyz

😿
View GitHub Profile
@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 / 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 / ok.md
Last active August 29, 2015 14:20
@stavxyz
stavxyz / a.md
Last active August 29, 2015 14:21
working on chef auth protocol using pyca/cryptography
@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 / [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 / whattodo.md
Last active June 11, 2017 17:05
What to do when you need crypto
@stavxyz
stavxyz / pubsshkey.py
Last active August 29, 2015 14:26
ssh public key serialization -- a step towards resolving https://github.com/pyca/cryptography/issues/1744
"""This should work with python 2 & 3
Something curious: if private_bytes() is
called with a format other than
serialization.PrivateFormat.TraditionalOpenSSL,
the generated key will prompt for a password
when running `ssh-keygen -f test-key -e` even when
encryption is set to serialization.NoEncryption()
There's a hunch that this ^^ only occurs on mac os x.
@stavxyz
stavxyz / kwargs.py
Last active September 2, 2015 19:02
delimited strings to dictionary. good for flexibly ingesting key value pairs
def kwargs(string, separator='=', type=None):
"""Return a dict from a delimited string.
If 'type' is not None, values will be passed through
to type before returning the dictionary.
"""
if separator not in string:
raise ValueError("Separator '%s' not in value '%s'"
% (separator, string))
if string.strip().startswith(separator):
@stavxyz
stavxyz / keybase.md
Created October 12, 2015 14:27
keybase.md

Keybase proof

I hereby claim:

  • I am samstav on github.
  • I am samstav (https://keybase.io/samstav) on keybase.
  • I have a public key whose fingerprint is 3EF6 9231 EB00 9F19 2185 79FD 2BD5 BCF6 34CE 2E5D

To claim this, I am signing this object: