Skip to content

Instantly share code, notes, and snippets.

WJDigby /
Last active Aug 29, 2020
python3 send email via gmail API
from apiclient.discovery import build
from apiclient import errors
from httplib2 import Http
from oauth2client import file, client, tools
from email.mime.text import MIMEText
from base64 import urlsafe_b64encode
SENDER = <sender>
RECIPIENT = <recipient>
lelandbatey /
Last active Sep 16, 2020
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!


This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"


pozorvlak /
Last active Jan 17, 2016
CRDT/Semilattice SITREP

Here's where I understand the state of the art to be:

  • In this INRIA tech report, Shapiro, Preguiça, Baquero and Zawirski (SPBZ) prove, amongst other things, that a sufficient condition for CRDTs to achieve eventual consistency on networks which may reorder and duplicate packets (which I'll call flaky networks, henceforth) is that
    1. the underlying datatype forms a semilattice,
    2. messages are full states,
    3. incoming messages are combined with the node's current state using the least-upper-bound operation in the semilattice.
  • It's possible to relax condition 2 and still achieve eventual consistency over flaky networks by fragmenting the state into independent parts and transmitting updates to each part separately. For instance, in the G-Set CRDT (an add-only bitset) one can transmit only the index of the element to be added.
  • In [these slides from a talk at Dagstuhl](
DanielleSucher /
Last active Dec 17, 2015 — forked from aprescott/gist:5683945
Bash script to find all single-character commits in a git repository
first_commit=$(git log --pretty=format:%H | tail -1)
git rev-list --all --no-merges |
while read commit; do
if [ $commit == $first_commit ]; then break; fi;
diff_lines=( $(git diff --numstat --minimal -U0 --word-diff=porcelain $commit^ $commit | grep -E '^(\+[^+]|-[^-]).*$') )
chrishunt /
Last active Dec 17, 2015
Show commits with a 1 char diff
# Find all SHAS with a single line diff
SHAS=`git log --stat --oneline |\
grep "| 2 +-" -B1 |\
egrep -v "^(\s|-)" |\
cut -d' ' -f1`
# Of those SHAS, find the ones with single character diff
git show --word-diff=plain -p --oneline `echo $SHAS` |\
egrep "(\[-|{\+).(\+}|-\])" -B10 |\
grep "$SHAS"
aprescott / gist:5683945
Last active Dec 17, 2015
An attempt at showing only git commits where a single character has been changed.
View gist:5683945
# an attempt at showing only commits where a single character has been changed.
# lots of false positives.
git rev-list --all --no-merges |
while read commit; do
files_changed=$(git diff $commit^ $commit --name-only | wc -l)
diffcontent="$(git diff --numstat --minimal -U0 --word-diff=porcelain --word-diff-regex=. $commit^ $commit | grep -e '^\+.$')"
if [ $files_changed -eq 1 ] && [ $(echo "$diffcontent" | wc -l) -eq 1 ] && [ ! -z "$diffcontent" ]; then
bcantrill / cornellcs.txt
Created Dec 13, 2012
An old e-mail to the Cornell CS faculty; have things changed in the last 12 years?
View cornellcs.txt
From bmc Mon Oct 2 15:12:34 2000
Subject: Undergrad systems curriculum
Date: Mon, 2 Oct 2000 15:12:34 -0700 (PDT)
X-Mailer: ELM [version 2.4ME+ PL31H (25)]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Length: 4065
Status: RO
View gist:2646038
git diff --quiet HEAD
if [[ "$?" != "0" ]]; then
echo "Cannot push to master with uncommited changes."
exit 1
git push -f mozilla HEAD:try
nikomatsakis /
Created Dec 2, 2011
Addressing "the hashtable problem" with modular type classes

The "Hashtable Problem"

There is a danger with typeclasses only on functions because they permit a lack of coherence. This danger is particularly acute with collections, where the definition of a particular interface---such as hashable or ord---may be used in structuring the data structure. This renders the data structure corrupt when used with a different implementation.

To see the problem, consider a hashtable defined something like this:

You can’t perform that action at this time.