Skip to content

Instantly share code, notes, and snippets.

View Seggan's full-sized avatar
💭
Developing... what else?

Seggan

💭
Developing... what else?
  • South Carolina, USA
  • 11:46 (UTC -05:00)
View GitHub Profile
@Seggan
Seggan / rol.rol
Created October 6, 2022 19:15
Rol Showoff
// Rol: a language transpiled to Lua for all you Lua syntax haters
// Overall the language is quite C-like
print("Hello, World!")
// Semicolons are not required, but can be used
print("Semi");print("colon")
// Idk about variable syntax, is similar to Kotlin
var a: Int = 1
@Seggan
Seggan / ops.txt
Last active January 28, 2023 02:23
Fig operators
char (arity) - desc
whitespace - nop
newline - Starts a new function
! (1) - (any) logical not
" - String literal
# - Misc digraph char
$ (1) - (any) reverse
% (2) - (num, num) b mod a, (str, any) replace % in a with b
& (2) - (num, num) bitwise AND
@Seggan
Seggan / test.java
Created December 23, 2021 03:02
Proving Thread-Safety of SimplexOctaveGenerator#generateNoise
import org.bukkit.util.noise.SimplexOctaveGenerator;
import org.junit.jupiter.api.Assertions;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadLocalRandom;
public class OctaveGeneratorThreadTest {
public static void main(String[] args) throws InterruptedException {
int threadCount = 500; // set this to the number of threads to use in testing
@Seggan
Seggan / turing_machine.py
Last active December 14, 2021 18:27
A Minimalistic Turing Machine
"""
A minimalistic Turing machine I wrote for an assignment.
Has 4 commands: > (unconditional branch), + (add), x (halt), and ? (branch if zero). > adds to the current
tape location by x, where x is the number right after the command. + adds the number in absolute
position a to the number in absolute position b, one-indexed, where a and b are the two numbers
following the command. x stops the program and prints the contents of the tape. ? checks if the previous
number is zero, if it is, add x to the tape position, where x is the number following the command.
Sample multiplication program: > 7 c a b ? 4 > 3 x + 4 3 -1 + 14 5 > -13, where c is the result
@Seggan
Seggan / BlockStorageMock.java
Last active May 28, 2021 20:40
BlockStorage, mocked
Map<Location, Map<String, String>> storage = new HashMap<>();
try (MockedStatic<BlockStorage> bsMock = Mockito.mockStatic(BlockStorage.class)) {
bsMock.when(() -> BlockStorage.addBlockInfo(any(Block.class), anyString(), anyString()))
.then((Answer<Void>) a -> {
Block b = a.getArgument(0, Block.class);
storage.computeIfAbsent(b.getLocation(), k -> new HashMap<>())
.put(a.getArgument(1), a.getArgument(2));
return null;
}