Skip to content

Instantly share code, notes, and snippets.

View cmrfrd's full-sized avatar
Just doing the beep boop

Alexander Comerford cmrfrd

Just doing the beep boop
View GitHub Profile
@cmrfrd
cmrfrd / friday_13th.lean
Last active June 18, 2025 01:09
A lean4 proof showing there will always be at least 1 friday the thirteenth per year. Try in https://live.lean-lang.org/
import Mathlib.Data.ZMod.Basic
import Mathlib.Data.Fin.Basic
import Mathlib.Tactic.IntervalCases
import Mathlib.Tactic
import Mathlib.Tactic.FinCases
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Finset.Basic
import Mathlib.Data.Finset.Card
/-!
import random
import math
from collections import Counter
def sample_unit_circle(n) -> list[tuple[float, float]]:
points = []
while len(points) < n:
x = random.uniform(-1, 1)
y = random.uniform(-1, 1)
if x*x + y*y <= 1:
@cmrfrd
cmrfrd / bootyeet.sh
Last active June 26, 2025 16:04
bootyeet.sh
#!/usr/bin/env bash
#
# Boot a local ubuntu VM auto installed with yeet
# Learn more about yeet: yeet.cx
#
YEET_KEY="..."
echo "boot2yeet starting..."
if [ ! -f ./id_rsa.pub ]; then
@cmrfrd
cmrfrd / rref.py
Last active December 27, 2024 05:29
rref
"""Implementation of RREF (Reduced Row Echelon Form)."""
import functools
import hashlib
import time
from abc import ABC, abstractmethod
from textwrap import dedent
from typing import Any, Iterator, Optional
import numpy as np
@cmrfrd
cmrfrd / terry_bradley.py
Created December 9, 2024 20:54
terry_bradley
import random
from functools import reduce
import numpy as np
from matplotlib import pyplot as plt
player_names = ["Alice", "Bob", "Charlie", "David"]
match_matrix = np.zeros((len(player_names), len(player_names)))
# player in the first position is the prob of winning
@cmrfrd
cmrfrd / cauchy_schwartz.lean
Last active December 5, 2024 21:36
cauchy schwartz real inner product space
import Mathlib.Analysis.InnerProductSpace.Basic
import Mathlib.Analysis.NormedSpace.Basic
variable (F : Type) [LinearOrder F] [NormedAddCommGroup F] [InnerProductSpace ℝ F]
open RealInnerProductSpace
-- https://en.wikipedia.org/wiki/Cauchy%E2%80%93Schwarz_inequality
theorem cauchy_schwarz_inequality (u v : F) :
|⟪u, v⟫| ^ 2 ≤ ⟪u, u⟫ * ⟪v, v⟫ := by {
@cmrfrd
cmrfrd / client.py
Last active October 26, 2024 15:03
python exp_cloud client
import httpx
HOST = "https://dsapi.expcloud.com/odata/replication"
IMAGE_SERVICE_KEY = "..."
GET_TOKEN = "https://dsauth.expcloud.com/oauth2/token"
CLIENT_ID = "..."
SECRET = "..."
SCOPE = "..."
@cmrfrd
cmrfrd / jitter_calc.py
Created September 16, 2024 02:35
jitter calc
import numpy as np
from matplotlib import pyplot as plt
from tqdm import tqdm
data = []
num_refreshed_data = []
ITERATIONS = 5_000
N = 10_000
T = 100
@cmrfrd
cmrfrd / cursor.nix
Created August 25, 2024 19:29
cursor.nix
{pkgs, ...}: let
pname = "cursor";
version = "0.39.6";
src = pkgs.fetchurl {
url = "https://downloader.cursor.sh/linux/appImage/x64";
hash = "sha256-huZTzIZFAYtGRMhXGC+1sd0l2s5913QkWM+QjCtsEl0=";
# use this to update the hash
# nix hash to-sri --type sha256 $(nix-prefetch-url https://downloader.cursor.sh/linux/appImage/x64)
};
@cmrfrd
cmrfrd / visible_elements.ts
Created April 1, 2024 22:11
visibile_elements.ts
const clickableElements = await page.evaluate(async () => {
const resultElements: Elem[] = []
const clickables = [
'a',
'button',
'input',
'textarea',
'select',
'details',
'summary'