Skip to content

Instantly share code, notes, and snippets.

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class Node {
int start;
int end;
Node suffixlink;
HashMap<String,Node> children = new HashMap<>();
public Node next;
public boolean containsSuffix(String str) {
Node node = root;
while (true) {
if (str.isEmpty()) {
return node.children.isEmpty(); // return node.isleaf
}
node = node.children.get(String.valueOf(str.charAt(0)));
if (node == null) {
return false;
}
@Adrodoc
Adrodoc / mcfd-poc.mcfunction
Created June 14, 2019 23:46
proof of concept for simulating nested function calls with command blocks
# @e[limit=2]
tag @e[limit=2] add todo
tag @e[tag=todo,limit=1] add current
tag @e[tag=current] remove todo
execute as @e[tag=current] run say 1
execute as @e[tag=current] run say 2
tag @e[tag=current] remove current
@Adrodoc
Adrodoc / setmultimap.lua
Created March 26, 2018 13:56
setmultimap.lua
-- adrodoc55/setmultimap.lua
local pkg = {}
function pkg.put(multimap, key, value, hashfunction)
hashfunction = hashfunction or str
local set = multimap[key] or {}
local hash = hashfunction(value)
set[hash] = value
multimap[key] = set
@Adrodoc
Adrodoc / hammer.lua
Created March 17, 2018 21:23
Tinkers Construct Hammer
local pkg = {}
function pkg.give()
if spell.owner then
spell:execute('give %s golden_pickaxe 1 0 {hammer:true}')
end
end
function pkg.stop()
spell:execute('kill @e[type=wol:spell,tag=adrodoc.hammer]')
@Adrodoc
Adrodoc / tetris.lua
Last active October 19, 2021 07:39
tetris.lua
require 'mickkay.wol.Spell'
tetris = {}
tetris.delay = 10
tetris.origin = Vec3(453985, 80, -888253)
tetris.width = 10
tetris.height = 20
tetris.rotationCenter = Vec3(0,-1,0)
local upperCenter = tetris.origin + Vec3(tetris.width//2 + 1, tetris.height-1, 0)
@Adrodoc
Adrodoc / EventQueue.lua
Created January 14, 2018 00:36
EventQueue.lua
function EventQueue:clear()
while self:pop(0) do end
end
@Adrodoc
Adrodoc / SharedVar.lua
Last active January 14, 2018 13:50
SharedVar.lua
require 'adrodoc55.wol.EventQueue'
local requestEventName = 'SharedVarRequest-'
local updateEventName = 'SharedVarUpdate-'
declare('SharedVar')
local function createSharedVar(name)
Check.isString(name, 1)
local result = {
@Adrodoc
Adrodoc / claiming.lua
Last active March 26, 2018 15:58
claiming.lua
-- adrodoc55/claiming.lua
require "mickkay.wol.Spell"
local setmultimap = require "adrodoc55.setmultimap"
local cities = require "mickkay.cities"
local datastore = require "mickkay.datastore"
local pkg = {}
local store
-- gist.a532a79bc8ceb459a21f23e4a17e084c.scribble
if adrodoc55 == nil then
require "gist.5812f439642a1d4a9d89cdb75b38a13a.adrodoc55"
end
function scribble(eventType)
local q = Events.register(eventType)
for e in q.next do
print(str(e))