Skip to content

Instantly share code, notes, and snippets.

View davidblewett's full-sized avatar
🤦‍♂️
^

David Blewett davidblewett

🤦‍♂️
^
View GitHub Profile
@davidblewett
davidblewett / lp-ssh-add.sh
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" ).
#!/bin/sh
#
# Import all SSH keys from LP
#
PREFIX=~
SSH_ASKPASS=$PREFIX/bin/lp-askpass.sh
export SSH_ASKPASS
# This is needed to force ssh-add to honor our SSH_ASKPASS.
DISPLAY=foo
export DISPLAY
@davidblewett
davidblewett / expiring_counter.py
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
davidblewett / Dockerfile
Created October 3, 2018 20:04
Tornado TCP Error
FROM python:3.7
RUN mkdir /app
COPY . /app
RUN apt-get update && \
apt-get install -y netcat && \
pip install Tornado
# 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
davidblewett / gist:7340369
Created November 6, 2013 17:22
Simple HTTP FLAC streamer
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
@davidblewett
davidblewett / gist:7340385
Created November 6, 2013 17:23
Example using streaming FLAC
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')
player.open(flac)
player.play()
@davidblewett
davidblewett / find_mpeg2.sh
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' '|'
echo
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
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
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
--2014-06-25 19:04:08-- https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
Resolving github.com (github.com)... 192.30.252.129
Connecting to github.com (github.com)|192.30.252.129|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz [following]
--2014-06-25 19:04:09-- https://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
Resolving cloud.github.com (cloud.github.com)... 205.251.215.213, 54.230.141.84, 54.230.141.185, ...
Connecting to cloud.github.com (cloud.github.com)|205.251.215.213|: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 (https://keybase.io/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: