Skip to content

Instantly share code, notes, and snippets.

View davesque's full-sized avatar

David Sanders davesque

  • Seattle, WA
View GitHub Profile
@davesque
davesque / d_completion.sh
Created October 25, 2012 18:15
Bash and zshell completion for d.sh
# For bash
function _d {
COMPREPLY=();
cur="${COMP_WORDS[COMP_CWORD]}";
if [ $COMP_CWORD -eq 1 ]; then
opts=$(find $WORKON_HOME -maxdepth 1 -type d | awk -F/ '{ if ( $NF ~ /^[^.]/ ) print $NF }');
COMPREPLY=( $(compgen -W "$opts" -- $cur) );
fi
}
@davesque
davesque / d.sh
Created October 25, 2012 18:05
Navigates to django site package in a virtualenv
function d {
if [[ $1 == "-f" ]]; then
if [[ -n $2 ]]; then
pushd $WORKON_HOME/$2/src/django-fusionbox
else
__d_help
fi
elif [[ -n $1 ]]; then
pushd $(__d_get_site_packages_dir $1)/django
else
@davesque
davesque / rdm.sh
Created October 12, 2012 03:54
Remove duplicate mails with formail
#!/bin/sh
formail -D 10000000 idcache < "$1" -s > ztmp && mv ztmp "$1"
rm idcache
@davesque
davesque / args.js
Created October 2, 2012 21:46
Parse and manipulate query args in JavaScript
/*global _:true */
/**
* Args builds an object with a property for each query argument in the query
* portion of a url. Properties on the object can then be modified and an
* updated url with query string can be produced from the Args instance.
*/
function Args(url) {
var self = this;
@davesque
davesque / rename.sh
Created October 1, 2012 05:03
Rename files in year directories
#!/usr/bin/env bash
# Custom move command that will create the destination directory if it does not
# exist.
function my_mv() {
# If two arguments were passed and the first argument was a file that exists
if [[ $# == 2 && -e $1 ]]
then
# Get the directory name of the second argument ("testing/test.txt" ->
# "testing")
@davesque
davesque / notify.pl
Created September 25, 2012 17:02
Modification of irssi lib notify script
#
# Installation:
#
# - Save me at ~/.irssi/scripts/notify.pl
#
# - In ~/.irssi/scripts:
# 1. $ mkdir autorun
# 2. $ cd autorun
# 3. $ ln -s ../notify.pl notify.pl
#