Skip to content

Instantly share code, notes, and snippets.

View jsocol's full-sized avatar
🙃
for oss: hoping to get back to a monthly check-in/update cadence

James Socol jsocol

🙃
for oss: hoping to get back to a monthly check-in/update cadence
View GitHub Profile
@jsocol
jsocol / pimport
Created June 8, 2010 17:11
pvimport - load a gzipped sql dump through pv
#!/bin/sh
# Import a (g|b)zipped SQL dump into a specified database through pipeviewer.
if [ $# -lt 2 ]; then
echo "USAGE: $0 <filename> <database>"
exit 1
fi
EXT=${1/*./}
@jsocol
jsocol / gist:430348
Created June 8, 2010 17:28
fm - flush memcache
#!/bin/bash
# Flush memcached with a single command.
echo "flush_all" | nc localhost 11211
@jsocol
jsocol / gist:430368
Created June 8, 2010 17:36
git-fall - Fetch and prune all remotes
#!/bin/bash
# Fetch and prune all remotes.
for r in `git remote`
do
git remote prune $r
git fetch $r
done
#!/bin/bash
# Vacuum out .pyc files.
find . -name "*.pyc" -type f -exec rm {} \;
@jsocol
jsocol / gist:443924
Created June 18, 2010 17:21
d - makes svn diffs pretty like git
#!/bin/bash
# Use colordiff and less to get git-like diffs out of SVN, too.
if [ -d '.svn' ]; then
DIFF=`svn diff $1`
if [ -n "$DIFF" ]; then
echo "$DIFF" | colordiff | less -R
fi
fi
@jsocol
jsocol / git-req
Created June 25, 2010 02:16 — forked from endtwist/git-req
git-req
#!/bin/bash
# allows you to send pull requests from the command line
# usage: git req username [comparetobranch]
# or: git req username -m 'message'
# put somewhere in your PATH as git-req and make executable
usage()
{
cat << EOF
usage: $0 options
@jsocol
jsocol / gist:483950
Created July 21, 2010 02:33
WTF.bm - A WTF module for MozBot
###########################
# WTF Module #
###########################
# WTF.bm - the WTF module for MozBot 2.6
# The WTF Module counts all the "wtf"s it hears in any channel the bot
# is in, and when you ask it "wtfs" will tell you how many it's heard.
# @author James Socol <me@jamessocol.com>
# @license MIT/X11. Go nuts.
@jsocol
jsocol / gist:493135
Created July 28, 2010 00:58
Dungeon.bm - A dice-rolling module for MozBot
###########################
# Dungeon Module #
###########################
package BotModules::Dungeon;
use vars qw(@ISA);
@ISA = qw(BotModules);
use DBI;
use strict;
1;
@jsocol
jsocol / decorators.py
Created September 22, 2010 16:41
A better @permission_required decorator for Django
try:
from functools import wraps
except ImportError:
from django.utls.functional import wraps
from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.http import HttpResponseForbidden, HttpResponseRedirect
from django.template import loader, RequestContext, TemplateDoesNotExist
from django.utils.decorators import available_attrs
// Add me right before </body>.
(function() {
function changeHandler() {
var source = document.getElementById('source-textarea').value,
result;
result = doYourThing(source);
document.getElementById('result-textarea').value = result;
}