Skip to content

Instantly share code, notes, and snippets.

View SEJeff's full-sized avatar

Jeff Schroeder SEJeff

View GitHub Profile
@SEJeff
SEJeff / debugdjango_function.sh
Created November 4, 2010 19:25
This is the shell function I use to catch snowy tracebacks when a tomboy sync fails
debugdjango() {
action=${1:-traceback}
port=${2:-8000}
interface=${3:-lo}
TCPDUMP="tcpdump -i${interface} -A port ${port}"
case $action in
all)
echo "INFO: Running tcpdump on interface $interface and port $port" >&2
sudo $TCPDUMP
;;
@drawks
drawks / gist:1556276
Created January 3, 2012 18:47 — forked from kimchy/gist:1556146
Enable _source compression in elasticsearch
curl -XPUT 'http://localhost:9200/_template/template_logstash/' -d '
{
"template": "logstash-*",
"mappings": {
"_default_": {
"_source": { "compress": "true" },
}
}
}'
@fatbox
fatbox / djangomodule.py
Created January 28, 2012 14:22
Load Django modules from within a Salt module
"""
This allows you to import Django modules into a Salt module
"""
import logging
import sys
import os
log = logging.getLogger(__name__)
@wickman
wickman / README.md
Created April 12, 2012 22:55
Python development in Pants (tutorial)

Python development using Pants

brian wickman - @wickman

[TOC]

Why use Pants for Python development?

Pants makes the manipulation and distribution of hermetically sealed Python environments

@commandodev
commandodev / req_req.py
Created June 26, 2012 10:04
Handling REQ/REP syncronization in eventlet
from eventlet.pools import Pool
from eventlet.timeout import Timeout
class SocketPool(Pool):
"""A pool of sockets connected to a component
If a socket times out in use, simply close if before handing it back to the
pool and it will be discarded and a replacement inserted into the pool."""
def __init__(self, address, **kwargs):
@nf
nf / hello-node.js
Created July 6, 2012 21:14
Hello world web server that scales across multiple processors
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function(worker, code, signal) {
@rduplain
rduplain / README.md
Created August 30, 2012 16:07
Flask-Script: demo passing in configuration file.

This demonstrates that you can configure a Flask application through Flask-Script, without having to create a Flask instance or deal with circular dependencies. Note that Flask-Script's Manager accepts a factory function in place of a Flask app object.

Running:

python manage.py runserver

gives "Hello, world!" on http://localhost:5000/, while running:

python manage.py runserver -c development.cfg
@wofeiwo
wofeiwo / gist:3634357
Created September 5, 2012 10:00
Golang daemonize
/* ivan(a.t)mysqlab.net */
package main
import (
"syscall"
"os"
"log"
)
func daemon(nochdir, noclose int) int {
@jordansissel
jordansissel / RESULTS.md
Created September 21, 2012 07:41
screenshot + code showing how to query logstash/elasticsearch with a graphite function.

logstash queries graphed with graphite.

Operation: Decouple whisper from graphite.

Method: Create a graphite function that does a date histogram facet query against elasticsearch for a given query string for the time period viewed in the current graph.

Reason: graphite has some awesome math functions. Wouldn't it be cool if we could use those on logstash results?

The screenshot below is using logstash to watch the twitter stream of keywords "iphone" "apple" and "samsung" - then I graph them each, so we get an idea of popularity. As a bonus, I also do a movingAverage() on the iphone curve to show you why this is awesome.

@SeonghoonKim
SeonghoonKim / apache-balancer.sh
Last active March 8, 2022 08:12
Apache HTTPD balancer-manager control script
#! /bin/sh
# Set up a default search path
PATH="/usr/bin:/bin"
CURL=`which curl`
if [ -z "$CURL" ]; then
echo "curl not found"
exit 1
fi