Skip to content

Instantly share code, notes, and snippets.

Avatar

Joonas wyozi

  • Finland
View GitHub Profile
@wyozi
wyozi / TabCountSync.js
Created Jun 19, 2020
Same-origin tab count tracker with BroadcastChannel
View TabCountSync.js
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();
}
@wyozi
wyozi / cofetch.lua
Last active Jun 7, 2020
Tiny GarrysMod coroutine functions
View cofetch.lua
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 / bin_repl
Created Jun 2, 2020
Phoenix Framework must-haves
View bin_repl
# Run REPL
iex -S mix
@wyozi
wyozi / conversion.sh
Created May 5, 2020
Imagemagick convert: *.png to gif
View conversion.sh
# 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 / a.md
Created Oct 10, 2016
Notes on hashcat
View a.md
@wyozi
wyozi / mersennetwister.lua
Last active Aug 16, 2016
Mersenne twister using bit lib (orig: https://github.com/rangercyh/chance)
View mersennetwister.lua
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 Mar 30, 2016
NSTable extracted from wyozi/nsgui
View nstable.lua
-- 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 Sep 29, 2020
Garry's Mod: Small world snapshot requester library
View cl_worldview.lua
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 Aug 29, 2015
gace help docs
View help.html
<!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 Apr 13, 2014
gmod rendertargets
View fbo_test.lua
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()
You can’t perform that action at this time.