Skip to content

Instantly share code, notes, and snippets.

View geekhunger's full-sized avatar

geekhunger geekhunger

View GitHub Profile
@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()
})
@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 / 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 / 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 / Main.lua
Last active February 20, 2020 07:36
This is a MySQL Adapter for Codea + demo code. It lets your Codea app talk directly to a MySQL server.
--# Main
-- mysql adapter
--
-- TODO: write higher level API to mysql
-- app should cache inputs and push to mysql when server available
-- also queries should be wrapped in coroutines or something, to be async?
function setup()
@geekhunger
geekhunger / Main.lua
Created December 22, 2017 23:46
Codea CraftAR example. Place window frames which display your current camera feed.
--# Main
supportedOrientations(LANDSCAPE_ANY)
displayMode(OVERLAY)
function setup()
    scene = craft.scene()
@geekhunger
geekhunger / Main.lua
Created January 23, 2016 21:10
Procreate Animation Player. Tool wrote in Codea.
--# Main
-- Procreate Animation Player [v1]
-- (c) kennstewayne.de
--
-- Works only with Dropbox for now!
--
displayMode(FULLSCREEN)
function setup()
@geekhunger
geekhunger / LineCaps.lua
Created November 20, 2015 17:45
Initial commit
local _line = line
local function lineCap(d)
for x = 1, d do
y = math.sqrt(d*d - x*x)
rect(0, 0, x, y)
end
end
function line(x1, y1, x2, y2, capMode)
@geekhunger
geekhunger / page.hbs
Created January 26, 2015 11:14
Ghost - List of posts inside post.hbs and page.hbs
...
{{> posts_list}}
...
@geekhunger
geekhunger / LineCaps.lua
Last active November 19, 2015 11:57
Fake lineCapMode() for line(), when noSmooth() is activated in Codea.
local _line = line
local function lineCap(d)
for x = 1, d do
y = math.sqrt(d*d - x*x)
rect(0, 0, x, y)
end
end
function line(x1, y1, x2, y2, capMode)