Skip to content

Instantly share code, notes, and snippets.

spacekitcat /
Last active Feb 28, 2021
Naive ray tracer implementation 00. It renders two spheres with inverted z values, the z value goes between 0 and 15, simulating a bounce effect.
import pygame as pg
import numpy as np
def is_exit_key(e):
return e.type == pg.KEYUP and (e.key == pg.K_ESCAPE or e.key == pg.K_q)
class GameObject:
def __init__(self, position, colour):
self.position = position
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import os
# The range of images to generate, which also controls the number of gradient 'stops'
imageCount = 30
# How far to increment red for each image, currently tied to imageCount as you can see
colorIncrement = 255 / imageCount
# Output folder for the images
spacekitcat / 6502-nes-stitch-n-draw.asm
Created Sep 1, 2019
6502 machine code snippet for stiching and rendering a 4 part sprite on the 8-bit Nintendo (NES)
View 6502-nes-stitch-n-draw.asm
.define OAM_TABLE_START $0200
; .zeropage
; param_1: .res 1
; param_2: .res 1
; param_3: .res 1
; temp_var_1: .res 1
; temp_var_2: .res 1
; temp_var_3: .res 1
spacekitcat / 6502-time-delay.asm
Created Aug 24, 2019
Creates a time delay on the 6502. Easy to adapt the intervals or even parameterise the subroutine
View 6502-time-delay.asm
; Written for the CA65 assembler and tested on a NES emulator
counter_lsb: .res 1
counter_msb: .res 1
.proc RateLimit
lda #$EE ; Most Significant Byte 'interval'
sta counter_msb
lda #$00 ; Least Significant Byte 'interval'
spacekitcat / 6502-16bit-counter.asm
Last active Aug 10, 2019
Code demonstrating a 16-bit counter written for the 6502, an 8-bit processor
View 6502-16bit-counter.asm
lda #$00
sta $a0
lda #$00
sta $a1
ldy $a0 ; Debug, shows the LSB in the Y register
inc $a0
spacekitcat / shannon-entropy-for-a-file.js
Last active Apr 29, 2019
Computes the Shannon entropy for a given input file
View shannon-entropy-for-a-file.js
const fs = require('fs');
const updateOccurenceTable = (byteOccurenceTable, inputBuffer) => {
inputBuffer.forEach(character => {
const byteOccurenceAccumulator = byteOccurenceTable[character];
byteOccurenceTable[character] = byteOccurenceAccumulator !== undefined ? byteOccurenceAccumulator + 1 : 1;
const { total } = byteOccurenceTable; = total ? total + inputBuffer.length : inputBuffer.length;
spacekitcat /
Created Oct 13, 2018
Deletes, packages and redeploys a CloudFormation stack. Convenience for scripts for debugging automatic deploys.
# October 2018.
# Written by Lisa Burton.
# Provided under the terms of the MIT license.
spacekitcat / motion-mailer-d
Created Feb 25, 2018
Initd script to bootstrap the watch command when the system starts up. The watch command periodically runs a bash script.
View motion-mailer-d
screen -d -m sudo watch -n5 'bash /opt/bin/'
spacekitcat /
Created Feb 25, 2018
Find an email the latest output image from the motion service
which motion
if [ ! $? -eq 0 ]
echo "Cannot find motion service in PATH, is it installed?"
exit 1
View SpecRunner.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>Jasmine Spec Runner v2.5.2</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-2.5.2/jasmine_favicon.png">
<link rel="stylesheet" href="lib/jasmine-2.5.2/jasmine.css">
<script src="lib/jasmine-2.5.2/jasmine.js"></script>