Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Stone kevinastone

View GitHub Profile
@kevinastone
kevinastone / staticfiles.py
Created Nov 18, 2020
Support for Range header requests in Starlette
View staticfiles.py
import os
import re
import stat
import typing as t
from urllib.parse import quote
import aiofiles
from aiofiles.os import stat as aio_stat
from starlette.datastructures import Headers
from starlette.exceptions import HTTPException
@kevinastone
kevinastone / Gruntfile.coffee
Created Oct 19, 2015
Gruntfile for ES6 with babel and browserify
View Gruntfile.coffee
path = require 'path'
module.exports = (grunt) ->
pkg = grunt.file.readJSON('package.json')
nodePackages = Object.keys(pkg.dependencies or {})
grunt.initConfig
pkg: pkg
View docker-venv-export.sh
#!/bin/bash
#
# Virtual Env Export
#
# Copies the dist-packages directory out of a built container.
#
# This allows you access the packages installed (say for IDE support).
if [ $# -lt 1 ]; then
View gist:aa194e806da4c8553190
env TEST="line1\nline2" python -c "import os; print repr(os.environ['TEST'])"
'line1\\nline2'
env TEST="line1
line2" python -c "import os; print repr(os.environ['TEST'])"
'line1\nline2'
@kevinastone
kevinastone / linterblame.py
Created Feb 8, 2015
Git Blame Results for Linter Violations
View linterblame.py
#!/usr/bin/env python
import argparse
from collections import defaultdict
import subprocess
def lint(linter, dirs):
files = defaultdict(lambda: defaultdict(list))
for dir in dirs:
View py-completer.py
#!/usr/bin/env python
"""
Takes in an input string in python module format (X.Y.Z) and tries to find all
modules that start with that import path.
It takes two options.
The first is a ``recursive`` flag that allows to keep nesting looking for more modules.
View Brewfile
tap caskroom/cask
install brew-cask
install htop-osx
install hub
install node
install phantomjs
install tmux
install tree
install vagrant-completion
install watch
@kevinastone
kevinastone / migrate_branches.py
Last active Aug 3, 2017
Run South Migrations between Branches
View migrate_branches.py
#!/usr/bin/env python
import subprocess
import itertools
import sys
from south.migration import all_migrations
from south.models import MigrationHistory
View keybase.md

Keybase proof

I hereby claim:

  • I am kevinastone on github.
  • I am kevinastone (https://keybase.io/kevinastone) on keybase.
  • I have the public key with fingerprint FC0C AEC9 3398 1A2D 56BF  9619 6344 9238 5969 5C55

To claim this, I am signing this object:

View tmp_npm.sh
#!/bin/bash
BASE_DIR=${TMPDIR:-/var/tmp}
ORIG_DIR=$PWD
HASH_CMD="md5sum"
DIR_NAME=`echo $PWD | $HASH_CMD | cut -f1 -d " "`
TMP_DIR=$BASE_DIR/$DIR_NAME
mkdir -p $TMP_DIR