Skip to content

Instantly share code, notes, and snippets.

@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()
@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 / 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 / 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 / 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 / a.md
Created October 10, 2016 00:52
Notes on hashcat
@wyozi
wyozi / conversion.sh
Created May 5, 2020 03:04
Imagemagick convert: *.png to gif
# Delay of 200ms per frame; remove transparent background and fill with white; loop
convert -delay 20 -alpha remove -background white *.png -loop 0 navmesh_weights.gif
@wyozi
wyozi / bin_repl
Created June 2, 2020 13:27
Phoenix Framework must-haves
# Run REPL
iex -S mix
@wyozi
wyozi / cofetch.lua
Last active June 7, 2020 15:01
Tiny GarrysMod coroutine functions
function cofetch(url, headers)
local co = coroutine.running()
assert(co)
-- ensure we wait at least one tick
timer.Simple(0, function()
http.Fetch(url, function(body, size, headers, code)
coroutine.resume(co, body, size, headers, code)
end, function(err)
coroutine.resume(false, err)
@wyozi
wyozi / TabCountSync.js
Created June 19, 2020 15:28
Same-origin tab count tracker with BroadcastChannel
class TabCountSync {
constructor() {
this.bc = new BroadcastChannel("tabcount-sync");
this.bc.postMessage("opened");
this.bc.onmessage = (ev) => this.onMessage(ev);
this.count = 1;
this.subscriptions = new Set();
}