Skip to content

Instantly share code, notes, and snippets.

View marvk's full-sized avatar
🐧

Marvin marvk

🐧
View GitHub Profile

So, whats wrong with the following start to a constructor of a Graph class?

public Graph(String fileName) {
    File file = null;
    try {
        file = new File(fileName);
    } catch (Exception e) {
        // TODO: handle exception
 }
@marvk
marvk / Caesar.java
Last active February 15, 2019 11:05
Ceasar Cypher
public final class Caesar {
private static final int NUM_LETTERS = 26;
public static String caesar(final String s, final int shift) {
return s.chars()
.filter(Caesar::isEnglishLetter)
.map(character -> getIntUnaryOperator((char) character, shift))
.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
.toString();
}
@marvk
marvk / Groupify.java
Last active February 15, 2019 11:32
Groupify
public final class Groupify {
public static String groupify(final String input, final int groupSize) {
if (groupSize < 1) {
throw new IllegalArgumentException("groupSize must be bigger than zero, was " + groupSize);
}
final String inputPadded = input + "x".repeat((groupSize - input.length() % groupSize) % groupSize);
final String[] split = inputPadded.split("(?<=\\G.{" + groupSize + "})");
package net.marvk.nuthello.game;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
import net.marvk.nuthello.player.Player;
import net.marvk.nuthello.player.PlayerFactory;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Optional;
@marvk
marvk / script.js
Created March 19, 2019 20:49
Lichess load all online group members
let lnCounter = 0;
let removeOffline = function () {
while (document.getElementsByClassName('offline')[0]) {
document.getElementsByClassName('offline')[0].parentElement.remove();
}
}
let loadOnline = setInterval(function(){
lnCounter++;
@marvk
marvk / chess.2019-03-22-23-07-29.log
Last active March 22, 2019 23:41
Lichess API problem
00:31:04.005 [I/O dispatcher 55] TRACE net.marvk.chess.lichess4j.GameStateResponseConsumer - Received game state response:
{"type":"gameState","moves":"e2e4 d7d6 g1f3 g8f6 b1c3 c7c5 f1b5 c8d7 b5c4 b8c6 d2d3 e7e6 e1g1 f8e7 c1e3 e8g8 a1b1 f6g4 e3f4 g4e5 c4b3 e5f3 d1f3 c6d4 f3e3 e6e5 f4g3 e7g5 f2f4 g5h6 e3f2 d4b3 a2b3 h6f4 g3f4 e5f4 f2f4 d7c6 c3d5 c6d5 e4d5 d8c7 f1f2 a8d8 f4a4 b7b6 b1f1 c7e7 f2f5 d8d7 a4e4 f8e8 f1e1 e7e4 e1e4 d7e7 e4e7 e8e7 g1f2 b6b5 h2h3 e7e8 f5h5 g7g6 h5h4 e8e5 c2c4 f7f5 f2f3 b5c4 b3c4 e5e1 g2g4 e1d1 f3e3 f5f4 e3e4 d1d2 g4g5 d2b2 e4f4 b2d2 f4e4 d2g2 h4g4 g2f2 e4e3 f2h2 g4g3 h2c2 g3f3 c2g2 h3h4 g2h2 f3f4 a7a5 d3d4 c5d4 e3d4 a5a4 c4c5 h2d2 d4e3 d2d5 c5d6 a4a3 f4a4 d5d6 a4a3 d6d8 a3a7 d8f8 a7d7 f8f5 e3e4 f5f2 d7d8 g8g7 d8c8 f2h2 c8c7 g7g8 c7c8 g8f7 c8c7 f7f8 c7h7 f8g8 h7h6 g8g7 e4e5 h2f2 e5e6 f2f5 e6d7 f5c5 d7d6 c5c2 d6e6 c2c3 e6e5 c3c4 e5d5 c4b4 d5e6 b4d4 e6e7 d4d5 e7e8 d5d2 h4h5 g6h5 e8e7 d2h2 e7e6 h2e2 e6f5 e2f2 f5e5 g7g8 h6h5 f2f7 h5h6 g8g7 h6f6 f7d7 f6c6 d7d2 g5g6 d2f2 c6a6 f2f3 a6d6 f3f1 d6
import java.util.UUID;
class Scratch {
public static void main(String[] args) {
final UUID uuid = UUID.randomUUID();
final int[] result = new int[129];
for (int i = 0; i < 1_000_000_000; i++) {
@marvk
marvk / PigFarm.ahk
Last active March 25, 2020 00:08
PigFarm Script
$F20::
Sleep := 10
NumRight := 4
CntInner := 20
DistRight := 5
NumLeft := NumRight * 2
DistLeft := DistRight * -1
While GetKeyState("F20","P") {
Loop %NumRight% {
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; Move SW
Numpad1::
MouseGetPos, xpos, ypos
Click 1730 877
MouseMove, %xpos%, %ypos%
\begin{figure}
\centering
\begin{tikzpicture}
\pgfplotstableread[col sep = comma]{contents/data/ground-truth/Result_25.csv}\loadedtable
\begin{axis}
[
ybar,
bar width=.5cm,
width=0.9\textwidth,
height=.5\textwidth,