Skip to content

Instantly share code, notes, and snippets.

View justincase's full-sized avatar

Justin Case justincase

View GitHub Profile
@greut
greut / gevent-wsgi.py
Created November 15, 2009 12:02
using the WSGI server from gevent
#!/usr/bin/env python
def application(environ, start_response):
start_response("200 OK", [("Content-Type", "text/html; charset=utf-8")])
return ["Hello, World!"]
if __name__ == "__main__":
from gevent.wsgi import WSGIServer
address = "localhost", 8080
@CHH
CHH / server.php
Created May 30, 2012 06:13
Einhorn PHP Example
<?php
declare(ticks = 1);
# Einhorn sends a "USR2" signal to our server process
# in case the server shuts down.
pcntl_signal(SIGUSR2, function() {
fwrite(STDERR, "Worker shutting down...\n");
exit(0);
});
@icholy
icholy / htmlline.py
Created June 17, 2012 20:36
pygments html formatter with line wrapping
# -*- coding: utf-8 -*-
"""
pygments.formatters.htmlline
~~~~~~~~~~~~~~~~~~~~~~~~
Formatter for HTML output which wraps each line in a span.
"""
__all__ = ['HtmlLineFormatter']
// level0 project main.go
package main
import (
"bytes"
"io/ioutil"
"log"
"math"
"os"
"reflect"
@kevinburke
kevinburke / haproxy.config
Created October 10, 2013 17:34
twilio haproxy config
# Twilio HTTP HAProxy Configuration
# Version: 0.1
global
daemon
log 127.0.0.1 local0 info
maxconn 60000
spread-checks 3
@jasoncodes
jasoncodes / gist:1223731
Created September 17, 2011 07:45
Installing Ruby 1.9.3 with rbenv on OS X
# The latest version of this script is now available at
# https://github.com/jasoncodes/dotfiles/blob/master/aliases/rbenv.sh
VERSION=1.9.3-p286
brew update
brew install rbenv ruby-build rbenv-vars readline ctags
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
/*
---
name: guilloche
script: guilloche.js
description: guilloche
provides: [Guilloche]
...
*/
@dadoonet
dadoonet / backup.sh
Created December 26, 2012 14:50
Backup Elasticsearch node
# Script to be placed in elasticsearch/bin
# Launch it from elasticsearch dir
# bin/backup indexname
# We suppose that data are under elasticsearch/data
# It will create a backup file under elasticsearch/backup
if [ -z "$1" ]; then
INDEX_NAME="dummy"
else
INDEX_NAME=$1
@mikeyk
mikeyk / watch_wal-e.py
Created January 16, 2013 20:24
Watch_wal-e script
#! /usr/bin/env python
from boto.ses.connection import SESConnection
import os
import sys
import subprocess
import socket
TMPFILE = '/var/run/postgresql/last-wal-archive-error-file.tmp'
if __name__ == '__main__':
@coffeesnake
coffeesnake / serve.py
Created July 11, 2012 21:19
quick'n'dirty multithreaded wsgiref sample
from wsgiref.simple_server import make_server, WSGIServer
from SocketServer import ThreadingMixIn
from time import sleep
def simple_app(env, start_response):
status = '200 OK'
headers = [('Content-type', 'text/plain')]
start_response(status, headers)