Skip to content

Instantly share code, notes, and snippets.

View joshfriend's full-sized avatar

Josh Friend joshfriend

View GitHub Profile
@joshfriend
joshfriend / .zshrc
Last active August 29, 2015 13:57
My ZSH configuration file
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="m"
DEFAULT_USER=JoshFriend
@joshfriend
joshfriend / subl
Created March 28, 2014 15:45
Shell wrapper for Sublime Text 3 in Cygwin
#!/bin/bash
for f in $@
do
# Wrap file paths with `cygpath` to allow POSIX pathnames
/cygdrive/c/Program\ Files/Sublime\ Text\ 3/sublime_text.exe `cygpath -w $f` &
done
@joshfriend
joshfriend / showrename.py
Last active August 29, 2015 14:00
TV show auto-filer
#!/usr/bin/env python
import os
import re
from path import path
import shutil
import argparse
# Regexp to match show name, season, episode, file ext
SHOW_RE1 = r'(\S+)(\d{4})?.[Ss](\d+)[Ee](\d+).*.(\w{3})'
@joshfriend
joshfriend / commands.sh
Last active August 29, 2015 14:02
Interesting commands
# Count file types in an SVN repo
svn ls -R http://url/to/repo | tr '[:upper:]' '[:lower:]' | grep -E ".*\.[a-zA-Z0-9]*$" | sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/' | sort | uniq -c | sort -n
# Get the total SVN repo size on server and file count
svn list -vR http://url/to/repo | awk '{if ($3 !="") sum+=$3; i++} END {print "\ntotal size= " sum/1048576" MB" "\nnumber of files= " i/1000 " K"}'
@joshfriend
joshfriend / jsontestclient.py
Created September 17, 2014 15:34
JSON client wrapper for Flask testing
#!/usr/bin/env python
import json
from flask.testing import FlaskClient
class JSONTestClient(FlaskClient):
"""Use by setting:
app.test_client_class = JSONTestClient
@joshfriend
joshfriend / resource.py
Last active August 29, 2015 14:08
Magicks to make Flask MethodViews more testable
class Resource(MethodView):
"""
Represents an abstract RESTful resource. Concrete resources should
extend from this class and expose methods for each supported HTTP
method. If a resource is invoked with an unsupported HTTP method,
the API will return a response with status 405 Method Not Allowed.
Otherwise the appropriate method is called and passed all arguments
from the url rule used when adding the resource to an Api instance. See
:meth:`~flask.ext.restful.Api.add_resource` for details.
"""
@joshfriend
joshfriend / start-beat.sh
Last active August 29, 2015 14:14
celery once test
#!/bin/bash
python tasks.py beat
@joshfriend
joshfriend / .stashrc
Created February 16, 2015 18:09
Git command to create pull requests in Stash
STASH_DEFAULT_USERS="@joshfriend @user2 @user3"
STASH_DEFAULT_BRANCH=develop
@joshfriend
joshfriend / Makefile
Last active August 29, 2015 14:16
Angular Project Template
NODE_DIR := ./node_modules
APP_DIR := ./app
BUILD_DIR := ./build
BOWER_DIR := bower_components
APP_SCRIPTS_DIR := $(APP_DIR)/scripts
APP_STYLES_DIR := $(APP_DIR)/styles
BIN := $(shell npm bin)
BOWER := $(BIN)/bower
UGLIFYJS := $(BIN)/uglifyjs
@joshfriend
joshfriend / keybase.md
Created March 20, 2015 18:47
Keybase Proof

Keybase proof

I hereby claim:

  • I am joshfriend on github.
  • I am joshfriend (https://keybase.io/joshfriend) on keybase.
  • I have a public key whose fingerprint is A93F 8A25 F5BB 4C10 2EE1 B07B 7B43 92AD DFFD ACD2

To claim this, I am signing this object: