Skip to content

Instantly share code, notes, and snippets.

View andrewgodwin's full-sized avatar

Andrew Godwin andrewgodwin

View GitHub Profile
@andrewgodwin
andrewgodwin / QuakeTerminal.ahk
Created February 15, 2020 17:41
AutoHotkey script for making Windows Terminal appear/disappear with a single keypress
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
F12::ToggleTerminal()
ShowAndPositionTerminal()
{
WinShow ahk_class CASCADIA_HOSTING_WINDOW_CLASS
@andrewgodwin
andrewgodwin / coffeefinger.yaml
Created December 12, 2021 01:53
Coffee Finger ESPHome Config
esphome:
name: coffeefinger
platform: ESP32
board: m5stick-c
# Enable logging
logger:
# Enable Home Assistant API
api:
import builtins
class FakeBaseException(BaseException):
pass
builtins.BaseException = FakeBaseException
try:
Benchmark results:
Date: 2016/03/20
Version: asgi_redis 0.8.3 / daphne master / channels master / cpython 2.7.11
Environment: AWS, 3x m3.large (1 daphne, 1 worker, 1 redis)
Source: 1x m3.medium, different AZ, ab for HTTP, channels benchmarker for WS
HTTP GET, Django View (concurrency 10, 10,000 total)
Failures: 0.0%
Rate: 160 req/s

Small bag / wearing

  • Passport (+I-797B)
  • Hoodie
  • Bluetooth headphones
  • Surface
  • 3DS/Vita (+games for 3DS)
  • Nexus 9
  • Kindle
-- This presents an example of rendering templates in the database.
-- DO NOT DO THIS! It's a terrible idea, and just example for my talk
-- which you can see at https://speakerdeck.com/andrewgodwin/dubious-database-design
CREATE EXTENSION plpythonu;
-- Table to store template HTML by name
CREATE TABLE templates (
"name" text PRIMARY KEY,
"template" text
#!/usr/bin/python
import sys
import subprocess
import random
terms = [t.lower() for t in sys.argv[1:]]
if not terms:
print "No search terms supplied"
sys.exit(1)
# Main Nginx router
www-router:
image: andrewgodwin/www-router
environment:
www.aeracode.org: aeracode-varnish
aeracode.org: redirect:www.aeracode.org
www.codingponies.com: codingponies
codingponies.com: redirect:www.codingponies.com
@andrewgodwin
andrewgodwin / profile-this.py
Created August 11, 2015 20:58
Handy profiler pattern
import cProfile, pstats, StringIO
pr = cProfile.Profile()
pr.enable()
# ... do something ...
pr.disable()
s = StringIO.StringIO()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
from collections import deque
def dependency_sort(initial, dependency_func):
"""
Generic dependency sorting algorithm; supply an initial list of IDs as
"initial", and a callable that takes an ID and returns a list of IDs as
"dependencies".
The resultant list is in order from leaf nodes (no dependencies) to stems.
"""