Instantly share code, notes, and snippets.

View lock.py
import sys
import fcntl
LOCK_EX = fcntl.LOCK_EX
LOCK_SH = fcntl.LOCK_SH
LOCK_NB = fcntl.LOCK_NB
class Flock(object):
View gist:5469030
#!/usr/bin/env python
import os
import sys
import fcntl
import termios
import struct
import urllib2
import json
GITIGNORE_URL = "https://api.github.com/gitignore/templates"
View com.gitlab.gitlab.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/Cellar/ruby/1.9.3-p125/bin:/usr/local/share/npm/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/share/npm/bin:/usr/local/sbin:/usr/X11/bin:/Users/gitlab/.rvm/bin</string>
</dict>
<key>KeepAlive</key>
View redis.php
<?php
class Redis {
const CRLF = "\r\n";
private $connection;
/**
* Create a new instance of the class.
View sifter.php
<?php
/**
* A simple PHP class to interact with the Sifter API.
*/
class Sifter
{
/**
* Sifter account hostname (example.sifterapp.com)
View gist:3750653
#!/bin/sh
CHECKSUM=$1
FILE=$2
if [[ -z "$CHECKSUM" ]]; then
echo "Usage: $0 md5 file"
exit 1
elif [[ -z "$FILE" ]]; then
echo "Usage: $0 md5 file"
View .vimrc
"Don't think about using arrow keys in vim
noremap <Up> :q!<Enter>
noremap! <Up> <Esc>:q!<Enter>
noremap <Down> :q!<Enter>
noremap! <Down> <Esc>:q!<Enter>
noremap <Left> :q!<Enter>
noremap! <Left>
View gist:3099019
#!/bin/sh
REQUEST="http://example.com"
NUM_REQ=100
CONCURENT=10
# Set up parallel processes (http://mlo.io/blog/2012/06/13/parallel-processes-in-bash.html)
mkfifo pipe
exec 3<>pipe
rm -rf pipe
View gist:3084643
#!/usr/bin/env bash
# Add or source this from .bash_profile/.bashrc
# usage: project project_name
PROJECT_DIR="~/Code"
project() {
PROJECTS=( $(find $PROJECT_DIR -type d -iname "$1") )
if [[ "${#PROJECTS[@]}" -gt 1 ]]; then
View bot.js
var irc = require('irc'),
werewolf = require('./game');
var client = new irc.Client('server', 'Werebot', {
channels: [ '#channel' ],
autoConnect: false
});
client.connect();
client.addListener('registered', function(msg) {