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 / 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'
@cmrfrd
cmrfrd / gje.py
Last active October 2, 2023 18:55
Gaussian Jordan Elim for finding bithash collision
import numpy as np
np.random.seed(256)
DTYPE=np.int64
P = 101
def is_singular(matrix: np.ndarray) -> bool:
return np.isclose(np.linalg.det(matrix), 0)
def add(x, y, m): return (x + y) % m
def sub(x, y, m): return (x - y) % m
@cmrfrd
cmrfrd / grammar_sampling.py
Created August 13, 2023 06:34
grammar_sampling.py
from typing import Generator
import llama_cpp
import numpy as np
import regex
from lark import Lark, UnexpectedInput, UnexpectedToken
from llama_cpp import Llama
from pydantic import BaseModel, Field
import rstr
from itertools import islice
@cmrfrd
cmrfrd / gist:fe8f61da076f8a4a751bf8fc8cb579a5
Created December 28, 2022 04:12
ipad_screen_mirror_server
#! /usr/bin/env nix-shell
#! nix-shell --quiet -p uxplay -i bash
set -ueo pipefail
## Clear any existing "DROP ME" rules
## ref: https://stackoverflow.com/a/63855690/12393422
while sudo iptables -L -n --line-number | grep "DROP ME" > /dev/null; do
sudo iptables -D INPUT $(sudo iptables -L -n --line-number | grep "DROP ME" | head -1 | awk '{print $1}');
done
@cmrfrd
cmrfrd / bloop_use
Last active March 9, 2020 21:41
bloop_use
import time
import asyncio
import operator
from functools import wraps
from itertools import repeat, count
from aioitertools import iter as aiter
from aioitertools import islice
from peewee import *
from peewee import Expression
@cmrfrd
cmrfrd / bloob
Created March 9, 2020 21:28
bloop
import time
import asyncio
import operator
from functools import wraps
from itertools import repeat, count
from aioitertools import iter as aiter
from aioitertools import islice
from peewee import *
from peewee import Expression
@cmrfrd
cmrfrd / snake_string2.py
Last active March 3, 2020 23:10
snake_string2.py
import _collections_abc
from operator import itemgetter as _itemgetter, eq as _eq
from keyword import iskeyword as _iskeyword
import sys as _sys
from functools import wraps
MAX_DEPTH = 1024
class SnakeString(_collections_abc.Sequence):
"""
@cmrfrd
cmrfrd / snake_string.py
Last active February 28, 2020 22:34
snake string
"""S is a snake string
The goal of snake string to easily generate paramaterized strings from
attributes, args, and kwargs.
Examples:
S.asdf -> asdf
S.hey.how.are.you -> hey.how.are.you
S.wow.s("this").is.cool -> wow.this.is.cool
@cmrfrd
cmrfrd / org_include_file_ref.org
Created December 6, 2019 01:41
org_include_file_ref.org
(org-babel-do-load-languages
  'org-babel-load-languages
  '((shell . t)
    (go . t))))
@cmrfrd
cmrfrd / async.pysc
Created December 5, 2019 16:21
async.pysc
import asyncio
import random
async def p(q,n):
for x in range(n):
print("p: ",x)
await asyncio.sleep(random.random())
await q.put(str(x))
async def c(q):