Skip to content

Instantly share code, notes, and snippets.

View bastienvoirin's full-sized avatar

Bastien Voirin bastienvoirin

  • France
  • 14:49 (UTC +02:00)
View GitHub Profile
import numpy as np
from random import shuffle
from matplotlib import pyplot as plt
class Simulation:
"""
"""
@bastienvoirin
bastienvoirin / b.ebnf
Last active April 11, 2020 11:46
B compiler
incdec = "++" | "--" ;
unary = "-" | "~" | "!" | "*" | "&" ;
binary = "|" | "&" | ["#"] rel | "%" ;
rel = "==" | "!=" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | "+" | "-" | "*" | "/" ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
@bastienvoirin
bastienvoirin / constants.lua
Last active March 31, 2020 17:48
Lua compiler
local RESERVED = {
BLOCK_START = {
DO = "do",
ELSE = "else",
ELSEIF = "elseif",
FOR = "for",
FUNCTION = "function",
IF = "if",
REPEAT = "repeat",
THEN = "then",
@bastienvoirin
bastienvoirin / controls.mcfunction
Last active March 23, 2020 12:24
Animal Crossing: Wild World in Minecraft
effect give @a[gamemode=adventure] jump_boost 1000000 128 true
effect clear @a[gamemode=!adventure] jump_boost
from itertools import *
for i in count(start, step):
for i in cycle(seq):
for i in repeat(elem, n):
for i in accumulate(seq):
for i in accumulate(seq, operator.mul):
for i in chain():
for i in dropwhile(lambda x: x, seq):
local Tokens = {
{
type = "whitespace",
patterns = {
"%s+"
}
},
{
type = "comment",
patterns = {
@bastienvoirin
bastienvoirin / lexer.lua
Last active March 13, 2020 08:56
Lua Lexer for Lua
local Tokens = {
LBRACE = "{", RBRACE = "}", LBRACK = "[", LPAREN = "(",
RBRACK = "]", RPAREN = ")", LSHIFT = "<<", RSHIFT = ">>",
BAND = "&", BNOT = "~", BOR = "|", LENGTH = "#",
PLUS = "+", MINUS = "-", TIMES = "*", POW = "^",
DIV = "/", IDIV = "//", MOD = "%", EQUALS = "=",
DOT = ".", DDOT = "..", DDDOT = "...", COLON = ":",
EQ = "==", NE = "~=", QUOTE = "'", QQUOTE = '"',
LE = "<=", GE = ">=", LT = "<", GT = ">",
AND = "and", BREAK = "break", DO = "do", ELSE = "else",
@bastienvoirin
bastienvoirin / loop.mcfunction
Last active August 22, 2019 18:01
Rush Data Pack
scoreboard players add @e[type=armor_stand,x=1000,y=175,z=1000,distance=..100] ticks 1
execute at @e[type=armor_stand,x=1000,y=175,z=1000,distance=..100,scores={ticks=30..}] run summon minecraft:item ~ ~ ~ {Item:{id:"minecraft:brick",Count:1b}}
scoreboard players add @e[x=1000,y=175,z=1000,distance=..100,type=armor_stand,scores={ticks=30..}] bronze 1
scoreboard players reset @e[x=1000,y=175,z=1000,distance=..100,type=armor_stand,scores={ticks=30..}] ticks
execute at @e[type=armor_stand,x=1000,y=175,z=1000,distance=..100,scores={bronze=8..}] run summon minecraft:item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:1b}}
scoreboard players add @e[x=1000,y=175,z=1000,distance=..100,type=armor_stand,scores={bronze=8..}] iron 1
scoreboard players reset @e[x=1000,y=175,z=1000,distance=..100,type=armor_stand,scores={bronze=8..}] bronze
/* Simulation LCR */
float x, x1, x2, y, b, c, delta, asq, bsq, u, v, g, d, lsq, rsq, error, count;
float pos[] = new float[2];
int t;
void setup() {
sample();
size(800, 800);
/* Simulation NSWE */
float x, y, alpha, beta, alphasq, betasq, lambda, asq, bsq, u, v, error, avg, maxerror;
float[] pos = new float[2];
int t;
void setup() {
sample();
size(800, 800);