Skip to content

Instantly share code, notes, and snippets.

View erikLundstedt's full-sized avatar
🐧

erik lundstedt erikLundstedt

🐧
View GitHub Profile
@chomy
chomy / bcm2835.lisp
Created December 17, 2014 10:49
Common Lisp package for GPIO control of Raspberry Pi
(defpackage :BCM2835
(:use :FFI)
(:export :init
:close
:gpio-fsel
:gpio-write
:gpio-lev
:gpio-set
:gpio-clr
:delay
@polymeris
polymeris / lisp.lua
Created September 15, 2015 15:10
Toy Lisp interpreter in Lua / LPEG
local lpeg = require'lpeg'
local P, R, S = lpeg.P, lpeg.R, lpeg.S --patterns
local C, Ct = lpeg.C, lpeg.Ct --capture
local V = lpeg.V --variable
local parser = P {
'program', -- initial rule
program = Ct(V'sexpr' ^ 0),
wspace = S' \n\r\t' ^ 0,
atom = V'boolean' + V'integer' + V'string' + V'symbol',
@GlorifiedPig
GlorifiedPig / hook.lua
Last active April 21, 2023 12:12
Lua Hook Library
--- A library used for calling and attaching hooks.
-- @module Hook
Hook = {}
local cachedHooks = {}
--- Attaches a function to a hook.
-- @string hookID The string ID of the hook to be attached to.
-- @string uniqueID The unique ID of the function you are attaching to the hook.
-- @func func The function to be called when the hook is called.
@randompherret
randompherret / quantity_unit.php
Last active September 21, 2024 03:24
Script to import conversion factors into grocy
<?php
$apiaccess =[
"url" => "https://grocy.yourdomain.tld/api",
"key" => "1234password"
];
$quantity_units = [
"Cup" => [
"name" => "Cup",
"description" => "",
"name_plural" => "Cups"
@amygrinn
amygrinn / is-plural.el
Last active September 28, 2021 18:34
(require 'ispell)
(defun is-plural (noun)
"Determine if any word in NOUN has a base (root) word.
Uses either ispell, aspell, or hunspell based on user settings."
(condition-case err
(progn
(ispell-set-spellchecker-params)
(let* ((words (split-string noun))
@amygrinn
amygrinn / notify-send
Last active October 24, 2021 14:35
Libnotify shim for termux
#!/bin/bash
# This is a shim for libnotify on termux.
# Calls termux-notification with translated arguments from notify-send
ARGS=""
POSITIONAL=()
while [[ $# -gt 0 ]]; do
case "$1" in
-i|--icon)
;;; rational-module.el -*- lexical-binding: t; -*-
;;; License
;; Copyright (C) 2022
;; SPDX-License-Identifier: MIT
;; Author: Erik Lundstedt, System Crafters Community
;;; Commentary:
@Maista6969
Maista6969 / ordered_table.lua
Created May 18, 2023 22:45
MPV Lua scripts to interface with Stash
local ordered_table = {}
--[[
This implementation of ordered table does not hold performance above functionality.
It invokes a metamethod `__newindex` for every access, and
while this is not ideal performance wise, the resulting table behaves very closely to
a standard Lua table, with the quirk that the keys are ordered by when they are first seen
(unless deleted and then reinserted.)
--]]
-- private unique keys
local _values = {}