Skip to content

Instantly share code, notes, and snippets.

View hoelzro's full-sized avatar

Rob Hoelz hoelzro

View GitHub Profile
apiVersion: 1
providers:
- name: example-provider
options:
path: /etc/dashboards
foldersFromFilesStructure: true
@hoelzro
hoelzro / sunset.lua
Last active November 1, 2023 20:40
local ceil = math.ceil
local floor = math.floor
-- trigonometric functions that work in terms of degrees
local function sin(degrees)
return math.sin(math.rad(degrees))
end
local function asin(x)
return math.deg(math.asin(x))
@hoelzro
hoelzro / gist:3919bc2d579f94bf19ad61a2afd259a0
Created August 27, 2023 14:21
Killing this loop messes with zsh stdout
seq 1 5 | while read n ; do
sleep 5
done > /dev/null
@hoelzro
hoelzro / pretty.lua
Created November 17, 2011 16:13
Pure Lua persistence of functions with upvalues
local format = string.format
local tjoin = table.concat
local tostring = tostring
local type = type
local floor = math.floor
local pairs = pairs
local ipairs = ipairs
local error = error
module 'pretty'
@hoelzro
hoelzro / multi.lua
Last active November 30, 2022 02:55
Multiple inheritance in Lua
local Mom = {}
local Dad = {}
local Child = {}
function Mom:work()
print "I'm a particle physicist!"
end
function Dad:work()
print "I'm a computer guy!"
local rules = named_rule_builder() -- *waves hands*
rules.manager_logger = {
rule = {},
callback = manage_log.record,
}
rules.generic_properties = {
rule = {},
properties = {
@hoelzro
hoelzro / foo.bar.lua
Created October 19, 2011 21:07
Simple relative require in Lua
require 'baz'
@hoelzro
hoelzro / repl.lua
Created October 5, 2011 18:28
A Lua REPL implemented in Lua
do
local buffer = ''
local function gather_results(success, ...)
local n = select('#', ...)
return success, { n = n, ... }
end
local function print_results(results)
@hoelzro
hoelzro / posix.rs
Created June 25, 2013 06:54
Process execution tracer in Rust
extern mod c {
unsafe fn fork() -> libc::pid_t;
unsafe fn exit(status: libc::c_int) -> !;
unsafe fn getpid() -> libc::pid_t;
unsafe fn waitpid(pid: libc::pid_t, status: *libc::c_int, flags: libc::c_int) -> libc::c_int;
unsafe fn execvp(file: *libc::c_char, argv: **libc::c_char) -> !;
unsafe fn kill(pid: libc::pid_t, signal: libc::c_int) -> libc::c_int;
unsafe fn strerror(errno: libc::c_int) -> *libc::c_char;
}
@hoelzro
hoelzro / lua-set-path.c
Created July 3, 2013 15:10
Override package.path from C
int
luaR_set_package_path(lua_State *L, const char *path)
{
lua_getglobal(L, "package");
lua_pushstring(L, path);
lua_setfield(L, -2, "path");
lua_pop(L, 1);
return 0; /* should check for errors */
}