Skip to content

Instantly share code, notes, and snippets.

View appgurueu's full-sized avatar

Lars Müller appgurueu

View GitHub Profile
@appgurueu
appgurueu / PHPExample.php
Created August 17, 2018 13:07
Small PHP Example, WTFPL
<!doctype html>
<!-- Template for lua_api.html -->
<html lang="en">
<body data-spy="scroll" data-target="#contenttable" data-offset="15" style="background: url('background.png') no-repeat center center fixed;background-size: 100% 100%;background-repeat: no-repeat;image-rendering:optimizeSpeed">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Example">
<meta name="author" content="Lars Müller">
@appgurueu
appgurueu / generate_bg.py
Last active October 6, 2018 08:45
Generate MT Background for Website Python Script
import PIL
import random
from PIL import Image
size=(60,40)
dirtlevel=3*16
gravellevel=5*16
dirt=Image.open("default_dirt.png")
gravel=Image.open("default_gravel.png")
@appgurueu
appgurueu / init.lua
Last active March 9, 2022 00:53
modlib - init.lua - template
-- Table helpers
table_ext= {
tablecopy = function(t)
return table.copy(t)
end,
count = function(table)
local count = 0
for _ in pairs(table) do
@appgurueu
appgurueu / init.lua
Created March 7, 2020 17:17
Minetest Waypoint Testmod
-- Use this to test waypoint capabilities
minetest.register_chatcommand(
"test_waypoints",
{
description = "tests waypoint capabilities",
func = function(name)
local player = minetest.get_player_by_name(name)
minetest.chat_send_all(
"regular: " ..
player:hud_add {
@appgurueu
appgurueu / markdown_to_bbcode.js
Created April 7, 2020 13:02
Converts Markdown to BBCode
const md = require('mark-twain');
const parse5 = require('parse5');
tags = {
"strong": "b",
"em": "i",
"u": "u",
"code": "icode",
"h1": ["h", "b"],
"h2": ["size=150", "color=#115098"],
@appgurueu
appgurueu / default_bones.lua
Last active March 9, 2022 00:44
Gets default bone positions from glTF files (for Minetest)
-- helper function
local function quaternion_to_rotation(q)
local rotation = {}
local sinr_cosp = 2 * (q[4] * q[1] + q[2] * q[3])
local cosr_cosp = 1 - 2 * (q[1] * q[1] + q[2] * q[2])
rotation.x = math.atan2(sinr_cosp, cosr_cosp)
local sinp = 2 * (q[4] * q[2] - q[3] * q[1])
if sinp <= -1 then
@appgurueu
appgurueu / init.lua
Last active March 9, 2022 00:44
Shuts down the server if it lags too much ("antilag" Minetest mod init.lua)
local min_lag = 1 -- in seconds
local min_times = 10 -- has to occur 10x
local times = 0
minetest.register_globalstep(function(lag)
if lag < min_lag then
times = 0
else
times = times + 1
if times >= min_times then
minetest.request_shutdown("Server shutting down due to high latency (lag).")
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.function.BiFunction;
import java.util.concurrent.ThreadLocalRandom;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Supplier;
/**
@appgurueu
appgurueu / crosshair.lua
Created December 19, 2020 11:53
Crosshair spread indicator code
crosshair = {}
function crosshair:set_meta(meta)
return setmetatable(self, {__index = function(self, index)
if crosshair[index] ~= nil then
return crosshair[index]
end
if meta[index] ~= nil then
return meta[index]
end
@appgurueu
appgurueu / trinary_logic.lua
Created June 11, 2021 14:06
Trinary logic
-- Set boolean metatable
debug.setmetatable(false, {
__add = function(a, b)
if b == nil then
return b + a
end
return a or b
end,
__mul = function(a, b)
if b == nil then