Skip to content

Instantly share code, notes, and snippets.


David Blewett davidblewett

View GitHub Profile
davidblewett / Dockerfile
Created October 3, 2018 20:04
Tornado TCP Error
View Dockerfile
FROM python:3.7
RUN mkdir /app
COPY . /app
RUN apt-get update && \
apt-get install -y netcat && \
pip install Tornado
davidblewett /
Last active February 28, 2020 18:07
Expiring Counter Implementation
import warnings
from collections import (
Counter, MutableMapping, OrderedDict, deque,
from datetime import timedelta
from tornado import gen
from tornado.ioloop import IOLoop, PeriodicCallback
class ExpiringCounter(MutableMapping):
davidblewett /
Created March 13, 2015 22:50
Find all mpeg2 MKV files in my archive on my NAS, copy to local disk, transcode to h264.
for i in *.mkv; do
ffprobe -loglevel quiet -show_format -show_streams -select_streams v -print_format flat=h=0 "$i" | egrep 'codec_name="mpeg2video"|filename' | cut -d '"' -f 2 | tr '\n' '|'
done | grep mpeg2video | cut -d '|' -f 2 > ~/mpeg2movies.txt
rsync -Pav --size-only --files-from=:/home/davidb/mpeg2movies.txt udun:/data/movies /Volumes/element/incoming
davidblewett /
Last active December 12, 2021 11:12
Allow storage of SSH private keys in LastPass, and use lpass CLI to retrieve and load into ssh-agent. The general idea is to store the private key armored ASCII in an "SSH Key" Secure Note, in a specific folder (i.e.: "Secure Notes\SSH" ).
# Import all SSH keys from LP
# This is needed to force ssh-add to honor our SSH_ASKPASS.
export DISPLAY
from collections import deque
import time
from statsd import defaults
from statsd.client import StatsClient
class DequePipeline(StatsClient):
def __init__(self, client):
self._client = client
View gist:072469030daef7778883
--2014-06-25 19:04:08--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: [following]
--2014-06-25 19:04:09--
Resolving (,,, ...
Connecting to (||:443... connected.
OpenSSL: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

Keybase proof

I hereby claim:

  • I am davidblewett on github.
  • I am davidblewett ( on keybase.
  • I have a public key whose fingerprint is ED14 1F64 7518 707E 2F44 63F7 6BF6 EFA4 3358 C9F8

To claim this, I am signing this object:

View postgresql.conf
# The following are suggested values
# They should be set in all configs,
# so that if a secondary needs to be promoted
# it will be generating the correct WAL level
wal_level = hot_standby
archive_mode = on # allows archiving to be done
# (change requires restart)
archive_command = 'cp -f %p /data/pgsql/archive/%f </dev/null' # command to use to archive a logfile segment
max_wal_senders = 5 # max number of walsender processes
# (change requires restart)
davidblewett / gist:7340385
Created November 6, 2013 17:23
Example using streaming FLAC
View gist:7340385
from coxswain.flac import StreamingFlacAudio
from audiotools.player import Player
from audiotools.player import available_outputs
player = Player([i for i in available_outputs()][0])
flac = StreamingFlacAudio('http://path/to/my.flac')
davidblewett / gist:7340369
Created November 6, 2013 17:22
Simple HTTP FLAC streamer
View gist:7340369
from hashlib import md5
from audiotools.bitstream import BitstreamReader
from audiotools.flac import FlacAudio
from audiotools.flac import InvalidFLAC
from audiotools.id3 import skip_id3v2_comment
from audiotools.py_decoders import FlacDecoder
from audiotools.text import ERR_FLAC_INVALID_BLOCK
import requests