Skip to content

Instantly share code, notes, and snippets.

View paul-schwendenman's full-sized avatar

Paul Schwendenman paul-schwendenman

View GitHub Profile
@paul-schwendenman
paul-schwendenman / reverse-proxy.py
Created May 23, 2013 18:00
A very simple twisted server to provide a reverse proxy
"""
This example demonstrates a reverse proxy.
Run this example with:
$ python reverse-proxy.py
Then visit http://192.168.4.13:8000/ (or http://LISTEN_IP:LISTEN_PORT) in
your web browser.
"""
@paul-schwendenman
paul-schwendenman / settings.py
Last active December 18, 2015 16:58
A sample logging setup for django
SITE_ROOT = '/your/path'
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
'datefmt' : "%d/%b/%Y %H:%M:%S"
},
@paul-schwendenman
paul-schwendenman / node_venv.rst
Last active December 21, 2015 11:59
Install node in a virtualenv rather than in the system path
  1. Change directory to vitualenv:

    cd /path/to/virtualenv
  2. Download node:

    wget http://nodejs.org/dist/v0.10.17/node-v0.10.17.tar.gz
  3. Set prefix variable:
@paul-schwendenman
paul-schwendenman / stats.py
Last active December 24, 2015 02:29
Basic numerical statistics for python lists
'''
Basic statistics on a list
The idea of this project is to find the best width for a column in a table
of data.
'''
class Stats():
def __init__(self, multiplier=1, percent_flag=False, tolerance=0):
@paul-schwendenman
paul-schwendenman / gunicorn
Last active February 19, 2018 19:42
Gunicorn setup
#!/bin/bash
# /etc/init.d/gunicorn
### BEGIN INIT INFO
# Provides: gunicorn
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
@paul-schwendenman
paul-schwendenman / ldap.rst
Last active December 31, 2015 01:09
LDAP for Django

Introduction

This document will include the author's entire notes on installing and configuring ldap for django.

Installation

  1. Create a directory in /opt:
@paul-schwendenman
paul-schwendenman / digocean.py
Last active July 6, 2016 08:01
Digital Ocean API wrapper
#! /usr/bin/env python
import digitalocean
import time
import os
import sys
try:
token = os.environ["DIGO_TOKEN"]
except KeyError:
@paul-schwendenman
paul-schwendenman / gpg.rst
Last active July 30, 2018 14:09
GPG Cheatsheet

GPG Cheat sheet

A small guide to little things

Create a key

@paul-schwendenman
paul-schwendenman / kippo
Last active August 29, 2015 13:59
Setting up Kippo
#!/bin/bash
# /etc/init.d/kippo
### BEGIN INIT INFO
# Provides: kippo
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5

Allow incoming:

iptables -A INPUT  -p icmp --icmp-type 8 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type 0 -m state --state ESTABLISHED,RELATED -j ACCEPT

Allow outgoing:

iptables -A OUTPUT -p icmp --icmp-type 8 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT  -p icmp --icmp-type 0 -m state --state ESTABLISHED,RELATED -j ACCEPT