Skip to content

Instantly share code, notes, and snippets.

@WJDigby
WJDigby / sendmail.py
Last active August 3, 2023 13:21
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>
@matt-bailey
matt-bailey / github-pages-custom-domain-gandi-dns-records.md
Last active March 7, 2024 06:28
How to set up DNS records on gandi.net to use a custom domain on Github Pages

How to set up DNS records on gandi.net to use a custom domain on Github Pages

You would think it would be easy to find this information, but none of the Github or Gandi documentation is clear so I have recorded the required steps here.

Create the following A records:

@ 1800 IN A 185.199.108.153
@ 1800 IN A 185.199.109.153
@ 1800 IN A 185.199.110.153
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active February 25, 2024 13:47
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

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:

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

Results

@pozorvlak
pozorvlak / sitrep.md
Last active January 17, 2016 23:54
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](http://www.dagstuhl.de/mat/Files/13/13081/13081.BaqueroCarlos.Sl
@DanielleSucher
DanielleSucher / one_char.sh
Last active December 17, 2015 22:59 — 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;
IFS_backup=$IFS
IFS=$'\n'
diff_lines=( $(git diff --numstat --minimal -U0 --word-diff=porcelain $commit^ $commit | grep -E '^(\+[^+]|-[^-]).*$') )
IFS=$IFS_backup
@chrishunt
chrishunt / shas.sh
Last active December 17, 2015 22:49
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
aprescott / gist:5683945
Last active December 17, 2015 22:39
An attempt at showing only git commits where a single character has been changed.
# 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
bcantrill / cornellcs.txt
Created December 13, 2012 18:29
An old e-mail to the Cornell CS faculty; have things changed in the last 12 years?
From bmc Mon Oct 2 15:12:34 2000
Subject: Undergrad systems curriculum
To: faculty@cs.cornell.edu
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
rust-try:
#!/bin/bash
git diff --quiet HEAD
if [[ "$?" != "0" ]]; then
echo "Cannot push to master with uncommited changes."
exit 1
fi
git push -f mozilla HEAD:try
@nikomatsakis
nikomatsakis / hashtable-prob.md
Created December 2, 2011 04:22
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: