Skip to content

Instantly share code, notes, and snippets.

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# Set up the figure and 3D axis
fig = plt.figure(figsize=(16, 14))
ax = fig.add_subplot(111, projection='3d')
# Create the grid of x and y values
x = np.linspace(0.01, 1, 200) # Increased resolution
@llllvvuu
llllvvuu / uncheck_all.js
Last active August 28, 2024 07:04
paste this into the console
async function uncheckAllWithDelay() {
const checkboxes = document.querySelectorAll('input[type="checkbox"], [role="checkbox"]');
for (let i = 0; i < checkboxes.length; i++) {
const checkbox = checkboxes[i];
if (checkbox.checked || checkbox.getAttribute('aria-checked') === 'true') {
const clickEvent = new MouseEvent('click', {
view: window,
bubbles: true,
cancelable: true
});
@llllvvuu
llllvvuu / topo.c
Created August 16, 2024 11:39
topo.c
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
typedef struct {
uint32_t u, v;
} Edge;
/**
@llllvvuu
llllvvuu / pdf_salt_form_fields.py
Last active August 16, 2024 11:41
Salt pdf form fields to prevent collision when merging with another pdf. Tested with Python 3.9.18.
"""
Adds a salt to every form field key in the PDF so that
when you merge it with other PDFs, the values don't get clobbered.
"""
import argparse
import uuid
from PyPDF2 import PdfReader, PdfWriter
from PyPDF2.generic import IndirectObject, PdfObject, TextStringObject

Problem: https://twitter.com/littmath/status/1769044719034647001

Flip a fair coin 100 times—it gives a sequence of heads (H) and tails (T). For each HH in the sequence of flips, Alice gets a point; for each HT, Bob does, so e.g. for the sequence THHHT Alice gets 2 points and Bob gets 1 point. Who is most likely to win?

Proofs:

  1. https://twitter.com/llllvvuu/status/1769629337953923403
  2. https://x.com/alexselby1770/status/1769795987344638033
  3. https://twitter.com/RadishHarmers/status/1770217473716932647
  4. https://x.com/RadishHarmers/status/1771368007174168604?s=20

Keybase proof

I hereby claim:

  • I am llllvvuu on github.
  • I am llwu (https://keybase.io/llwu) on keybase.
  • I have a public key ASBegEzHvChNWe569jBMgHkkJPAmA7La4nhxghUB4gEdZgo

To claim this, I am signing this object:

@llllvvuu
llllvvuu / screenshot.sh
Created April 12, 2017 22:51
command line script to grab frames from video files with .ass subs using fast seek
infile=$1
shift
outfile=$1
shift
ffmpeg -dump_attachment:t "" -i "$infile"
mv *.ttf *.TTF *.otf *.OTF *.ttc *.TTC ~/.fonts
fc-cache -fv ~/.fonts
ffmpeg -i "$infile" -map 0:s:0 subs.ass
for var in "$@"
do
@llllvvuu
llllvvuu / mouse.xboxdrv
Created January 7, 2017 11:58
OSMC RasPi Wireless XBox 360 controller
# Mouse Emulation
# ===============
#
# This configuration file emulates a mouse. The left stick controls
# the cursor, the right stick becomes a horizontal and vertical scroll
# wheel, the dpad acts as cursor keys, the start and back buttons
# become forward and back buttons, the guide button escape and LB and
# RB become page up and page down and the face button act as mouse
# button.