Skip to content

Instantly share code, notes, and snippets.

@Therosin
Therosin / gh-makeprivate.ps1
Created March 4, 2026 09:02
Batch Private your personal and org GitHub repos based on stale/string matches.
<#
.SYNOPSIS
Bulk-set GitHub repos to private using GitHub CLI (gh), with filters.
.DESCRIPTION
Evaluates repositories for one or more GitHub owners and sets matching public repositories to private.
By default, a repository is selected when ANY of the following is true:
- stale last push date
- empty repository
- low recent commit activity
@Therosin
Therosin / utils-random.lua
Last active March 31, 2024 01:33
Lua 5.1 entropy generator, with uuidv4 "like" id generator.
local function positionalHashing(hexString)
local finalNumber = 0
for i = 1, #hexString do
local char = hexString:sub(i, i)
local numValue = tonumber(char, 16) or 0
finalNumber = (finalNumber + (numValue * i)) % (2 ^ 53)
end
return finalNumber
end
@Therosin
Therosin / EventManager.lua
Last active March 31, 2024 01:05
LuaWorldState
-- Copyright (C) 2024 Theros <https://github.com/therosin>
--
-- This file is part of LuaWorldStateSystem.
--
-- LuaWorldStateSystem is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- LuaWorldStateSystem is distributed in the hope that it will be useful,
@Therosin
Therosin / TypedPipeline.md
Last active March 17, 2024 16:10
(terrible) "TypedPipeline" system for multi stage data pipelines in typescript.

Overview

The createTypedPipeline utility allows you to construct and execute a sequence of stages, where each stage performs a transformation or operation on input data, potentially resulting in a new output type. It supports both synchronous and asynchronous stages, making it suitable for a wide range of data processing tasks.

Key Features

  • Type Safety: Ensures the inputs and outputs of stages are correctly typed.
  • Context Sharing: A shared context (ctx) object is passed through stages, allowing for state sharing and error collection.
  • Flexible Error Handling: Configurable behavior to either halt execution on errors or continue, logging errors to the context for later handling.
@Therosin
Therosin / ASCII-EbookLibrary
Last active September 8, 2023 08:35
List eBooks in the current or specified folder as a nice ASCII-Art List based on Category/Subcategory, Optionally generate and image and save it.
import os
import platform
from PIL import Image, ImageDraw, ImageFont
import click
# where is your eBook library located? (uses current directory by default)
EBOOK_LIBRARY_PATH = "."
# Should we create an image or just print the ASCII art?
CREATE_IMAGE = False
@Therosin
Therosin / mousePos.js
Last active July 13, 2023 23:40
access mouse position from css
function createDocumentMouseTracker(document) {
/**
* store the current mouse position in a data attribute so it can be read by CSS.
*/
const updateMouseTracking = (e) => {
document.documentElement.dataset.mouseX = Math.round(e.clientX);
document.documentElement.dataset.mouseY = Math.round(e.clientY);
}
document.enableMouseTracking = () => {
@Therosin
Therosin / scrollPos.js
Last active July 13, 2023 23:40
access scroll position from css
/**
* Creates a scroll tracker for the given document.
* @param {Document} document - the document to track
*/
function createDocumentScrollTracker(document) {
/**
* store the current scroll position in a data attribute so it can be read by CSS.
*/
const updateScrollTracking = () => {
document.documentElement.dataset.scrollX = Math.round(window.scrollX);
@Therosin
Therosin / debounce.js
Last active July 13, 2023 22:59
Debounce a callback function
/**
* debounce a callback function.
* @param {function} fn - the function to debounce
* @returns {function} - the debounced function
*/
const debounce = (fn) => {
let frame;
return (...params) => {
if (frame) { cancelAnimationFrame(frame); }
@Therosin
Therosin / WebClient.lua
Last active July 8, 2023 22:49
WebClient in lua using powershell for environments with no loadlib or popen but working os.execute
local M = {
_NAME = 'mWebClient',
_VERSION = '0.1-dev',
_DESCRIPTION = [[
Provides Basic GET/POST Supprt for CE3 Game Modules
the lua environment found in CE3 games doesnt allow for loading common dll based http libraries
this module attempts to get around this by using native windows powershell calls and coroutines
]],
_AUTHOR = "Theros <theros@svaltek.xyz"
}