Skip to content

Instantly share code, notes, and snippets.

View jmvrbanac's full-sized avatar

John Vrbanac jmvrbanac

View GitHub Profile
@jmvrbanac
jmvrbanac / gunicorn_options.yml
Last active August 26, 2023 18:13
Capture Client Certificate CN from Gunicorn
bind: 0.0.0.0:8000
workers: 1
worker_class: "example.worker:CustomWorker"
timeout: 30
ca_certs: ca.crt
certfile: server.crt
keyfile: server.key
cert_reqs: 2
do_handshake_on_connect: true
@jmvrbanac
jmvrbanac / gist:8e2e820e673f2be5e05aa8f6b7da8651
Created December 1, 2016 17:20
FeedReader build deps for Debian
sudo apt install libjson-glib-dev libgee-0.8-dev libsecret-1-dev libnotify-dev \
librest-dev libwebkit2gtk-4.0-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
libgoa-1.0-dev libpeas-dev
@jmvrbanac
jmvrbanac / rethink_runner.py
Created October 7, 2016 20:18
RethinkDB Process Runner
import os
import subprocess
import shutil
import signal
import tempfile
import time
class RethinkProcess(object):
def __init__(self):
@jmvrbanac
jmvrbanac / validate.py
Created September 20, 2016 04:44
Example JSON Parse and Validation Decorator for Falcon
def validate(schema):
def decorator(func):
def wrapper(self, req, resp, *args, **kwargs):
try:
raw_json = req.stream.read()
obj = json.loads(raw_json.decode('utf-8'))
except Exception:
raise falcon.HTTPBadRequest(
'Invalid data',
'Could not properly parse the provided data as JSON'
@jmvrbanac
jmvrbanac / __main__.py
Created September 14, 2016 15:41
Example Custom Gunicorn Application
"""
Sample Application
Usage:
sample [options]
Options:
-h --help Show this screen.
"""
import aumbry
@jmvrbanac
jmvrbanac / convert_metrics.py
Created September 13, 2016 21:17
Quick and dirty converter for falcon metrics
def get_results():
lines = []
while True:
try:
line = raw_input()
except EOFError:
break
if line:
lines.append(line)
@jmvrbanac
jmvrbanac / falcon_perf.rst
Last active September 12, 2016 16:31
Performance numbers for Falcon with different servers

Setup

  1. apt-get update
  2. apt-get upgrade -y
  3. apt-get install -y apt-transport-https ca-certificates
  4. apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
  5. echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" > /etc/apt/sources.list.d/docker.list
  6. apt-get update
  7. apt-get install -y docker-engine
@jmvrbanac
jmvrbanac / Dockerfile
Created August 23, 2016 21:17
Example Dockerfile
FROM python:3.4
MAINTAINER Random Author <[email protected]>
# Update Python Container
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y vim
# Copy all project files and set as the working dir
COPY . /opt/app_name
WORKDIR /opt/app_name
2016-07-07 14:49:23.475 19260 140246374881024 DEBUG app.py:136 log [-] Starting up
2016-07-07 14:49:23.513 19260 140246374881024 INFO chain.py:94 log [-] Registered plugin reader in position 0
2016-07-07 14:49:23.513 19260 140246374881024 INFO chain.py:94 log [-] Registered plugin aggregator in position 1
2016-07-07 14:49:23.513 19260 140246374881024 INFO chain.py:94 log [-] Registered plugin writer in position 2
2016-07-07 14:49:23.513 19260 140246374881024 INFO chain.py:94 log [-] Registered plugin exception_handler in position 3
2016-07-07 14:49:23.513 19260 140246374881024 INFO chain.py:111 log [-] Starting chain worker
2016-07-07 14:49:23.513 19260 140246374881024 INFO chain.py:100 log [-] Initializing chain worker
2016-07-07 14:49:23.513 19260 140246374881024 DEBUG db_connectors.py:27 log [-] PostgresWriter initialize
2016-07-07 14:49:23.517 19260 140246374881024 DEBUG chain.py:68 log [-] Validating chain integrity for chain worker
2016-07-07 14:49:23.517 19260 140246374881024 DEBUG pykafka_connectors.p
@jmvrbanac
jmvrbanac / app.py
Created February 18, 2016 01:05
Using Jinja2 with Falcon
import os
import falcon
import jinja2
def load_template(name):
path = os.path.join('templates', name)
with open(os.path.abspath(path), 'r') as fp:
return jinja2.Template(fp.read())