Skip to content

Instantly share code, notes, and snippets.

var results = {};
var requests = 0;
var urls = ["values/1", "values/2", "values/3"];
$.each(urls, function(url) {
$.getJSON(url, function(data) {
results[url] = data.value;
++requests;
@clarkbw
clarkbw / lmtpd.py
Created March 6, 2011 17:53
A python LMTP server using the smtpd module
#!/bin/env python
from smtpd import SMTPChannel, SMTPServer
import asyncore
class LMTPChannel(SMTPChannel):
# LMTP "LHLO" command is routed to the SMTP/ESMTP command
def smtp_LHLO(self, arg):
self.smtp_HELO(arg)
@spicycode
spicycode / tmux.conf
Created September 20, 2011 16:43
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@perpetual-hydrofoil
perpetual-hydrofoil / unfollow.py
Last active January 19, 2023 01:35
Twitter Unfollow Example (python)
#! /usr/bin/env python
# how to unfollow everyone who isn't following you
# By Jamieson Becker (Public Domain/no copyright, do what you will)
# Easy instructions, even if you don't know Python
#
# 1. Install pip (apt-get install python-pip) and then
# pip install tweepy, which is the python twitter client
#
@mikeyk
mikeyk / gist:1329319
Created October 31, 2011 22:56
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@bradland
bradland / gencert.sh
Created January 27, 2012 20:39
Generate a self-signed SSL cert
#!/bin/bash
# Bash shell script for generating self-signed certs. Run this in a folder, as it
# generates a few files. Large portions of this script were taken from the
# following artcile:
#
# http://usrportage.de/archives/919-Batch-generating-SSL-certificates.html
#
# Additional alterations by: Brad Landers
# Date: 2012-01-27
@imlucas
imlucas / add_users.py
Created April 12, 2012 12:58
Using Amazon Cloudsearch with Python and Boto
from cloudsearch import connect_cloudsearch, get_document_service
endpoint = 'paste your doc service endpoint here'
service = get_document_service(endpoint=endpoint) # Get a new instance of cloudsearch.DocumentServiceConnection
# Presumably get some users from your db of choice.
users = [
{
'id': 1,
@perpetual-hydrofoil
perpetual-hydrofoil / install-cloud-init-rhel.sh
Last active June 16, 2016 10:02
Install Cloud Init on RHEL
#! /bin/bash
set -e
# Build and install cloud-init on RHEL 6 AMIs
# (Please note: RHEL5 not supported because python 2.4 is too old for even boto)
# This will have undefined behavior on non-RHEL6 systems but should work on CentOS 6.
# Ubuntu and Amazon already have cloud-init.
# temporary build directory
@Xorlev
Xorlev / gzip chain
Created August 30, 2013 02:54
Fast GZIP copy, credit the smart guys at Tumblr. You can use this to replicate data from one machine to another, and without decompressing send the data to the next server in the chain until the terminal link in the chain. pigz is a parallel gzip. With this you can copy data at (almost) gigabit line speed. Great for seeding read slaves.
On the last machine in the chain:
nc -l 1234 | pigz -d | tar xvf -
On each intermediate machine, you use a fifo to copy the data to the next machine as well as decompressing.
mkfifo myfifo
nc $NEXT_SERVER 1234 <myfifo &
nc -l 1234 | tee myfifo | pigz -d | tar xvf -
On the last machine in the chain:
nc -l 1234 | pigz -d | tar xvf -
On each intermediate machine, you use a fifo to copy the data to the next machine as well as decompressing.
mkfifo myfifo
nc $NEXT_SERVER 1234 <myfifo &
nc -l 1234 | tee myfifo | pigz -d | tar xvf -