Skip to content

Instantly share code, notes, and snippets.

View ainsleyrutterford's full-sized avatar

Ainsley Rutterford ainsleyrutterford

  • Amazon
  • London
View GitHub Profile
uint8_t k2[16] = {0xD4, 0x96, 0xE8, 0x8F, 0x21, 0x40, 0x55, 0x92,
0xED, 0x18, 0x62, 0xA9, 0x8C, 0x68, 0x35, 0xE6};
uint8_t m2[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
uint8_t c2[16] = {0xBB, 0xA8, 0x7B, 0x22, 0xF9, 0xF0, 0x01, 0x2A,
0x7E, 0xC2, 0xFE, 0x11, 0xE0, 0x07, 0x9A, 0x2D};
@ainsleyrutterford
ainsleyrutterford / Lerp.cs
Last active April 9, 2019 17:46
Simple linear interpolation function at a constant speed.
public float driverFloat;
public float currentFloat;
private float Interp(float current, float target, float divisor) {
if (target != current) {
return current + (target - current)/divisor;
} else {
return target;
}
}
@ainsleyrutterford
ainsleyrutterford / fps.cpp
Created April 14, 2019 15:27
FPS coutner SDL
Uint32 fps_lasttime = SDL_GetTicks(); //the last recorded time.
Uint32 fps_current; //the current FPS.
Uint32 fps_frames = 0; //frames passed since the last recorded fps.
while (!quit) {
if (update()) {
fps_frames++;
if (fps_lasttime < SDL_GetTicks() - 1000) {
fps_lasttime = SDL_GetTicks();
fps_current = fps_frames;
@ainsleyrutterford
ainsleyrutterford / Loader.cpp
Last active April 23, 2019 12:15
Converts .obj files to a vector of Triangles.
#include <iostream>
#include <fstream>
#include <sstream>
#include "TestModelH.h"
using namespace std;
using glm::vec3;
using glm::vec4;
vector<Triangle> load_obj(string filename) {
@ainsleyrutterford
ainsleyrutterford / anti-aliasing.cpp
Created April 27, 2019 19:06
Anti aliasing code for a rasteriser created using C++.
vec3 aliasing_buffer[SCREEN_HEIGHT][SCREEN_WIDTH];
screen *screen = InitializeSDL(SCREEN_WIDTH/3, SCREEN_HEIGHT/3, FULLSCREEN_MODE);
memset(screen->buffer , 0, screen->height * screen->width * sizeof(uint32_t));
memset(depth_buffer , 0, SCREEN_HEIGHT * SCREEN_WIDTH * sizeof(float ));
memset(aliasing_buffer, 0, SCREEN_HEIGHT * SCREEN_WIDTH * sizeof(vec3 ));
void draw_screen(screen* screen) {
for (int y = 0; y < SCREEN_HEIGHT; y+=3) {
@ainsleyrutterford
ainsleyrutterford / listing.tex
Created April 30, 2019 22:06
Simple example of the listings package in latex.
\usepackage{listings}
\lstset{language=C,
basicstyle=\ttfamily,
keywordstyle=\color{blue}\ttfamily,
stringstyle=\color{red}\ttfamily,
commentstyle=\color{green}\ttfamily,
morecomment=[l][\color{magenta}]{\#}}
% Do everything above in your preamble
/* This is for the central column of content */
.container {
max-width: 65rem; /* Allows the column to be resizable */
margin: 0 auto;
padding-top: 2rem;
}
h1 {
color: #000000; /* Black. */
padding: 1rem 1rem 1rem 1rem; /* top, right, bottom, left */

Using gdb, a backtrace of the crash can be found:

#0  0x0000000000407b0c in f90sac::f90sac_tshift at f90sac.F90:1126
#1  0x000000000041ae78 in analyser::an_applysplittingoperators at Analyser.F90:138
#2  0x000000000041d23c in evaluatepath at EvaluatePath.f90:84
#3  0x000000000041c1e8 in evaluatemodel at Evaluate.F90:84
#4  0x000000000041d550 in mhsampler at Samplers.f90:95
#5  0x000000000041bcec in mtssampmain at MTSSampMain.f90:47

Hackintosh installation

Notes about the installation processes for Windows, Linux, and macOS on my new build.

Hardware

  • Case: NCASE M1 V5.0
  • CPU: Intel i7 10700K
  • GPU: Sapphire Radeon RX 5700 XT Pulse
  • Memory: Corsair Vengeance LPX DDR4 3000MHz 32GB
@ainsleyrutterford
ainsleyrutterford / pokemon-weaknesses.json
Created August 25, 2022 23:16
Pokémon type weaknesses chart as JSON
{
"normal": {
"normal": 1,
"fire": 1,
"water": 1,
"electric": 1,
"grass": 1,
"ice": 1,
"fighting": 2,
"poison": 1,