Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// included bc i use clang, remove if gcc.
// taken from
// https://github.com/lattera/glibc/blob/master/string/memfrob.c
void *memfrob(void *s, size_t n) {
char *p = (char *)s;

DO NOT USE THIS INFORMATION

Some libraries are incorrectly identified as Apache 2.0/MIT. The solution is to manually add license fields in each info.rkt and (make a tool to) go off of those.

Library License
com-win32-i386 Apache 2.0/MIT
com-win32-x86_64 Apache 2.0/MIT
db-ppc-macosx Apache 2.0/MIT
db-win32-i386 Apache 2.0/MIT
#!/bin/bash
# no set -e because gh might 404
set -uo pipefail
IFS=$'\n\t'
if test "$#" -ne 2; then
echo "run as ./github-add-collabs.sh user/repo usernames.txt"
exit
fi
@a11ce
a11ce / reversing-the-technical-interview.rkt
Created November 19, 2021 20:52
Racket translation of "Reversing the technical interview"
#lang racket
; read this, and check back here as you go for racket code
; https://aphyr.com/posts/340-reversing-the-technical-interview
(define (cons h t)
(lambda (p)
(if p
h
t)))
@a11ce
a11ce / julia.rkt
Created October 18, 2021 22:22
julia fractals with shading.rkt
#lang racket
(require (except-in "shading.rkt"
; we need magnitude from racket
; for complex numbers
magnitude))
; creates a procedure f_c(z) = z^2 + c
; given a constant c
(define (julia-fc c)
@a11ce
a11ce / script.gs
Created August 26, 2021 21:53
Class Spreadsheet Sorter
// https://stackoverflow.com/a/54024653
function hsv2rgb(h,s,v)
{
let f= (n,k=(n+h/60)%6) => v - v*s*Math.max( Math.min(k,4-k,1), 0);
return [f(5) * 255,f(3) * 255,f(1) * 255];
}
// https://stackoverflow.com/a/52171480
function hash(str, seed = 0) {
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
import random
def main():
pop = makePopulation(10)
pop[3][3] = 5
for i in range(100):
pop = stepForward(pop)
# COMMENT AND UNCOMMENT NEXT TWO LINES
@a11ce
a11ce / life.c
Created April 28, 2020 01:14
tinyLife
#include <stdio.h> // by Riley
#include <stdlib.h>// a11ce on GitHub
#include <unistd.h>// Conway's Game
#include <string.h>// of Life
#include <time.h> // 2019
#define l for(i j = 0; j < H; j++) \
{for(i k = 0; k < W; k++){
#define e ;}}
#define c [j][k]
const int H=40; const int W=40;
def main():
hSeq = "HEAGAWGHEE"
#hSeq = "z"
vSeq = "PAWHEAE"
#vSeq = "ab"
data = makeSameOne(hSeq, vSeq)
#showTable(hSeq, vSeq, data, hideZero=True)
f, t = makeFT(hSeq, vSeq)
print(transcribe(hSeq, vSeq, f, t))
@a11ce
a11ce / Server.java
Created October 21, 2018 20:43
Multithreaded Java server boilerplate
import java.util.Scanner;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.io.BufferedReader;
import java.io.InputStreamReader;