Skip to content

Instantly share code, notes, and snippets.

View TannerRogalsky's full-sized avatar
💯
P I X E L S

Tanner Rogalsky TannerRogalsky

💯
P I X E L S
View GitHub Profile
@TannerRogalsky
TannerRogalsky / p01.rs
Created November 28, 2022 12:41
AoC Problem01 2021 GBA
#![cfg_attr(not(test), no_std)]
#![cfg_attr(not(test), no_main)]
#[cfg(not(test))]
extern crate alloc;
#[cfg(not(test))]
type Vec<T> = alloc::vec::Vec<T>;
#[cfg(not(test))]
@TannerRogalsky
TannerRogalsky / main.lua
Created January 23, 2017 13:55
Fast vertex setting in Love using ImageData and the FFI
local num_verts = 100000
local vertices = {}
for i=1,num_verts do
vertices[i] = {0, 0, 0, 0, 255, 255, 255, 255}
end
local ffi = require('ffi')
ffi.cdef[[
typedef struct {
float x, y;
@TannerRogalsky
TannerRogalsky / set.lua
Last active June 21, 2020 04:46
A simple set implementation in lua
local Set = {}
function Set.new()
local reverse = {}
local set = {}
return setmetatable(set, {
__index = {
insert = function(set, value)
if not reverse[value] then
table.insert(set, value)
@TannerRogalsky
TannerRogalsky / RES Module - Subreddit Linker.js
Created July 12, 2011 03:20
A module for Reddit Enhancement Suite (RES) which finds any subreddit mentions that are not links and converts them into links.
modules['subredditLinker'] = {
moduleID: 'subredditLinker',
moduleName: 'Subreddit Linker',
options: { },
description: 'Finds any subreddit mentions that are not links and converts them into links.',
isEnabled: function() {
return RESConsole.getModulePrefs(this.moduleID);
},
include: Array(
/https?:\/\/([a-z]+).reddit.com\/user\/[-\w\.]+/i,
@TannerRogalsky
TannerRogalsky / main.cpp
Created February 11, 2018 00:23
Emscripten producing invalid JS when unary operator is applied to static const instance property.
#include <cstdio>
class UnaryTest {
public:
static const UnaryTest STATIC_TEST;
double p;
UnaryTest(double p);
};
@TannerRogalsky
TannerRogalsky / Bot.java
Last active November 17, 2017 17:49
An IRC bot for playing rock paper scissors.
import org.jibble.pircbot.*;
import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Random;
public class Bot extends PircBot {
public final String PARENT = "C:\\Documents and Settings\\Tanner Rogalsky\\My Documents\\RPS\\users";
public String mainChannel;
@TannerRogalsky
TannerRogalsky / buffer.cpp
Created April 7, 2017 11:11
Subdivide a polyhedron and buffer it's vertices into a VBO.
template<int32_t N>
void buffer(GLuint *vbos) {
if constexpr(N >= 0) {
const auto vertices = subdivide<N>(indexedVertices, indices);
const auto wireframe = getWireframeGeometry(vertices);
glBindBuffer(GL_ARRAY_BUFFER, vbos[N]);
glBufferData(GL_ARRAY_BUFFER, wireframe.size() * sizeof(Vertex), wireframe.data(), GL_STATIC_DRAW);
buffer<N - 1>(vbos);
}
}
local _PACKAGE = (...):match("^(.+)[%./][^%.]+")
local Line = {}
Line.__index = Line
local Vector = require(_PACKAGE .. ".vector")
function Line.new(x1, y1, x2, y2)
local self = setmetatable({}, Line)
self.origin = Vector(x1, y1)
@TannerRogalsky
TannerRogalsky / generateSphereVertices.lua
Created June 24, 2016 23:38
Fake 2D Sphere Without A Shader
local function insertVertices(vertices, vert, ...)
if vert then
table.insert(vertices, vert)
insertVertices(vertices, ...)
end
end
local function createSphereVertex(radius, theta, phi, ox, oy)
local xb = math.cos(phi) * math.cos(theta)
local yb = math.sin(theta)
@TannerRogalsky
TannerRogalsky / genMesh.lua
Created June 23, 2016 19:48
Generate a circular mesh.
local function genMesh(num_verts, radius)
local verts = {}
local interval = math.pi * 2 / num_verts
for i=1,num_verts do
local phi = i * interval
local x = radius * math.cos(phi)
local y = radius * math.sin(phi)
local u = (x + radius) / (radius * 2)
local v = (y + radius) / (radius * 2)
table.insert(verts, {x, y, u, v})