Skip to content

Instantly share code, notes, and snippets.

View geekhunger's full-sized avatar

geekhunger geekhunger

View GitHub Profile
@geekhunger
geekhunger / class.lua
Last active June 1, 2021 21:33
Classes implementation in vanilla Lua with support for getters & setters! Well documented.
-- 2019 (c) [email protected]
-- Providing object inheritance, the correct way!
-- Support for getters and setters!
-- (Getter/Setter name can even be a regex expression! - But be careful your namin as "get_%w+" for example would override the entire standard proxy behaviour of class_mt.__index or cast_mt.__index - This can be either a powerful feature or produce unintended results.)
-- Classes are linked through __parent objects inside of each (sub-)class until they finally get instanciated
-- (the base-class is assigned as the __index metatable)
-- This way we can extend parent classes or change their methods even after their creation while still being able to see these changes in the sub-classes
-- Instances of classes are deep-copies down their entire inheritance chain
@geekhunger
geekhunger / hotload.lua
Last active February 20, 2020 07:33
hot-swap modules required by Lua (bonus: low-level system information and filesystem access via utilities.lua)
-- 2020 (c) [email protected]
-- IMPORTANT NOTE for Lua < 5.1
-- When using this class to hotload other modules, be sure to count tables WITH table.getn and NOT with # !!!
-- Lua 5.1 and prior don't support overriding # via .__len metamethod - so our best bet here is to modify table.getn
-- and use table.getn whenever we have to check the number of entires in numerical tables
local _require = require
local _ipairs = ipairs
local _pairs = pairs
@geekhunger
geekhunger / config.h
Created June 2, 2022 07:58
Kinesis Advantage2 Keymap (kint36 fork by Geekhunger)
#pragma once
#define TAPPING_TERM 100 // I'm mainly using this for modifiers, etc
#define KEY_TAP_TIMEOUT 190 // same meaning as TAPPING_TERM but for the rest of the regular keys (KC_A ... KC_Z)
#define PREVENT_STUCK_MODIFIERS
//#define STM32_SYSCLK KINETIS_SYSCLK_FREQUENCY
//#define NOP_FUDGE 0.4
//#define RGB_DI_PIN LINE_PIN28
//#define RGBLED_NUM 4
@geekhunger
geekhunger / gtm.js
Created January 23, 2023 10:26
Easy GTM Script Include
const attr = "data-gtm"
const gtm = document.head.querySelector(`script[${attr}]`) // basically reference to itself
if(gtm) {
window["dataLayer"] = window["dataLayer"] || []
window["dataLayer"].push({
"event": "gtm.js",
"gtm.start": new Date().getTime()
})