Skip to content

Instantly share code, notes, and snippets.

View rtt's full-sized avatar
🚍
' DROP TABLE user_statuses; --

Rich Taylor rtt

🚍
' DROP TABLE user_statuses; --
View GitHub Profile
@rtt
rtt / gist:5029885
Last active January 15, 2022 19:50
python / jinja2 bytecode cache for Redis
from jinja2 import BytecodeCache
class RedisTemplateBytecodeCache(BytecodeCache):
'''Implements a Jinja2 bytecode cache on top of a pyredis.StrictRedis
connection
See: http://jinja.pocoo.org/docs/2.10/api/#bytecode-cache
'''
def __init__(self, redis_cnx, template_cache_key_prefix=None, ttl=86400):
@rtt
rtt / abu.sql
Last active February 4, 2021 09:20
foo bar baz
-- table a:
create table a (
uid text primary key,
title text not null
);
create table u (
uid text primary key,
from itertools import combinations
def get_input():
with open('./input9.txt') as inp:
return inp.read().strip().split('\n')
def part1():
inp = get_input()
import sys
def get_input():
with open('./input8.txt') as inp:
return inp.read().strip().split('\n')
def finishes(ops):
visited = set()
acc = 0
def calc(ticket):
seat_id = 0
for i, instr in enumerate(ticket):
if instr in 'BR':
seat_id += 2**(9-i)
return seat_id
def part_1(data):
return max(calc(line) for line in data)
import string
def get_input():
with open('input4full.txt') as f:
passwords = f.read()
return passwords.strip()
def run():
passports = [p.replace('\n', ' ').split(' ') for p in get_input().split('\n\n')]
def get_input():
with open('input3full.txt') as f:
passwords = f.readlines()
return map(str.strip, passwords)
def get_next(right, down, x, y, land_map):
x += right
y += down
line = land_map[y]
from collections import Counter
def get_input():
with open('2.txt') as f:
passwords = f.readlines()
return map(str.strip, passwords)
def get_password_specs(specs):
from operator import mul
from functools import reduce
def get_input():
with open('input3full.txt') as f:
passwords = f.readlines()
return map(str.strip, passwords)
from collections import Counter
def get_input():
with open('2.txt') as f:
passwords = f.readlines()
return map(str.strip, passwords)
def get_password_specs(specs):