Skip to content

Instantly share code, notes, and snippets.

View tonetheman's full-sized avatar

Tony Colston tonetheman

View GitHub Profile
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name="viewport" />
<link rel="icon" href="data:,">
<title>String art</title>
<script type="text/javascript" src="jquery.min.js"></script>
html, body {
import collections
import math
import os
import cv2
import numpy as np
import time
MAX_LINES = 4000
N_PINS = 36*8
MIN_LOOP = 20 # To avoid getting stuck in a loop
tonetheman / seqsandarrays.nim
Created December 18, 2022 17:43
2d seq and some array examples for nim
# see here also for seq
# pretty print a seq
# or better than just echo it
proc pp(a: seq[ seq[int] ] ) =
for i in a:
tonetheman / mut_evenodd.nim
Created November 1, 2022 19:59
Mutually recursive even and odd function in nim
# forward declarations
proc even(x: int) : bool;
proc odd(x: int) : bool;
proc odd(x : int) : bool =
if x==0:
return false
return even(x-1)
tonetheman / mod.lua
Created August 29, 2022 22:54
lua code for a mod that works for 1 based numbers
saw this buried in this code
function mod(val,modulo)
--Mod for 1 based numbers.
--3%3=3. 4%3=1, 1%3=1
return (val-1)%modulo+1
tonetheman /
Created August 14, 2022 00:18
python3 struct read bytes
import struct
data = open("test.bin","rb").read()
# all of these are unsigned
def read_single_byte(data,position):
return struct.unpack("B",data[position:position+1])
def read_single_word(data,position):
return struct.unpack("H",data[position:position+2])
#include <iostream>
#include "raylib.h"
int main(void) {
std::cout << "howdy" << std::endl;
// Initialization
const int screenWidth = 800;
tonetheman / lines.pde
Created May 14, 2022 18:42
interesting processing i saw on twitter lost the link though :(
int n=200,i,s,t;
float a[] = new float[n*4],d;
void setup() {
for(i=0;i<n*4;i++) {
a[i] = 400-random(800);
tonetheman / makefile
Created May 13, 2022 13:18
shows an overwrite in c (not enough space in the array greeting)
# needed to include the no-stack-protector to make gcc
# be fast and loose with the stack
junk : test.c
gcc -o junk -g -fno-stack-protector test.c
clean :
rm -f ./junk
tonetheman /
Created May 11, 2022 22:44
Python3 http.server that does send back the 2 needed headers for SharedArrayBuffer errors
TONY notes
This is a DIRECT copy pasta of the file in the official cpython github
I added the following two headers from SHEER FRUSTRATION to get past a random SharedArrayBuffer not defined error
line 749 or so
self.send_header("Cross-Origin-Opener-Policy", "same-origin")
self.send_header("Cross-Origin-Embedder-Policy", "require-corp")