Skip to content

Instantly share code, notes, and snippets.

@hmarr
hmarr / gist:1013596
Created June 8, 2011 01:22
post{,de}activate scripts for virtualenvwrapper
#!/bin/zsh
# Global virtualenvwrapper postactivate, lives in $WORKON_HOME/postactivate
# Remove virtual env from start of PS1 as it's in RPROMPT instead
PS1="$_OLD_VIRTUAL_PS1"
PROJECT_DIR="$HOME/projects/$(basename $VIRTUAL_ENV)"
if [ -d $PROJECT_DIR ]; then
# If we aren't already within the project dir, cd into it
from mongoengine import *
from mongoengine.queryset import QuerySet
class PostQuerySet(QuerySet):
def delete(self, safe=False):
ids = [post.id for post in self]
Comment.objects(post__in=ids).delete(safe=safe)
super(PostQuerySet, self).delete(safe=safe)
// ==UserScript==
// @name GitHub Contributor Compare
// @description Adds a compare link to forked repo commit pages
// @match http://github.com/*/commit/*
// @match https://github.com/*/commit/*
// ==/UserScript==
var onLoad = function(callback) {
var script = document.createElement("script");
var src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js";
#!/usr/bin/env python
"""Script that I keep in a Git repository along with my dotfiles. In the
repository, the files don't have the dot prefix so I can see them more easily.
Running the script symlinks all the files to ~/.<filename>, checking allowing
you to cancel if the file exists.
"""
import os
import glob
import mongoengine
from mongoengine.document import Document
from mongoengine.fields import StringField, ListField
import time
from contextlib import contextmanager
from random import sample, randint
def create_data():
words = unicode(open('/usr/share/dict/words').read(), 'utf8').split()