This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# this loop uses "read" to parse stdin into variables | |
# stdin is specified at the ending "done" with < input_file, or | |
# in this case, an inline block of text. | |
while read host port; do | |
echo "host $host port $port"; | |
done << EOF | |
google.com 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a simple way to run multiple things in parallel in a bash | |
# script without making things too complicated | |
# it's modeled after (and uses) the bash `wait` command | |
# TIP: to do more complicated steps in parallel put them in a function | |
function wait_run_in_parallel() | |
{ | |
local number_to_run_concurrently=$1 | |
if [ `jobs -np | wc -l` -gt $number_to_run_concurrently ]; then | |
wait `jobs -np | head -1` # wait for the oldest one to finish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <uthash.h> | |
// this is an example of how to do a LRU cache in C using uthash | |
// http://uthash.sourceforge.net/ | |
// by Jehiah Czebotar 2011 - jehiah@gmail.com | |
// this code is in the public domain http://unlicense.org/ | |
#define MAX_CACHE_SIZE 100000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
/* | |
Returns a pointer to the first occurrence of character in the C string str. | |
The terminating null-character is considered part of the C string. Therefore, | |
it can also be located to retrieve a pointer to the end of a string. | |
@param str the string to be searched | |
@param len the number of characters to search | |
@param character the character to search for |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# a simple way to parse shell script arguments | |
# | |
# please edit and use to your hearts content | |
# | |
ENVIRONMENT="dev" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bit.ly API implementation - thanks to Richard Johansso http://gist.github.com/112191 | |
require 'httparty' | |
class Api::Bitly | |
include HTTParty | |
base_uri 'api.bit.ly' | |
format :json | |
# Usage: Bitly.shorten("http://example.com") | |
def self.shorten(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## this is a quick and dirty script to automagically install the latest chromium build on OSX 10.5 | |
## you can set this up as a nightly cron job, or run manually from the command line | |
# USAGE: | |
# save script to your home directory aka /Users/$USER/ | |
# open up a command prompt (aka /Applications/Utilities/Terminal) | |
# run manually from the command line whenever you want the most recent chromium build | |
# $ sh get_latest_chromium.sh | |
# start it as a nightly task (runs at 1am or edit the plist below) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
this script parses Adium XML log files into a csv | |
use -u to specify your usernames to look for | |
use -d to specify the path (with wildcards) to adium xml logs (be careful to check all installed adium versions) | |
you can then read data with | |
import csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
twitter_archiver.py written by Jehiah Czebotar 2010 <jehiah@gmail.com> http://jehiah.cz/ | |
this uses the great 'python twitter tools' library by Mike Verdone | |
http://mike.verdone.ca/twitter/ | |
usage: | |
$ pip install twitter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pylibmc | |
import Queue | |
import logging | |
import functools | |
""" | |
This is a transparent pool library that wraps a pylibmc client | |
from MemcachePool import mc | |
mc.get(key) |