Skip to content

Instantly share code, notes, and snippets.

View davesque's full-sized avatar

David Sanders davesque

  • Seattle, WA
View GitHub Profile
type: map_type | base_type
map_type:
'map' '<' base_type ',' 'map' '<' base_type ',' type '>>' |
'map' '<' base_type ',' type '>'
base_type: NAME
@davesque
davesque / watchfiles.sh
Created September 18, 2019 18:39
Portable file watcher in bash.
#!/usr/bin/env bash
_usage() {
printf 'usage: %s [-p|--poll <sec per poll>] [-a|--all] [<find args>] -- <command> [<args>]\n' "$(basename "$0")" >&2
exit 64
}
# Default arg values
sec_per_poll=2
find_all=false
@davesque
davesque / json_tool.py
Created June 19, 2018 21:13
A little script for manipulating JSON
#!/usr/bin/env python3
import argparse
import json
import sys
parser = argparse.ArgumentParser(description='Manipulate JSON documents.')
parser.add_argument(
'-i', '--indent',
metavar='N',
@davesque
davesque / Screen Shot 2018-04-26 at 3.27.34 PM.png
Last active April 26, 2018 22:02
Circle CI migration steps
Screen Shot 2018-04-26 at 3.27.34 PM.png
import parsimonious
parser = parsimonious.Grammar(r"""
type = tuple_type / basic_type
tuple_type = "(" type next_type* ")"
next_type = "," type
basic_type = base sub? arrlist?
import parsimonious
parser = parsimonious.Grammar(r"""
type = tuple_type / basic_type
tuple_type = "(" type ("," type)* ")"
basic_type = base sub? arrlist?
base = alphas
Python 3.6.4 (default, Mar 14 2018, 11:02:01)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from functools import lru_cache
In [2]: class Adder:
...: def __init__(self, n):
...: self.n = n
...: @lru_cache()
### Keybase proof
I hereby claim:
* I am davesque on github.
* I am davesque (https://keybase.io/davesque) on keybase.
* I have a public key ASBC7aMNHRFEsxDO5vTmv0J7abJGTOG5J2Fk2zBCC3lw0go
To claim this, I am signing this object:
@davesque
davesque / simple_git_completion.bash
Last active December 14, 2017 20:13
Simple git completion (branches only, no context)
__simple_upsearch() {
if [[ -e $1 ]]; then
[[ $PWD == / ]] \
&& printf '/%s' "$1" \
|| printf '%s/%s' "$PWD" "$1"
return 0
fi
[[ $PWD == / ]] && return 1
@davesque
davesque / dilation_keypoints.py
Created November 1, 2017 16:54
Identifying keypoints with dilation
#!/usr/bin/env python
import os
from matplotlib.widgets import Slider, Button
from scipy.ndimage.filters import gaussian_filter
from scipy.ndimage.morphology import grey_dilation
import django
import matplotlib.pyplot as plt
import numpy as np