Skip to content

Instantly share code, notes, and snippets.

View abaines's full-sized avatar

Alan Baines abaines

View GitHub Profile
@tburrows13
tburrows13 / factorio-2.0-mod-porting.md
Last active January 26, 2025 15:59
Factorio 2.0 mod porting guide
@abaines
abaines / control.lua
Last active November 9, 2024 17:50
Factorio space-age: Fix starting map settings
local handler = require("event_handler")
handler.add_lib(require("freeplay"))
if script.active_mods["space-age"] then
handler.add_lib(require("space-finish-script"))
else
handler.add_lib(require("silo-script"))
end
@kgriffs
kgriffs / string_util.lua
Created May 27, 2020 17:41
Lua string utilities (contains, startswith, endswith, replace, insert)
function string:contains(sub)
return self:find(sub, 1, true) ~= nil
end
function string:startswith(start)
return self:sub(1, #start) == start
end
function string:endswith(ending)
@tkfu
tkfu / srd_5e_monsters.json
Last active February 22, 2025 21:33
A JSON file with all the D&D 5e SRD monster data
[
{
"name": "Aboleth",
"meta": "Large aberration, lawful evil",
"Armor Class": "17 (Natural Armor)",
"Hit Points": "135 (18d10 + 36)",
"Speed": "10 ft., swim 40 ft. ",
"STR": "21",
"STR_mod": "(+5)",
"DEX": "9",
@tylerneylon
tylerneylon / json.lua
Last active March 31, 2025 01:08
Pure Lua json library.
--[[ json.lua
A compact pure-Lua JSON library.
The main functions are: json.stringify, json.parse.
## json.stringify:
This expects the following to be true of any tables being encoded:
* They only have string or number keys. Number keys must be represented as
strings in json; this is part of the json spec.
@hieblmedia
hieblmedia / .gitignore
Last active April 12, 2025 02:48
Gitignore - Exclude all except specific subdirectory
#
# If all files excluded and you will include only specific sub-directories
# the parent path must matched before.
#
/**
!/.gitignore
###############################
# Un-ignore the affected subdirectory
@MihailJP
MihailJP / d_copy.lua
Created October 22, 2012 14:47
Shallow- and deep-copy of table in Lua
function clone (t) -- deep-copy a table
if type(t) ~= "table" then return t end
local meta = getmetatable(t)
local target = {}
for k, v in pairs(t) do
if type(v) == "table" then
target[k] = clone(v)
else
target[k] = v
end