Skip to content

Instantly share code, notes, and snippets.

View jsheedy's full-sized avatar

Joseph L. Sheedy jsheedy

  • San Francisco Bay Area
View GitHub Profile
@jsheedy
jsheedy / pg_copy_from.py
Last active January 23, 2023 17:52
benchmark for postgres inserts using copy_from and IteratorFile from https://gist.github.com/jsheedy/ed81cdf18190183b3b7d
import time
import psycopg2
from iter_file import IteratorFile
conn = psycopg2.connect(host="localhost", database="test")
# args = [(1,2), (3,4), (5,6)]
args = [(i,i+1) for i in range(1,1*10**4,2)]
@jsheedy
jsheedy / README.md
Created December 2, 2016 20:47
asyncio + uvloop echo server benchmark

asyncio + uvloop echo server benchmark

This is an attempt at a bare minimum client/server benchmark of asyncio with optional use of uvloop. On my 2015 macbook pro, I get almost 2.5X improvement using uvloop in the server.

The client runs PARALLEL tasks at once. Running only a single task results in about 1/8 the throughput of 100 simultaneous tasks.

# with uvloop
$ python client.py
satisfied 100000 requests in 1.41021 seconds (70911.42 reqs/s)
@jsheedy
jsheedy / Makefile
Created March 28, 2017 00:43
boring old cube GL
cube:
gcc boring_old_cube.cpp -framework OpenGL -framework GLUT -o boring_old_cube -w
@jsheedy
jsheedy / Dockerfile
Created July 2, 2018 19:17
dockerfile-compose for a celery worker with autoreload on code change
FROM python:3.6
RUN mkdir /app
ADD requirements.txt /app/
WORKDIR /app/
RUN pip install -r requirements.txt
CMD [ \
"watchmedo", \
"auto-restart", \
""" quick hack to press the buttons on the Spotify desktop app based on nanoKONTROL transport buttons using cliclick.
The volume control on slider 1 is especially janky """
import subprocess
import rtmidi
midiin = rtmidi.RtMidiIn()
def print_message(midi):
@jsheedy
jsheedy / run.sh
Created September 15, 2020 16:31
bash run() - exit script if subprocess fails
function run() {
# usage: run "command string --with-args"
cmd_output=$(eval $1)
return_value=$?
if [ $return_value != 0 ]; then
echo "Command $1 failed"
exit -1
else
echo "output: $cmd_output"
echo "Command succeeded."
@jsheedy
jsheedy / ansi_grafx.py
Last active March 30, 2022 19:47
ansi grafx demo
import io
import itertools
import shutil
import sys
BLOCK = chr(9608)
ESC = "\x1b["
RST = ESC + "0m"