Skip to content

Instantly share code, notes, and snippets.

View TheRayTracer's full-sized avatar

Simon Flannery TheRayTracer

  • Melbourne, Australia
View GitHub Profile
@TheRayTracer
TheRayTracer / main.cpp
Last active August 29, 2015 14:00
This code sample parses the results from a machine learning algorithm to produce receiver operating characteristic (ROC) curves. The curve plot points must be manually charted in an external application such as a spreadsheet application.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cassert>
@TheRayTracer
TheRayTracer / main.cpp
Created April 30, 2014 10:38
Computes epsilon - the smallest value such that, when added to 1, is still distinguishable from 1.
#include <iostream>
#include <limits>
#include <cassert>
namespace std { }
using namespace std;
/* Computes the smallest value such that, when added to 1, is still distinguishable from 1. */
template<typename T>
int epsilon(T& eps)
@TheRayTracer
TheRayTracer / iris_classification_results.png
Last active August 14, 2017 09:44
This R script demonstrates Machine Learning and classification using the Caret package. First, the Iris set is divided into a training set and a test set. Secondly, the model is trained. Then, predictions are queried and accuracy is calculated. Lastly, RoC curves are plotted for evaluation. Plots are generated for each step.
iris_classification_results.png
@TheRayTracer
TheRayTracer / cpuid.h
Last active August 29, 2015 14:06
Utility of functions that help to determine specific CPU features, including determining the vendor of the CPU.
#ifndef CPUID_H
#define CPUID_H
#include <memory.h>
#define FAMILY_ID 0x0000F00
#define EXT_FAMILY_ID 0x0F00000
#define PENTIUM4_ID 0x0000F00
@TheRayTracer
TheRayTracer / chart.png
Last active August 29, 2015 14:10
A small collection of scripts to simulate and analyse a game of Monopoly.
chart.png
@TheRayTracer
TheRayTracer / main
Last active August 29, 2015 14:19
Two puzzles solved using Python. 1. The classic "Make 4 litres from only a 3 litre and 5 litre jug without markings except of a total volume" problem. Two methods are illustrated using a simple Jug class. 2. Maximising the profit by buying low and selling high from yesterday's stock prices.
class jug:
def __init__(self, size):
self.size = size
self.volume = 0
self.waste = 0
def empty(self):
self.waste = self.waste + self.volume
self.volume = 0
@TheRayTracer
TheRayTracer / lm75a.sh
Created November 8, 2015 11:20
This entry contributes a simple Bash script to query and control a LM75 Digital Temperature Sensor via I2C. The second Bash script is a utility to interact with a real-time clock (RTC). The third entry is a Python script for a mini web server to retrieve the temperature in either Celsius (default) or Fahrenheit. These were a few very fun weekend…
#!/bin/bash
readonly lm75=0x48 # Slave address with A0, A1, and A2 set to 0v (ground).
while [ $# -gt 0 ]
do
if [ "$1" == "-debug" ]
then
debug=true
fi
@TheRayTracer
TheRayTracer / SSD1306.py
Last active August 4, 2019 00:03
The below Python source controls an OLED display (size 128 x 64) using a SSD1306 chipset and the SPI interface. The source code initialises the chipset setting the 2 orange pages at the top of the display, and includes functions for drawing primitive shapes and a full ASCII set.
import struct
import spidev
import sys
import time
import random
import RPi.GPIO as gpio
ascii = [
[ 0x55, 0x00, 0x55, 0x00, 0x55 ],
[ 0x55, 0x00, 0x55, 0x00, 0x55 ],
@TheRayTracer
TheRayTracer / SSD1331.py
Last active March 12, 2020 13:18
The below Python source files control an OLED display (size 96 x 64, 65K colours) using a SSD1331 chipset and the SPI interface. The source code initialises the chipset and includes hardware accelerated functions for drawing primitive shapes and a non-hardware accelerated full ASCII set. Examples include a basic Space Invaders game, and a clock.
import struct
import spidev
import sys
import time
import random
import RPi.GPIO as gpio
ascii = [
[ 0x55, 0x00, 0x55, 0x00, 0x55 ],
[ 0x55, 0x00, 0x55, 0x00, 0x55 ],
@TheRayTracer
TheRayTracer / mushrooms_explore_a.png
Last active October 6, 2022 20:30
Using R to explore the UCI mushroom dataset reveals excellent KNN prediction results.
mushrooms_explore_a.png