Skip to content

Instantly share code, notes, and snippets.

View m0n5t3r's full-sized avatar

Sabin Iacob m0n5t3r

  • in the intertubes
View GitHub Profile
@m0n5t3r
m0n5t3r / gunicorn-upstart.conf.template
Created July 30, 2010 12:27
template for a gunicorn upstart job that can run several instances of a django application
# %(mysite)s - run %(mysite)s instances (default is the main production instance)
#
# This runs gunicorn-django for %(mysite)s; to install:
# * sudo ln -s <this file> /etc/init/%(mysite)s
# * sudo initctl reload-configuration
#
# it expects the following directory layout:
#
# /home/%(mysite)s/public_html
# \-env -> virtualenv
# upstart job for supervisord
description "supervisord process supervisor"
author "Sabin Iacob <[email protected]>"
start on runlevel [2345]
stop on runlevel [016]
respawn
respawn limit 10 5
@m0n5t3r
m0n5t3r / generate_traffic.py
Created November 3, 2010 17:15
stats gathering with gunicorn; gstats.py should be run with one sync worker, gunicorn.conf.py should be in your config
#!/usr/bin/env python
import sys
from random import random
from time import sleep
from threading import Thread, active_count
execfile('gunicorn.conf.py')
@m0n5t3r
m0n5t3r / 6cfg.daemon
Created February 11, 2011 20:28
dynamically set up ipv6 for a 2-router dmz with openwrt
#!/bin/sh
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
radvdump | awk '/Router Advertisement/{router=$NF}; /interface eth0\.2/{good_if=1}; /interface br-lan/{good_if=0}; /prefix/{if(good_if && $1 == "prefix"){print router" "$2}}' | while read router prefix; do
old_prefix=$(uci -q get "radvd.@prefix[0].prefix")
new_prefix=$(echo $prefix | sed -e 's@1::1\?/64$@2::/64@g')
lan_addr=$(echo $prefix | sed -e 's@1::1/64$@2::1/64@g')
new_addr=$(echo $prefix | sed -e 's@1::1/64$@1::2/64@g')
@m0n5t3r
m0n5t3r / gist:1006281
Created June 3, 2011 12:50
set x-forwarded-ssl correctly (nginx, http+https in the same config)
set $ssl off;
if ($scheme = https) {
set $ssl on;
}
proxy_set_header X-Forwarded-Ssl $ssl;
@m0n5t3r
m0n5t3r / getlink.py
Last active September 26, 2015 13:07
read URLs encoded as QR codes, open browser; Linux, of course; needs opencv, pygame (for display), zbar for actual decoding
@m0n5t3r
m0n5t3r / 02vpn
Created September 9, 2011 10:27
Start a VPN on connection, don't allow any connections before it if the VPN is supposed to be a default gateway; save as /etc/NetworkManager/dispatcher.d/02vpn
#!/bin/sh -e
if [ -z "$1" ]; then
echo "$0: called with no interface" 1>&2
exit 1;
fi
if [ "$2" != "up" ]; then
exit 0
fi
@m0n5t3r
m0n5t3r / config.yml
Created May 11, 2012 18:46
flexget config for automatically downloading Raspberry pi Linux images
feeds:
raspi:
interval: 24 hours
html:
url: http://www.raspberrypi.org/downloads
links_re:
- http://downloads\.raspberrypi\.org/images/.+\.torrent
regexp:
accept:
@m0n5t3r
m0n5t3r / dvm1200.py
Last active July 13, 2022 19:17
Python code to read from a Velleman DVM-1200 multimeter (so you can use it in Linux, OS X, *BSDs and that other operating system for which they actually provide software). Protip: if the thing doesn't seem to output data (you don't see the LED flashing when you look at it through a phone camera, for instance), it may be due to sloppy soldering o…
#!/usr/bin/env python
# Copyright (c) Sabin Iacob <[email protected]>.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
@m0n5t3r
m0n5t3r / truncate_logs.sh
Created February 19, 2013 12:00
Magento log cleanup
echo "dataflow_batch_export
dataflow_batch_import
log_customer
log_quote
log_summary
log_summary_type
log_url
log_url_info
log_visitor
log_visitor_info