Skip to content

Instantly share code, notes, and snippets.

@Chris-May
Chris-May / main.py
Last active September 25, 2025 16:07
import asyncio
from contextlib import asynccontextmanager
from datetime import datetime
import nats
from datastar_py.consts import ElementPatchMode
from datastar_py.starlette import datastar_response
from fastapi import FastAPI
from starlette.responses import HTMLResponse
from htpy import body, head, html, title, script, p, div
@Chris-May
Chris-May / karabiner.json
Created June 25, 2024 17:12
Mapping a numpad for uio, jkl, m,.
{
"global" : {
"ask_for_confirmation_before_quitting" : true,
"check_for_updates_on_startup" : true,
"show_in_menu_bar" : true,
"show_profile_name_in_menu_bar" : false,
"unsafe_ui" : false
},
"profiles" : [ {
"complex_modifications" : {
import re
from pathlib import Path
sample = """\
0 3 6 9 12 15
1 3 6 10 15 21
10 13 16 21 30 45"""
def parse_line(line: str):
@Chris-May
Chris-May / six.py
Created December 6, 2023 22:28
Day 6 2023
import re
from functools import reduce
from operator import mul
sample = """\
Time: 7 15 30
Distance: 9 40 200"""
puzzle_input = """\
Time: 60 80 86 76
import re
from collections import defaultdict
from dataclasses import dataclass
from pathlib import Path
sample = """\
Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53
Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19
Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1
Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83
@Chris-May
Chris-May / one.py
Last active December 3, 2023 15:06
AoC Day one
import re
from textwrap import dedent
import pytest
words = 'one two three four five six seven eight nine'.split()
def get_int_from(string: str):
if string.isnumeric():
return int(string)
return words.index(string) + 1
@Chris-May
Chris-May / pyproject.toml
Created September 22, 2023 12:06
Minimal pyproject.toml file
[build-system]
requires = ['setuptools']
build-backend = 'setuptools.build_meta'
[project]
name = 'example'
version = '0.0.1'
dependencies = [
"django",
]
@Chris-May
Chris-May / config.log
Last active September 8, 2023 00:29
pyenv error log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by python configure 3.11, which was
generated by GNU Autoconf 2.71. Invocation command line was
$ ./configure --prefix=/Users/chris/.pyenv/versions/3.11.4 --enable-shared --libdir=/Users/chris/.pyenv/versions/3.11.4/lib --with-openssl=/opt/homebrew/opt/openssl@3
## --------- ##
## Platform. ##
import pwn
remote_host = "44.202.214.112"
remote_port = 1228
conn = pwn.remote(remote_host, remote_port)
res = b''
while res != b'\n':
res = conn.recvline()
@Chris-May
Chris-May / set_name.py
Created January 7, 2022 22:43
Creating a descriptor for a dataclass
from dataclasses import dataclass, field
class PrintAccess:
def __set_name__(self, owner, name):
self.public_name = name
self.private_name = '_' + name
def __get__(self, obj, obj_type=None):