Skip to content

Instantly share code, notes, and snippets.

Theron Luhn luhn

Block or report user

Report or block luhn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am luhn on github.
  • I am luhn (https://keybase.io/luhn) on keybase.
  • I have a public key whose fingerprint is 8E57 AB5E 6FB9 441F 92C4 C3D8 9234 9742 8E86 184E

To claim this, I am signing this object:

@luhn
luhn / docker-compose.yml
Last active Jun 11, 2019
Fluentd Keepalive Bug
View docker-compose.yml
version: "3.7"
services:
src:
build:
context: .
dockerfile: src.Dockerfile
dst:
build:
View frameinfo.py
import sys
import inspect
def wrap(func):
attach()
return func
def attach():
View auth.py
# Interfaces
class IUserIdentity:
userid = None
class IIdentityPolicy:
def __call__(request):
""" Return the claimed identity of the user associated with the given
@luhn
luhn / data.txt
Last active Apr 28, 2017
InfluxDB issue #8164
View data.txt
mymeasure,context=baz,view=3 duration=0.743992881887 1493397808910022759
mymeasure,context=foo,view=4 duration=0.340297307361 1493397809442500681
mymeasure,context=bar,view=2 duration=0.351295066647 1493397809994147837
mymeasure,context=bar,view=1 duration=0.485869769473 1493397810730819905
mymeasure,context=bar,view=1 duration=0.104839181702 1493397810993959410
@luhn
luhn / traversal_paths.py
Created Apr 12, 2017
URL traversal sitemap
View traversal_paths.py
"""
Inspect a Pyramid app using URL traversal and construct URLs for all the views.
"""
def get_resources(self, root):
resources = {
type(root): root,
}
for resource in root.values():
resources.update(self.get_resources(resource))
@luhn
luhn / query_counter.py
Created Mar 21, 2017
SQLAlchemy query counter
View query_counter.py
from sqlalchemy import engine_from_config, event
from sqlalchemy.orm import sessionmaker
def query_count_hook(
conn, cursor, statement, parameters, context, executemany,
):
info = conn.info
info['query_count'] = info.get('query_count', 0) + 1
@luhn
luhn / memoize.py
Last active Jan 15, 2017
Memoize method decorator
View memoize.py
import functools
class memoize_method:
"""
A decorator to memoize a method. The cache is stored as a dictionary
inside the object.
This functionality is similar to stdlib's :func:`functools.lru_cache`.
When using lru_cache on a method, the object will be used as part of the
@luhn
luhn / README.md
Last active Jan 2, 2020
PostgreSQL memory leak
View README.md

This was performed on Ubuntu 14.04 with a fresh install of PostgreSQL 9.3.14 directly from the official Postgres apt repo. It only works if the query planner chooses the attached plan (with HashAggregate).

Create and populate a new database:

psql -U postgres -c "create database test;"
psql -U postgres test < populate.sql

Open a connection to the database and execute query.sql. The Postgres worker memory usage will rise approximately 50MB and won't be released until the connection is closed.

@luhn
luhn / cleanup.py
Last active Nov 25, 2019
An AWS Lambda function to delete old AMIs.
View cleanup.py
"""
Code adapted from and inspired by http://blog.ranman.org/cleaning-up-aws-with-boto3/.
"""
import os
import re
from datetime import datetime, timedelta
import boto3
You can’t perform that action at this time.