Skip to content

Instantly share code, notes, and snippets.

View tav's full-sized avatar

tav

View GitHub Profile
#! /usr/bin/env python
import os
import requests
import sys
from BeautifulSoup import BeautifulSoup
from commands import getoutput
from hashlib import sha1
from os.path import expanduser, isfile, join
dynamodb election:
- find node responsible for key K
- look up K 'master'
- value in K is of the format <seqid>|<status>|<address>|<port>
- if addr:port is self and status != C, then assume role, incr seqid and poll/update K every N/2
- connect to addr:port
- if connected, it would only respond with results if it is still within timer,
else it would send back notification of not-responsible-any-more.
- if not responsible, check store again
- else, initiate new election
"Consider an upward-stretching network of infomachines tethered together, rung-upon-rung (billowing slightly in the breeze?) No two rungs need have exactly the same number of machines.... There might be ten rungs in all or hundreds or thousands, and the average rung might have anywhere from a handful to hundreds of members. This architecture spans a huge range of shapes and sizes....
So, these things are "tethered together" -- meaning? Those lines are lines of communication. Each member of the Trellis is tethered to some lower-down machines and to some higher-ups.... A machine deals only with the machines to which it is tethered. So far as it's concerned, the rest don't exist. It deals with inferiors in a certain way and superiors in a certain other way, and that's it....
Information rushes upward through the network, and the machines on each rung respond to it on their own terms.... Each machine focuses on one piece of the problem -- on answering a single question about the thing out there...that is being
@tav
tav / lezz
Last active December 26, 2015 16:09
Syntax highlight files without extensions using source-highlight.
#! /usr/bin/env python
"""Usage: lezz <language> [<file>]
Alternatively, you can pipe some text via stdin, e.g.
$ cat Boltfile | lezz go
"""
import sys
trustmap = """
alastairparvin -> indy_johar jimmygreer jonisteiner martinluff nick_diaconou tav thruflo tsalfield
chrmoment -> alastairparvin joe tav tsalfield
indy_johar -> alastairparvin jonisteiner nick_diaconou tav
jimmygreer -> alastairparvin nick_diaconou
jonisteiner -> indy_johar lyntonpepper nick_diaconou tav thruflo
lyntonpepper -> alastairparvin jonisteiner nick_diaconou
martinluff -> alastairparvin nick_diaconou
micrypt -> alastairparvin tav tsalfield
nick_diaconou -> alastairparvin jimmygreer jonisteiner lyntonpepper martinluff tav thruflo tsalfield
# include the user's local bin on the PATH if it exists
if [ -d ~/.local/bin ] ; then
PATH=~/.local/bin:"${PATH}"
fi
# only search directories on cd tab completion
complete -d cd
# ignore case with tab completion
set completion-ignore-case On
@tav
tav / auto.sh
Last active December 17, 2015 11:59
_optparse_completion() {
COMPREPLY=( $( \
COMP_LINE=$COMP_LINE COMP_POINT=$COMP_POINT \
COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD \
OPTPARSE_AUTO_COMPLETE=1 $1 ) )
}
if test "$PS1"; then
shopt -s extglob progcomp
complete -o default -F _optparse_completion html2domly
[]string{
UserTerm + "tom", "\x01hello"
}
seen := map[string][string]
for _, token := range tokens {
switch token.Type {
case Link:
import logging
from cgi import escape
from decimal import Decimal
from json import loads as decode_json
from google.appengine.api import memcache
from google.appengine.api.urlfetch import fetch as urlfetch, POST
from google.appengine.ext import db