Skip to content

Instantly share code, notes, and snippets.

@SmallJoker
SmallJoker / notification_block.txt
Last active Apr 28, 2020
Clean up the new clutter in the notifications
View notification_block.txt
Filter Rules
==============
Works for:
- AdblockPlus
- ublock origin
- ??
Group by: Repository
View init_prevent_lava_placement.lua
minetest.register_privilege( "lava", "Can place lava at any depth.")
local LAVA_PLACE_DEPTH = -50
function override_on_place(item_name)
local def = minetest.registered_items[item_name]
local old_on_place = def.on_place
def.on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
@SmallJoker
SmallJoker / apply_pr.sh
Last active Jan 12, 2020
Applies PRs to any repository. Place into ~/ and run in the target directory
View apply_pr.sh
#!/bin/bash
url=$(git remote -v get-url upstream 2>&1)
if [[ $url == fatal* ]]; then
url=$(git remote -v get-url origin 2>&1)
fi
if [[ $url == fatal* ]]; then
echo "Can neither find 'upstream' nor 'origin' git remote."
exit 1
View neuron.cpp
/*
Example structure
┌─── NeuralLayer 1 ────┐
│ Inputs (source data) │
│ Outputs (1) │
└─────vvvvvvvvvvvv─────┘
┌─── NeuralLayer 2 ────┐
│ Inputs = Outputs (1) │
│ Outputs (2) │
└─────vvvvvvvvvvvv─────┘
@SmallJoker
SmallJoker / init_22_ascii_biome.lua
Last active Feb 17, 2019
ASCII-Art in the terminal based on the biome information
View init_22_ascii_biome.lua
-- Minetest Lua mod to have a rudimentary display of the biomes in your world
-- CC0, Written by Krock/SmallJoker 2019
-- Sample image: https://krock-works.uk.to/u/ethereal_cc57167_ASCII_map.png
local STEPSIZE = 32
local X_RADIUS = 1000
local Z_RADIUS = 1000
local CHARACTERS = {
"x", ".", "+", "@", "#",
"", "", "",
View vectortest.cpp
// g++ vectortest.cpp
/*
emplace_back: 553305 ticks
push_back: 665359 ticks
resize: 437487 ticks
*/
// g++ -O3 -ffast-math vectortest.cpp
/*
emplace_back: 165961 ticks
push_back: 165695 ticks
View profile-20180726T164916_technic.txt
Values below show absolute/relative times spend per server step by the instrumented function.
A total of 8885 samples were taken
instrumentation | min µs | max µs | avg µs | min % | max % | avg %
-------------------------------------------------------- | --------- | --------- | --------- | ----- | ----- | ------
mesecons: | 1 | 161770 | 86 | 0.0 | 99.1 | 3.3
- globalstep[1] ..................................... | 1 | 161768 | 84 | 0.0 | 99.0 | 2.5
- on_placenode[1] ................................... | 17 | 25 | 21 | 2.5 | 6.3 | 4.8
- on_dignode[1] ..................................... | 13 | 49 | 21 | 0.6 | 10.3 | 6.2
@SmallJoker
SmallJoker / network_sqrt_log2.cpp
Last active Jul 25, 2018
Test script to measure different methods of eoncoding and decoding floats over the network
View network_sqrt_log2.cpp
#include <cmath>
#include <cstdint>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <chrono>
#include <cassert>
typedef uint8_t u8;
typedef int8_t s8;
@SmallJoker
SmallJoker / MT-replace-deprecated.sh
Last active Mar 7, 2019
Minetest - Replace deprecated function calls
View MT-replace-deprecated.sh
#!/bin/bash
# License: CC0
# How to use:
# 1) Open the terminal in the target mod directory
# 2) Call the script
files=$(find . -name "*.lua")
ref_call()
@SmallJoker
SmallJoker / Data_RW.cs
Last active Oct 3, 2015
Code to serialize and deserialize a world
View Data_RW.cs
/*
Code to serialize and deserialize a world
Copyright (C) 2015 Krock/SmallJoker <mk939@ymail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
You can’t perform that action at this time.