Skip to content

Instantly share code, notes, and snippets.

View seyfahni's full-sized avatar

Niklas Seyfarth seyfahni

View GitHub Profile
@seyfahni
seyfahni / DecryptPasswordJetBrainsBuiltIn.java
Created September 1, 2023 09:19
Decrypt a password stored in IntelliJ's c.pwd file withg the BUILT_IN encryption method.
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.util.Base64;
class DecryptPasswordJetBrainsBuiltIn {
public static void main(String... args) throws GeneralSecurityException {
@seyfahni
seyfahni / TemplateMessage.java
Last active August 2, 2022 07:30
Message template class to format dynamic messages with JUnit 5 tests.
import java.util.Map;
import java.util.regex.MatchResult;
import java.util.regex.Pattern;
public final class TemplateMessage {
private static final Pattern MESSAGE_ARGUMENT_PATTERN = Pattern.compile("\\$\\{([^}]+?)}");
private final String template;
public TemplateMessage(final String template) {
@seyfahni
seyfahni / profiler_functions.php
Created February 18, 2021 16:53
Some functions for low-effort profiling. Exchange microtime with hrtime when using PHP >=7.3
<?php
function profiler_start($flag) {
global $profiler_stack;
$profiler_stack[] = [
'flag' => $flag,
'start' => microtime(true),
];
}
@seyfahni
seyfahni / toggle-keyboard-led.sh
Created July 21, 2020 07:18
CoolerMaster Devastator LED flag toggle script
#!/bin/sh
flags=$(xset -q | awk 'NR==2' | awk '{ print $10 }')
if test "$flags" = ffffe7fe
then
xset led off
else
xset led on
fi
@seyfahni
seyfahni / download_latest_papermc_server.sh
Created June 30, 2020 16:33
Launch to download the latest papermc.io minecraft server jar.
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
latest_version=$(wget -q -O - https://papermc.io/api/v1/paper | jq -r '.versions[]' | sort -Vr | head -n1)
latest_build=$(wget -q -O - https://papermc.io/api/v1/paper/$latest_version | jq -r '.builds.latest')
echo "loading server binary for minecraft version $latest_version build $latest_build"
wget -q -O "paper-$latest_version-$latest_build.jar" "https://papermc.io/api/v1/paper/$latest_version/$latest_build/download"
@seyfahni
seyfahni / readlink_fix.sh
Created May 26, 2020 09:44
readlink -f on every system
@seyfahni
seyfahni / docker.sh
Last active March 31, 2020 12:54
Work in your project inside any docker container, path aware and execute optional given command.
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
DOCKER_IMAGE="composer:latest"
name="project_$(date "+%Y%m%d_%H%M%S_%N")"
# Get this projects root directory by analysing the location of this script
# it is assumed that this script is inside a direct subdirectory, e.g. project-root/scripts/docker.sh