Skip to content

Instantly share code, notes, and snippets.

@wyozi
wyozi / mersennetwister.lua
Last active August 16, 2016 12:12
Mersenne twister using bit lib (orig: https://github.com/rangercyh/chance)
local N = 624
local M = 397
local MATRIX_A = 0x9908b0df
local UPPER_MASK = 0x80000000
local LOWER_MASK = 0x7fffffff
local band, bor, bxor, blshift, brshift = bit.band, bit.bor, bit.bxor, bit.lshift, bit.rshift
-- initializes mt[N] with a seed
local function init_genrand(o, s)
@wyozi
wyozi / nstable.lua
Created March 30, 2016 13:23
NSTable extracted from wyozi/nsgui
-- Extremely small OOP library
local function Class(name, parent)
local t = {}
local meta = {}
meta.__call = function(_, ...)
local inst = setmetatable({}, {__index = t})
if inst.initialize then inst:initialize(...) end
return inst
end
@wyozi
wyozi / cl_worldview.lua
Last active September 29, 2020 00:03
Garry's Mod: Small world snapshot requester library
local module = {}
worldview = module
module.Requests = module.Requests or {}
module.Rendering = false
function module.Request(id, renderData)
local t = module.Requests[id]
if not t then t={} module.Requests[id] = t end
@wyozi
wyozi / help.html
Last active August 29, 2015 14:14
gace help docs
<!DOCTYPE html>
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<style>
body {
background-color: rgb(218, 223, 225);
color: black;
font-family: 'Open Sans', sans-serif;
font-size: 14px;
@wyozi
wyozi / fbo_test.lua
Created April 13, 2014 09:39
gmod rendertargets
local rt1 = GetRenderTarget("TestRT1", 500, 500)
local rt2 = GetRenderTarget("TestRT2", 500, 500)
local rt_mat = Material("models/weapons/v_toolgun/screen")
hook.Add("HUDPaint", "TestRTHook", function()
render.PushRenderTarget(rt1)
render.Clear(0, 0, 0, 255)
cam.Start2D()