Skip to content

Instantly share code, notes, and snippets.

View JohnnyJayJay's full-sized avatar
🏔️
Now on Codeberg

Johnny JohnnyJayJay

🏔️
Now on Codeberg
View GitHub Profile

Git

Git ist ein Version Control System (VCS). Es wird verwendet, um mehrere Versionen eines Projekts zu handhaben, speichern und zu vereinen.

Vokabular

Begriff Bedeutung
repository Ber Ort, wo das Projekt und alle seine commits gespeichert werden
stage Dateien hinzufügen, die für einen commit berücksichtigt werden sollen
@JohnnyJayJay
JohnnyJayJay / DurationFormatter.java
Created May 13, 2020 19:06
util for simple duration formatting
import java.time.Duration;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* @author Johnny_JayJay (https://www.github.com/JohnnyJayJay)
*/
public final class DurationFormatter {
def add_adjacent_tiles(grid, room, x, y):
room.append((x, y))
grid[x][y] = 'C'
adjacent_tile_positions = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]
for (x, y) in adjacent_tile_positions:
if x < len(grid) and y < len(grid[x]) and grid[x][y] == 'R':
add_adjacent_tiles(grid, room, x, y)
return tiles
def group_tiles_to_rooms(grid):
@JohnnyJayJay
JohnnyJayJay / commands.clj
Last active June 29, 2020 12:55
A simple and generic command handler for clojure apps using core.match pattern matching.
(ns commands.core
(:require [clojure.string :refer [split]]
[clojure.core.match :refer [match]]))
(defmacro defcommand
"Defines a command function that takes a context argument and any number of additional arguments.
If the `name` symbol does not have explicit label metadata attached to it, the name of the symbol will be used as the label.
The `context-binding` can be any valid `let` binding form. It will be bound to the context argument at execution time.
The `patterns` are a variable number of [[clojure.core.match/match]] matching forms that represent the different arguments that
can be passed to this command."
@JohnnyJayJay
JohnnyJayJay / CustomHeads.java
Last active March 6, 2023 05:39
code to get custom heads in minecraft in any version
// Comment the line below in if you use compatre
//import com.github.johnnyjayjay.compatre.NmsDependent;
import net.minecraft.server.v1_8_R3.MojangsonParser;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
@JohnnyJayJay
JohnnyJayJay / haste.clj
Created April 5, 2021 23:26
A small babashka script to post text to a haste-server and get the url back
#!/usr/bin/env bb
(def ^:const base-url "https://hastebin.com")
(as-> (or (first *command-line-args*) System/in) $
(io/input-stream $)
(curl/post (str base-url "/documents") {:body $})
(:body $)
(json/parse-string $ true)
(:key $)
@JohnnyJayJay
JohnnyJayJay / discljord-slash-commands.md
Last active January 10, 2025 19:08
Quick primer for slash commands in discljord

Working with Slash Commands in discljord

At the end of 2020, Discord introduced a new feature that is available to bots: Slash Commands.
Slash Commands belong to a new feature category called "Interactions" which finally allows bots to enhance the Discord UI. As such, the way slash commands (and upcoming interactions such as clickable buttons aka. "components") work is quite different from other parts of the API.

What exactly are Slash Commands?

Slash commands are Discord entities that you can create, edit and delete through requests. Registered commands have a name and a description and are accessible in Discord clients by typing /name.
There are two types of commands: guild and global. As the names indicate, commands of the former type are only accessible in one specific guild

@JohnnyJayJay
JohnnyJayJay / example-tests.clj
Created July 23, 2021 13:44
Macro that can be used for small in-place tests and documentation
(defmacro examples
"Macro to generate illustrative tests for a function based on input-output pairs.
`f` is the function to test.
`equals` is the function used to compare the expected and actual result.
Each example call is a sequence where the first n - 1 items are the inputs and the last item is the expected output."
{:style/indent 1}
[f equals & example-calls]
`(fn []
~@(for [call example-calls
@JohnnyJayJay
JohnnyJayJay / measurements.json
Created March 2, 2022 16:46
Plotting variable interaction graph layout mesasurement results
[ {
"variables" : 250,
"clauses" : 1065,
"name" : "https://gbd.iti.kit.edu/file/6ffbc2b1851be02a3b040af9b7d15a42/",
"time" : 526
}, {
"variables" : 430,
"clauses" : 9080,
"name" : "https://gbd.iti.kit.edu/file/218aba6ee61e235dfb9bcde2894a007c/",
"time" : 1502
@JohnnyJayJay
JohnnyJayJay / bigswap.clj
Last active March 8, 2022 22:33
A Clojure function for atoms that I'm currently missing
(defn bigswap!
"`swap!` into an atom *and* return a custom value produced in the atomic function.
`atom` is the atom.
`f` is a function of two arguments: the first is a function `atom-set` that 'sets' the atom to the given value.
The second is the current value in the atom.
In essence, `bigswap!` returns the value of `f` while setting the value of the atom to the value set by `atom-set`, if applicable."
[atom f]
(let [return-val (volatile! nil)]