Skip to content

Instantly share code, notes, and snippets.

@stuhacking
stuhacking / Jasteroids.java
Last active March 9, 2020 14:43
Just a basic asteroids clone in Java for a test. Arrow keys + Space to move and shoot, 'r' to reset if you crash.
/**
* @file Jasteroids.java -- Simple Java Asteroids game.
*
* This file is self-contained using only dependencies built-into the
* standard java platform.
*/
import java.util.ArrayList;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JComponent;
@stuhacking
stuhacking / smallpt.c
Created March 27, 2019 16:29
C99 Implementation of Kevin Beason's Small Path Tracer (See link in file comment).
/*===-- small_pt.c - Kevin Beason's Small Path Tracer in C99 --------------===*/
/* This is a pure C99 implementation of Kevin Beason's small path tracer
* originally written in 99 lines of C++. This version does not aim to
* minimize lines of code (although it does adhere to a strict 80 column
* limit).
*
* This source is released under the MIT license, which is open and
* compatible with GPL. See https://opensource.org/licenses/MIT.
*
@stuhacking
stuhacking / bf.c
Last active March 27, 2019 16:26
BrainF*ck Interpreter. There are many like it but this one is mine.
/*===-- bf.c - BrainF*ck Interpreter --------------------------------------===*/
/* Notes:
* Bog standard BrainF*ck compliant interpreter. Uses a table to store jump
* addresses for loop return and escape.
*
* Language Ref:
* > Increment data pointer.
* < Decrement data pointer.
* + Increment (byte) value at data pointer.
@stuhacking
stuhacking / .gitignore
Created September 1, 2017 10:54
C++ Gitignore
# <Project Name> GitIgnore
# Created by https://www.gitignore.io/api/c++,cmake,emacs,intellij,linux,osx
# Build -----------------------------------------------------------------------
### Output and Cache Directories ###
/External/
/Debug/
/Docs/
/Release/
@stuhacking
stuhacking / puzzle-sum.clj
Created December 6, 2016 22:41
Quick solver for a cipher equation.
;; Given a cipher sum
;; THREE
;; THREE
;; FOUR
;; ONE
;; ______
;; ELEVEN
;; Calculate the cipher.
@stuhacking
stuhacking / x11colors.dat
Last active August 29, 2015 14:28
Standard X11 Colour palette in space delimited format.
snow 1.0000 0.9804 0.9804
ghost-white 0.9725 0.9725 1.0000
GhostWhite 0.9725 0.9725 1.0000
white-smoke 0.9608 0.9608 0.9608
WhiteSmoke 0.9608 0.9608 0.9608
gainsboro 0.8627 0.8627 0.8627
floral-white 1.0000 0.9804 0.9412
FloralWhite 1.0000 0.9804 0.9412
old-lace 0.9922 0.9608 0.9020
OldLace 0.9922 0.9608 0.9020
@stuhacking
stuhacking / SDL2_OpenGL.cpp
Created June 20, 2014 14:49
Skeleton for OpenGL renderer under SDL2.0
/**
* sdl2_opengl.cpp
* Minimal OpenGL Demo using SDL2.0
* from: https://gist.github.com/exavolt/2360410
*/
#include <iostream>
#include <string>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
(defn fizzbuzz [n]
(cond (zero? (rem n 15)) "FizzBuzz"
(zero? (rem n 5)) "Buzz"
(zero? (rem n 3)) "Fizz"
:else n))
(def fizzbuzz-seq
(for [x (iterate inc 1)]
(fizzbuzz x)))
module Main where
-- Infinite fizzbuzz sequence.
fizzbuzz :: [String]
fizzbuzz = [convert x | x <- [1..]]
where
convert s
| s `mod` 15 == 0 = "FizzBuzz"
| s `mod` 5 == 0 = "Buzz"
| s `mod` 3 == 0 = "Fizz"
@stuhacking
stuhacking / alm.pl
Created October 23, 2011 22:25
Simple Perl Speaking Alarm Clock with customisable phrases.
#! /usr/bin/perl -w
# The Perl Speaking Alarm CLock
# Author: Stuart Hacking <stuhacking_AT_gmail.com>
# Version: 0.2
# Speaks a mixture of early morning greetings to gently encourage the
# user to wake up. Volume increases each time a certain number of
# iterations passes. phrases and names can be customized individually.
# Makes use of OS X commands for speech and volume control. Similar