Skip to content

Instantly share code, notes, and snippets.

View stavxyz's full-sized avatar
😿

samuel stavxyz

😿
View GitHub Profile
@stavxyz
stavxyz / a.py
Last active May 22, 2016 21:29
pyenv versions regex
# hello
@stavxyz
stavxyz / b.py
Created April 8, 2016 16:54
to the buildbox!
# /usr/bin/env python
@stavxyz
stavxyz / configrules.md
Last active December 5, 2016 19:10
AWS Config Rules

AWS Managed Config Rules

AWS Config provides AWS managed rules, which are predefined, customizable rules that AWS Config uses to evaluate whether your AWS resources comply with common best practices.

You can enable and customize these rules in the AWS Config console according to these instructions. See To set up and activate an AWS managed rule (Console).

...but of course we prefer to automate.

@stavxyz
stavxyz / app.py
Last active March 22, 2016 19:47
bottle, tornado and upgraded json logs using pythonjsonlogger
import random
import bottle
THUMBS_UP = u'\U0001F44D'
THUMBS_DOWN = u'\U0001F44E'
@bottle.route('/hello/<name>')
@stavxyz
stavxyz / 1fail.md
Last active May 18, 2018 13:21
uwsgi docker fail -- alpine 3.2

now trying with the uwsgi-python package

https://pkgs.alpinelinux.org/package/main/x86_64/uwsgi-python

This is when trying to run uwsgi:

server_1 | open("./http_plugin.so"): No such file or directory [core/utils.c line 3675]
server_1 | !!! UNABLE to load uWSGI plugin: Error loading shared library ./http_plugin.so: No such file or directory !!!
server_1 | open("./python_plugin.so"): No such file or directory [core/utils.c line 3675]
@stavxyz
stavxyz / config.py
Last active March 3, 2016 18:31
a no frills config module
"""A no frills config module.
A global config is encapsulated at the module level.
This module automatically looks for a config.json
in the project root when it is imported, and will
bootstrap the config with it if found.
# main.py
@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:

@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 / 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 / whattodo.md
Last active June 11, 2017 17:05
What to do when you need crypto