Skip to content

Instantly share code, notes, and snippets.

View Quenty's full-sized avatar
🎉
Follow me on Twitter @Quenty

James Onnen Quenty

🎉
Follow me on Twitter @Quenty
View GitHub Profile
@sh1mmer
sh1mmer / The Koan of Closure
Created December 15, 2010 22:18
Programming Koans
The venerable master Qc Na was walking with his student, Anton. Hoping to
prompt the master into a discussion, Anton said "Master, I have heard that
objects are a very good thing - is this true?" Qc Na looked pityingly at
his student and replied, "Foolish pupil - objects are merely a poor man's
closures."
Chastised, Anton took his leave from his master and returned to his cell,
intent on studying closures. He carefully read the entire "Lambda: The
Ultimate..." series of papers and its cousins, and implemented a small
Scheme interpreter with a closure-based object system. He learned much, and
@Anaminus
Anaminus / ArrayDiff.lua
Last active September 29, 2020 01:40
ArrayDiff gets the difference between to arrays, detecting insertions, removals, swaps, and replacements.
--[[ ArrayDiff
Receives two arrays, and gets the difference between them. Returns a list of
steps that will turn the first array into the second.
- Elements in each array should be unique
- Order of elements matters
Ops:
insert: {1, index, value}
@Anaminus
Anaminus / splash-patch.lua
Created March 12, 2015 06:14
Replaces Roblox Studio's splash screen with another image.
-- Replaces Roblox Studio's splash screen with another image.
--
-- Usage:
--
-- lua splash-patch.lua [STUDIO_PATH] [IMAGE_PATH]
--
-- Specifying no options prompts for input.
-- First KB of original splash image file
anonymous
anonymous / Functions2.md
Created September 18, 2015 15:58
auto-posted gist

Functions: Passing By Value vs Passing by Reference

  • Motivating Demonstration: swap.c

Pointers in C

int a = 10;
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <memory>
#include <future>
#include <stdio.h>
#include <assert.h>
#include <time.h>
#include <stdint.h>
@badcc
badcc / ChangeClassName.lua
Last active September 13, 2024 17:53
Change ClassName of Roblox instance (using Anaminus' API dump)
local ClassName = 'TextButton'
local Object = game.Selection:Get()[1]
local HttpService = game:GetService('HttpService')
local API = HttpService:JSONDecode(HttpService:GetAsync('http://anaminus.github.io/rbx/json/api/latest.json'))
local function ChangeClass(ClassName, Object, NewObject)
for _,v in next,API do
if (v['type'] == 'Class' and v['Name'] == ClassName and v['Superclass']) then
ChangeClass(v['Superclass'], Object, NewObject)
elseif (v['type'] == 'Property' and v['Class'] == ClassName) then
pcall(function() -- If property is not allowed to be changed, do not error.
@zeux
zeux / edge-encode.cpp
Last active December 8, 2018 06:25
8-bit (unsigned) floating point encoding that is designed to be very efficient to decode on DX9/GLES2 class GPUs
// Can be used to efficiently encode floating point values from a limited range ([0..65k]) into a byte
// edgeDecode is optimized for GPUs (native exp2)
// edgeEncode1 is optimized for GPUs (native log2)
// edgeEncode2 is optimized for CPUs but is an approximation
// edgeEncode3 is optimized for CPUs
float edgeDecode(int e)
{
return exp2f(float(e) * (1 / 16.f)) - 1;
}
@Anaminus
Anaminus / Signal.lua
Last active September 29, 2020 01:33
--[[
# Signal
API-compatible Roblox events.
Addresses two flaws in previous implementations:
- Held a reference to the last set of fired arguments.
- Arguments would be overridden if the signal was fired by a listener.
local Roact = require("Roact")
local Segments = {}
for index = 1, 8 do
local X = (index - 1) % 4
local Y = math.floor((index - 1) / 4)
table.insert(Segments, {
Angle = 360 / (2 ^ index),
---
-- @module WaveCollapseUtils
-- @author Quenty
local WaveCollapseUtils = {}
local EDGE_DATA = {
{
2, -- Edge index (forward)
1, -- Neighbor's edgeindex (backward)