Skip to content

Instantly share code, notes, and snippets.

rubenwardy rubenwardy

Block or report user

Report or block rubenwardy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pipeline.lua
-- Run a series of functions as a pipeline - each returning the next's arguments.
-- The first function will be ran immediately
-- @param interval Time between pipelines
-- @param funcs A list of functions, each one of the form function(...)
-- where ... is returned by the previous function.
-- @param params Optional, a list of arguments to pass to the first function
local function pipeline(interval, funcs, params)
if funcs[1] ~= nil then
rubenwardy /
Last active May 21, 2018
Auto-restart, log per season, email on crash
cd ~/.minetest
mkdir -p logs_ctf
function mailme() {
echo "To:" > mail.txt
echo "Subject: CTF server crashed" >> mail.txt
echo "From:" >> mail.txt
echo "" >> mail.txt
View lua_console.lua
-- First check to see if it can be evaluated as an expression,
-- then fallback to executing it raw
local func, error = loadstring("return (" .. param .. ")")
if not func then
func, error = loadstring(param)
if not func then
return false, "E " .. error
View init.lua
function wrapRegisterCall(name, func)
for key, v in pairs(minetest["registered_" .. name .. "s"]) do
func(key, v)
local old = minetest["register_" .. name]
minetest["register_" .. name] = function(name, def)
func(name, def)
old(name, def)
PROMPT_COMMAND=__prompt_command # Func to gen PS1 after CMDs
get_git_as() {
if info=$(git diff --shortstat); then
echo $info
__prompt_command() {
rubenwardy / matrix_chain_mult_opt.js
Last active Nov 12, 2016
Matrix Chain Multiplication Order Optimisation
View matrix_chain_mult_opt.js
class MatrixRes {
constructor(rows, cols) {
this.rows = rows;
this.cols = cols;
sizeAfterMultiplyWith(other) {
return new MatrixRes(this.rows, other.cols);
rubenwardy / rod_cutting.js
Last active Nov 9, 2016
Finding the most profitable way to cut a rod, using bottom-up dynamic programming (CLRS Section 15.1)
View rod_cutting.js
var assert = require("assert");
class Result {
constructor(n, seq, score) {
this.n = n;
this.seq = seq;
this.score = score;
betterThan(other) {
rubenwardy /
Last active Apr 1, 2018
Server list point checker
# list all servers and their points:
# $ python
# lists all penalties being applied:
# $ python pen
# penalty -8 uptime for VanessaE's Nostalgia Server/
# penalty -8 uptime for VanessaE's Basic minetest_game server/
rubenwardy /
Last active Aug 29, 2015
Convert folder of images to PDF with filenames
# This batch file is specific to Linux.
# (the for, mkdir, rm etc commands may be done differently on your OS.
# the convert commands should be the same though)
rm /tmp/imageex -r
mkdir /tmp/imageex
for filename in *.png; do
echo "Processing $filename"
You can’t perform that action at this time.