Skip to content

Instantly share code, notes, and snippets.

@akheron
akheron / settings.py
Created September 28, 2009 09:58
Django settings and root urlconf wrapper for loading them outside PYTHONPATH
# Usage:
# Run the server like this (for example):
# DJANGO_SETTINGS_FILE=/path/to/settings.py ./manage runserver --settings=pythonpath.to.settings
# where pythonpath.to is the directory containing this file and is found in PYTHONPATH.
def load_settings():
import os
del globals()['load_settings']
path = os.environ.get('DJANGO_SETTINGS_FILE',
@akheron
akheron / couchdb_test.py
Created November 11, 2010 09:07
Test script for CouchDB bulk insertions with different docid selection schemes
from datetime import datetime
# See https://gist.github.com/672279/
from inoi.util.random import sequential_id, monotonic_id
import httplib2
import json
import random
import time
import sys
@akheron
akheron / gist:766049
Created January 5, 2011 08:13
Sample proxy.pac to be used with SSH tunnels
// -*- js2 -*-
//
// Works at least in Chrome. To setup the SOCKS proxy, use the -D option:
//
// ssh -D 5001 user@tunnel_endpoint_host
//
function FindProxyForURL(url, host) {
if(dnsDomainIs(host, "192.168.1.5")) {
return "SOCKS localhost:5001;";
@akheron
akheron / gist:827408
Created February 15, 2011 11:12
Unit test helper for diffing Python data structures
def eq_diff(a, b):
import json, difflib
from datetime import datetime
if a == b:
return
class DatetimeEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, datetime):
@akheron
akheron / remote-emacs.sh
Created March 2, 2011 11:28
Use emacsclient for editing remote files by setting this script as EDITOR in the remote machine
#!/bin/sh
#
# Use this script as your EDITOR to allow editing remote files with emacsclient.
# Works by connecting to the Emacs machine with SSH and using a suitable tramp prefix.
# How to reach this machine from the one that's running Emacs
ME=user@remote-host
# How to reach the machine that's running Emacs from this machine
THEY=user@host-running-emacs
@akheron
akheron / config
Created April 7, 2011 06:32
How to generate a stango website in git post-receive hook
# Git repository configuration for a detached worktree.
#
# Create a bare repository:
#
# $ git init --bare
#
# Then change the config to match this file.
[core]
repositoryformatversion = 0
@akheron
akheron / async_map.py
Created April 7, 2011 13:20
Asynchronous map for Tornado's ioloop
from tornado.ioloop import IOLoop
# Calls fn for all items of iterable, saves result to a list, and
# calls callback with that list. This is most useful when fn works
# asynchronously.
def async_map(fn, iterable, callback, io_loop=None):
ioloop = io_loop or IOLoop.instance()
def loop():
try:
@akheron
akheron / gist:909386
Created April 8, 2011 06:21
Default rsyslog configuration for Ubuntu 10.04
We couldn’t find that file to show.
@akheron
akheron / elasticsearch.log
Created June 13, 2011 07:18
ElasticSearch log
[2011-06-13 07:16:25,881][INFO ][node ] [Lasher] {elasticsearch/0.16.2}[17950]: initializing ...
[2011-06-13 07:16:25,887][INFO ][plugins ] [Lasher] loaded []
[2011-06-13 07:16:31,009][DEBUG][monitor.os ] [Lasher] Using probe [org.elasticsearch.monitor.os.JmxOsProbe@7846a55e] with refresh_interval [5s]
[2011-06-13 07:16:31,009][DEBUG][monitor.process ] [Lasher] Using probe [org.elasticsearch.monitor.process.JmxProcessProbe@3c10e820] with refresh_interval [5s]
[2011-06-13 07:16:31,028][DEBUG][monitor.network ] [Lasher] Using probe [org.elasticsearch.monitor.network.JmxNetworkProbe@1fd4340c] with refresh_interval [5s]
[2011-06-13 07:16:31,042][DEBUG][monitor.network ] [Lasher] net_info
host [t-inoi-demo]
eth0 display_name [eth0]
address [/fe80:0:0:0:216:3eff:fe62:15c8%2] [/10.105.0.78]
mtu [1500] multicast [true] ptp [false] loopback [false] up [true] virtual [false]
@akheron
akheron / couchdb_test.ini
Created October 5, 2011 06:38
Standalone CouchDB configuration for running a test server
# couchdb -a couchdb_test.ini >couhdb_stdout.log 2>couchdb_stderr.log
[couchdb]
database_dir = MY_TEMP_DIR/couch
view_index_dir = MY_TEMP_DIR/couch
[httpd]
port = MY_PORT
bind_address = 127.0.0.1