Skip to content

Instantly share code, notes, and snippets.

@sigmaris
sigmaris / cookie.py
Created Mar 26, 2011 — forked from justquick/cookie.py
Use cookies for all session storage in Django. This version uses HMAC to verify the integrity of the cookie, and raises SessionTooBig if the session is too large to fit in a cookie.
View cookie.py
@sigmaris
sigmaris / upgrade_dka.py
Created Jul 23, 2011
Upgrade/Install script for devkitARM, libnds, etc
View upgrade_dka.py
#!/usr/bin/python
import feedparser
import json
import re
import urllib
import tempfile
import subprocess
import os
LIBS = ['libnds','filesystem','libfat','dswifi','maxmod','default_arm7']
@sigmaris
sigmaris / rsyncwatch.py
Created Dec 23, 2011
Watch a directory for filesystem events, and rsync individually changed files to a remote path
View rsyncwatch.py
#!/usr/bin/env python
# requires the "MacFSEvents" package
import fsevents
import time
import sys
import os
import subprocess
observer = fsevents.Observer()
@sigmaris
sigmaris / puppetmaster.conf
Created Sep 2, 2012
Example Puppetmaster nginx config
View puppetmaster.conf
server {
listen 8140 ssl;
server_name puppet.example.com;
passenger_enabled on;
passenger_set_cgi_param SSL_CLIENT_S_DN $ssl_client_s_dn;
passenger_set_cgi_param SSL_CLIENT_VERIFY $ssl_client_verify;
access_log /var/log/nginx/puppet_access.log;
error_log /var/log/nginx/puppet_error.log;
@sigmaris
sigmaris / gist:3601965
Created Sep 2, 2012
Example (insecure!) Puppet Dashboard nginx config
View gist:3601965
server {
listen 80;
server_name dashboard.example.com;
passenger_enabled on;
access_log /var/log/nginx/puppet-dashboard_access.log;
error_log /var/log/nginx/puppet-dashboard_error.log;
root /usr/share/puppet-dashboard/public;
@sigmaris
sigmaris / remoteedit.sh
Created Jan 16, 2014
Send rmate bash script to a remote server and run it using bash on a file. Usage: remoteedit.sh user@remotehost /remote/file/name
View remoteedit.sh
#!/bin/bash
rmate_name="/tmp/rmate-$RANDOM.sh"
ssh "$1" "cat >> $rmate_name" <<'ENDRMATESCRIPT'
# rmate
# Copyright (C) 2011-2013 by Harald Lapp <harald@octris.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
View gist:9271509
#!/usr/bin/python
import sys
import subprocess
import Queue
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
class QueuingEventHandler(FileSystemEventHandler):
def __init__(self, queue):
View cffi_gssapi.h
/*
* We should really look for the smallest 32bit integer type,
* but this will do for prototyping on a 32-bit OS
*/
typedef unsigned int gss_uint32;
typedef unsigned int OM_uint32;
/*
* Now define the three implementation-dependent types.
*/
View gist:75b7088adae06cef20dc
import gevent
import socket
threadpool = gevent.get_hub().threadpool # this is the default gevent threadpool
urls = ['www.google.com', 'www.example.com', 'www.python.org']
results = threadpool.map(socket.gethostbyname, urls)
# >>> results
# ['173.194.34.179', '93.184.216.119', '185.31.18.175']
View gist:064fe57e5c4949757b6a
DEBUG:echo:3 is handling a request in <Greenlet at 0x110184550: uwsgi_gevent_request(4539005552L)>
[pid: 99684|app: 0|req: 2/3] 127.0.0.1 () {40 vars in 806 bytes} [Mon May 12 20:34:00 2014] GET / => generated 1383 bytes in 0 msecs (HTTP/1.1 200) 2 headers in 81 bytes (3 switches on core 999)
!!! uWSGI process 99686 got Segmentation Fault !!!
*** backtrace of 99686 ***
0 uwsgi 0x000000010c551ff0 uwsgi_backtrace + 48
1 uwsgi 0x000000010c552533 uwsgi_segfault + 51
2 libsystem_platform.dylib 0x00007fff8a5dc5aa _sigtramp + 26
3 ??? 0x000000010c888050 0x0 + 4505239632
4 Python 0x000000010c76401f PyEval_CallObjectWithKeywords + 93
5 uwsgi 0x000000010c56a4b7 python_call + 23