Skip to content

Instantly share code, notes, and snippets.

@greg-kennedy
greg-kennedy / perceptron.pde
Created September 23, 2025 15:41
Image classifier in Processing, based on example from "The Hitch-Hiker's Guide to Artificial Intelligence" (1986)
/**
* Image Classifier (Perceptron)
*
* Based on the "Computer Vision" example from
* "The Hitch-Hiker's Guide to Artificial Intelligence" (1986)
* Richard Forsyth, Chris Naylor
*
* https://archive.org/details/forsyth-naylor-hitchhikers-guide-to-ai-pc-basic/page/94/mode/2up
* https://en.wikipedia.org/wiki/Perceptron
*/
@greg-kennedy
greg-kennedy / 2d collision routines.c
Created August 7, 2024 04:17
Stashing some 2d collision routines here
// AABB to AABB collision
// In case of a hit, the first object is pushed out
static int aabb_aabb(short *x, short *y, unsigned short w, unsigned short h,
short ox, short oy, unsigned short ow, unsigned short oh)
{
// find protrusion into each side
int p_l = *x + w - ox; if (p_l <= 0) return 0;
int p_r = ox + ow - *x; if (p_r <= 0) return 0;
int p_u = *y + h - oy; if (p_u <= 0) return 0;
int p_d = oy + oh - *y; if (p_d <= 0) return 0;
@greg-kennedy
greg-kennedy / Blaseball TTS.js
Last active January 26, 2023 07:09
Blaseball TTS Userscript - adds a "speak" button to games so you can listen to them via browser TTS.
// ==UserScript==
// @name Blaseball TTS
// @namespace https://freshbreath.zone
// @version 2.1
// @description Add a "Speak" button to Blaseball live games
// @author MOS Technology 6502
// @match https://*.blaseball.com/
// @icon https://www.google.com/s2/favicons?sz=64&domain=blaseball.com
// @grant none
// @license CC0; https://creativecommons.org/share-your-work/public-domain/cc0/
@greg-kennedy
greg-kennedy / dosbox-demo-record-hack.patch
Last active September 6, 2019 17:33
DOSBox 0.74-3 Demo Record hack
--- dosbox-0.74-3/src/gui/sdlmain.cpp 2019-06-26 09:56:44.000000000 -0500
+++ dosbox-0.74-3-dev/src/gui/sdlmain.cpp 2019-09-06 12:05:17.963048000 -0500
@@ -284,6 +284,12 @@
bool startup_state_numlock=false;
bool startup_state_capslock=false;
+#ifdef C_SSHOT
+// demo recording hack
+int demostart = 0;
+int demoend = 0;
@greg-kennedy
greg-kennedy / android_on_chromebook.md
Last active January 2, 2018 18:35
Enable Android on Chromebooks

Modern Chromebooks support Android out-of-the-box. Older models may support it, but not "officially", and need a workaround to get Android going.

--enable-arc
--arc-availability=officially-supported
@greg-kennedy
greg-kennedy / minecraft-server-ubuntu.txt
Last active July 26, 2017 16:35
Minecraft Server on Ubuntu
# The Minecraft Distro (on Ubuntu)
## Install packages
* OpenJDK8
* perl
* <web server>
## Create user minecraft:minecraft
## Install minecraft vanilla server from Mojang
@greg-kennedy
greg-kennedy / FullScreenCanvas.html
Last active April 9, 2024 02:27
Full-window, proper aspect HTML5 canvas example
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Full-screen Canvas</title>
</head>
<body style="background:black">
<canvas id="canvas" style="position:fixed;background:green;">
Sorry, your browser does not appear to support HTML5 Canvas element.
</canvas>