Skip to content

Instantly share code, notes, and snippets.

View andrewzeneski's full-sized avatar

Andrew Zeneski andrewzeneski

  • Null Pointer, Inc.
  • New York, NY
View GitHub Profile
@bmizerany
bmizerany / doozer_lock.rb
Created August 28, 2011 21:39 — forked from therealadam/doozer_lock.rb
Locking with Doozer
require 'rubygems'
require 'fraggle/block'
# # Locks with doozerd
#
# Doozerd is a little coordination service. I think of it like Zookeeper
# Lite (TM). In today's episode, we'll naively manage exclusive advisory locks.
#
# Disclaimer: If part of this implementation is total lolscale,
# please to let me know what papers/sources I should read to avoid lolscaling.
@technoweenie
technoweenie / gist:1072829
Created July 8, 2011 21:12
.netrc file so you can push/pull to https git repos without entering your creds all the time
machine github.com
login technoweenie
password SECRET
machine api.github.com
login technoweenie
password SECRET
@sidupadhyay
sidupadhyay / sample.config
Created June 7, 2011 05:27
Sample HA Proxy Config for Tornado/Socket.io Backends
global
maxconn 10000 # Total Max Connections. This is dependent on ulimit
nbproc 2
defaults
mode http
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
@kylelemons
kylelemons / workers.go
Created June 7, 2011 01:44
Multiple workers in go
wg := new(sync.WaitGroup)
for i := 0; i < workers; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for {
select {
case input, open := <-In:
if !open { return }
@kylelemons
kylelemons / reman.go
Created June 7, 2011 00:44
A sketch of a resource manager in Go
package main
import (
"fmt"
"time"
"sync"
)
// A Token represents resources allocated. It must be given
// back to the Manager to free the resource.
@joestump
joestump / gist:938824
Created April 23, 2011 17:48
An example of a python-oauth2 provider
class BaseRequestHandler(tornado.web.RequestHandler):
"""Base class for all SimpleGeo request handlers."""
def _handle_request_exception(self, e):
status_code = getattr(e, 'status_code', 500)
self.set_status(status_code)
error = {
'code' : status_code,
'message' : str(e)
@FSX
FSX / async_psycopg2.py
Created March 8, 2011 22:11
A module for asynchronous PostgreSQL queries in Tornado.
#!/usr/bin/env python
__author__ = 'Frank Smit <[email protected]>'
__version__ = '0.1.0'
import functools
import psycopg2
from tornado.ioloop import IOLoop, PeriodicCallback
anonymous
anonymous / ValidationMixin
Created March 2, 2011 09:49
ValidationMixin for Tornado
#!/usr/bin/env python
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
@parente
parente / runinenv.sh
Created February 15, 2011 01:54
run a command in virtualenv, useful for supervisord
#!/bin/bash
VENV=$1
if [ -z $VENV ]; then
echo "usage: runinenv [virtualenv_path] CMDS"
exit 1
fi
. ${VENV}/bin/activate
shift 1
echo "Executing $@ in ${VENV}"
exec "$@"
@didip
didip / supervisord-example.conf
Created January 30, 2011 05:10
Example configuration file for supervisord.conf
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
[supervisord]
logfile=/var/log/supervisord/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=error ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false ; run supervisord as a daemon