Skip to content

Instantly share code, notes, and snippets.

@arpruss
arpruss / laptimes2.py
Created December 4, 2022 19:06
lap time generator
import math
"""nPerSet = 10
nSets = 7
setTime = 8*60
restTime = 42
adjustRestSets = 4"""
laps = 67
@arpruss
arpruss / timer.py
Last active December 14, 2022 15:56
Create video of a timer
import cv2
import numpy as np
import math
fontScale = 10
margin = .2
fontThickness = 3
backColor = (0,0,0)
textColor = (255,255,255)
FPS = 59.94
#include <stdio.h>
#include <stdint.h>
#include <malloc.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#define MAX_WORDS 13000 // leave room for some tinkering
#define LENGTH 5
from __future__ import print_function
import sys
LENGTH = 5
RIGHT_LETTER_RIGHT_PLACE = 1
RIGHT_LETTER_WRONG_PLACE = 2
SCORE_NONE = 0
void getSpecialWord(uint16_t _n, char* buffer) {
static uint16_t w;
w = 0;
const uint8_t* b = answers;
static uint16_t n;
n = _n + 1;
static uint8_t additionTable[256];
static uint8_t tableReady = 0;
static uint8_t c;
static uint8_t mask;
@arpruss
arpruss / sargon.py
Last active December 16, 2021 03:30
GRAPHICS = True # uses cv2 to display board
import z80 # pip3 --install z80, but modified to make af visible
import binascii
import time
if GRAPHICS:
import cv2
import numpy as np
zoom = 5
function finder(obj, keyToFind, level=7, soFar='', searched=new Set) {
if (level<=0 || typeof obj != 'object' || obj === null || searched.has(obj)) return;
searched.add(obj)
if (keyToFind in obj) {
console.log(soFar + '.' + keyToFind)
}
for (let key in obj) {
try {
@arpruss
arpruss / tobin.py
Last active July 11, 2021 00:06
convert a hex dump to binary
# Public Domain / CC0 license
import sys
import re
import zlib
infile = sys.argv[1]
outfile = sys.argv[1].replace(".txt",".bin")
data = [0 for i in range(32768)]
// simply read a 32k Gameboy cartridge
// public domain / CC0
#define CHUNK_SIZE 16
uint16_t address;
uint16_t globalChecksum;
uint16_t correctGlobalChecksum;
uint8_t headerChecksum;
uint8_t correctHeaderChecksum;
// try to read a badly damaged 32k Gameboy Cartridge
const uint32_t aPins[16] = { PB8, PB9, PC13, PB7, PA0, PA1, PA2, PA3,
PA4, PA5, PA6, PA7, PB0, PB1, PB10, PB11 };
const uint32_t dPins[8] = { PB4, PB3, PA9, PA8, PB15, PB14, PB13, PA10 };
// all 5V tolerant: PB4, PB3, PA9, PA8, PB15, PB14, PB13, PA10
uint16_t address;
uint16_t RD = PB5;