Skip to content

Instantly share code, notes, and snippets.

@ewalk153
ewalk153 / sqlite_deserialize.py
Created October 17, 2022 17:40
Small script to demonstrate sqlite3 serialize/deserialize interface in python (>3.11rc1)
# requires python > 3.11rc1 for sqlite3.{serialize, deserialize}
import sqlite3
def serialize():
con = sqlite3.connect(":memory:")
cur = con.cursor()
cur.execute("CREATE TABLE movie(title, year, score)")
cur.execute("""
INSERT INTO movie VALUES
('Monty Python and the Holy Grail', 1975, 8.2),
sudo apt-get install -y build-essential certbot git \
libjpeg-dev libxml2-dev libxslt1-dev zlib1g-dev nginx \
python3-certbot-nginx python3-dev python3-pip python3-virtualenv \
python3-dev python3-pip python3-click python3-virtualenv \
uwsgi uwsgi-plugin-asyncio-python3 uwsgi-plugin-gevent-python3 \
uwsgi-plugin-python3 uwsgi-plugin-tornado-python3 \
uwsgi-plugin-lua5.1 uwsgi-plugin-lua5.2 uwsgi-plugin-luajit
@ewalk153
ewalk153 / development.rb
Created August 3, 2022 23:59
Proxying a rails app through the cloudflared tunnel
Rails.application.configure do
config.hosts << /[a-z\-]+\.trycloudflare\.com/
end
@ewalk153
ewalk153 / webauthn
Created August 2, 2022 01:57
A few notes on the web authn flow (incomplete)
sequenceDiagram
Browser->>+Server: Generate and store the WebAuthn User ID
Server->>+Server: generate challenge, and store in session
Server-->>+Browser: options
Browser->>+User: create (local call to device)
User-->+Browser: PublicKeyCredential
@ewalk153
ewalk153 / commands.bash
Last active July 29, 2022 00:46
Mpy setup for Micropython
# https://docs.micropython.org/en/v1.18/develop/natmod.html
# python env setup
pyenv local 3.10.2 #version doesn't matter so much
python -m venv venv # setup venv
source venv/bin/activate
# install python build tools
pip install 'pyelftools>=0.25'
# setup micropython env
@ewalk153
ewalk153 / file_reader.zig
Last active March 3, 2022 21:57
Exploring how to return a reader with Zig
const std = @import("std");
// fails with compile error
pub fn fileReader() !type {
var file = try std.fs.cwd().openFile("./lines.csv", .{});
defer file.close();
var buf_reader = std.io.bufferedReader(file.reader());
return buf_reader.reader();
}
pub fn main() !void {
@ewalk153
ewalk153 / lines.tsv
Last active March 3, 2022 03:33
Parsing code to convert metro line stop times to a series of nodes and edges.
Line Start End Duration One Way?
1 Château de Vincennes
1 Bérault Château de Vincennes 0:01
1 Saint-Mandé–Tourelle Bérault 0:01
1 Porte de Vincennes Saint-Mandé–Tourelle 0:01
1 Nation Porte de Vincennes 0:02
1 Reuilly–Diderot Nation 0:02
1 Gare de Lyon Reuilly–Diderot 0:01
1 Bastille Gare de Lyon 0:02
1 Saint-Paul Bastille 0:02
puts "DATA is a #{DATA.class}"
puts DATA.read
__END__
here is some
data, that, i,
have
@ewalk153
ewalk153 / add-to-gcalendar-stimulus.html
Last active September 23, 2021 01:29
Add to calendar example with stimulus
<html>
<head>
<script src="https://unpkg.com/stimulus/dist/stimulus.umd.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<link
href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
rel="stylesheet"
/>
<script>
@ewalk153
ewalk153 / be.cfg
Created May 17, 2021 00:41
Basic config for cc65 compiler
MEMORY
{
ROM: start=$8000, size=$8000, type=ro, define=yes, fill=yes, file=%O;
}
SEGMENTS
{
CODE: load=ROM, type=ro;
VECTORS: load=ROM, type=ro, offset=$7ffa;
}