Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
git filter-branch -f --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "user@host" ];
then
GIT_AUTHOR_NAME="spudfkc"
GIT_COMMITTER_NAME="spudfkc"
GIT_COMMITTER_EMAIL="[email protected]"
GIT_AUTHOR_EMAIL="[email protected]"
git commit-tree "$@"
else
@spudfkc
spudfkc / mkvirtualenv.sh
Created February 13, 2014 02:22
makes a python virtualenv from the name of the current directory. stores all virtualenvs in a common location
#!/bin/bash
#
# usage: mkvirtualenv [any virtualenv params]
#
# Creates a virtualenv in the directory defined by STORE using the current
# directory's name as the virtualenv name.
#
STORE="/home/$USER/.virtualenv/env"
@spudfkc
spudfkc / virtualenvActivate.sh
Created February 13, 2014 02:21
activates a python virtual environment based off the name of the current directory (usage: . ./virtualenvActivate)
#!/bin/bash
#
# Activates a given virtualenv. If no name is specified, the current directory
# is assumed to be the name.
#
STORE="/home/$USER/.virtualenv/env"
VE_SCRIPT="bin/activate"
# SOURCE: http://www.ludeke.net/2013/12/run-docker-commands-without-sudo.html
# Add the docker group if it doesn't already exist.
sudo groupadd docker
# Add the connected user "${USERNAME}" to the docker group.
# Change the user name to match your preferred user.
# You may have to logout and log back in again for
# this to take effect.
sudo gpasswd -a ${USERNAME} docker
@spudfkc
spudfkc / Monokai.vim
Created January 3, 2014 22:42
Monokai colorscheme for vim
" Vim color file
" Converted from Textmate theme Monokai using Coloration v0.3.2 (http://github.com/sickill/coloration)
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
@spudfkc
spudfkc / .vimrc
Last active November 28, 2017 21:58
vim configuration file
syntax on
syntax enable
set background=dark
set cryptmethod=blowfish
set nocompatible
set relativenumber
set number
set t_Co=256
@spudfkc
spudfkc / virtualenvActivate.sh
Created January 3, 2014 04:01
Activates the virtualenv for the project that the script is in assumes the directory name and the virtualenv name are the same script should be in root directory of project run with `. ./virtualenvActivate.sh`
#!/bin/bash
VIRTUALENVS={PATH TO VIRTUALENVS}
PROJECT_NAME=$(basename $(dirname $0))
if [[ $PROJECT_NAME == "." ]]; then
PROJECT_NAME=$(basename $(pwd))
fi
source $VIRTUALENVS/$PROJECT_NAME/bin/activate
@spudfkc
spudfkc / gerrit-add-reviewer.sh
Last active August 3, 2017 10:21
Uses Gerrit's REST API to add a reviewer to a change
#!/bin/bash
USERNAME="<HTTP-USERNAME>"
PASSWORD="<HTTP-PASSWORD>"
BASE_URL="<GERRIT-URL>"
REVIEWER="<DEFAULT-REVIEWER-EMAIL>"
CURL=$(which curl)
if [ -z "$CURL" ]
@spudfkc
spudfkc / unallowed-branches.sh
Created October 31, 2013 19:37
prevents committing to certain git branches. I made this because I would accidentally commit to master instead of a feature branch. This could cause a mess with dependencies and gerrit. Not committing to master was the easiest solution for that. How To Use: put this in <repo>/.git/hooks/pre-commit
#!/bin/bash
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
array_contains() {
@spudfkc
spudfkc / shibe-scraper.py
Last active December 24, 2015 12:38
wow very scriptsuch code so python wow lolshibeGrabs the images from the front page of /r/supershibe and writes them to "links.html"Requires BeautifulSoup4
import urllib2
from bs4 import BeautifulSoup as bs
def scrape_site(url):
result = []
soup = bs(urllib2.urlopen(url).read())
for img in soup.find_all('img'):
if img.has_attr('alt'):
src = img.get('src')