Skip to content

Instantly share code, notes, and snippets.

View DRSchlaubi's full-sized avatar

Michael Rittmeister DRSchlaubi

View GitHub Profile
@DRSchlaubi
DRSchlaubi / EnvironmentVariable.kt
Last active January 18, 2021 19:10
Small helper class forenvironment variable based configs
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
/**
* Helper class that allows you to specify a [prefix] for your whole config.
*
* Is intended to be used via composition or via inheritance
*/
public open class EnvironmentConfig internal constructor(private val prefix: String) {
@DRSchlaubi
DRSchlaubi / ConfigurationSerializer.java
Last active August 20, 2020 19:48
Bukit config serializer
package org.wlosp.varo;
import com.google.common.base.Preconditions;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import java.io.IOException;
import java.nio.ByteBuffer;
@DRSchlaubi
DRSchlaubi / app-build.gradle.kts
Last active April 14, 2024 15:00
Flutter Kotlin Gradle DSL
import java.util.Properties
import java.nio.file.Files
val localProperties = Properties()
val localPropertiesFile = rootProject.file("local.properties").toPath()
if (Files.exists(localPropertiesFile)) {
Files.newBufferedReader(localPropertiesFile).use { reader ->
localProperties.load(reader)
}
}
@DRSchlaubi
DRSchlaubi / zip.kt
Last active April 16, 2022 17:33
Kotlin zip utils
/*
* Copyright 2020 Michael Rittmeister
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
# java.lang.NullPointerException
# at net.guterdeveloper.luckyblocksbattle.LuckyBlocksBattle.initVoting(LuckyBlocksBattle.java:59) -[?:?]
# at net.guterdeveloper.luckyblocksbattle.LuckyBlocksBattle.init(LuckyBlocksBattle.java:48) ~[?:?]
# at net.guterdeveloper.luckyblocksbattle.LuckyBlocksBattle.onEnable(LuckyBlocksBattle.java:43) -[?:?]
# at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[server.jar:git-Spigot-dbóde12-18fbb24]
@DRSchlaubi
DRSchlaubi / niggelstream.kts
Created April 20, 2020 19:01
file fixer 3001
import java.nio.file.Files
import java.nio.file.Paths
Files.walk(Paths.get("lib/"), Integer.MAX_VALUE).forEach {
if (!Files.isDirectory(it)) {
val oldName = it.toFile().name
val newName = if (oldName.isPotentialPascalCase) {
oldName.pascalCase()
} else oldName
Files.move(it, it.parent.resolveSibling(newName.toString()))
@DRSchlaubi
DRSchlaubi / fdsfds
Created March 12, 2020 16:51
cool gist
fds
@DRSchlaubi
DRSchlaubi / main.dart
Created March 9, 2020 19:23
dart sublist
void main() {
var list = [1,2,3,4,5,6,7,78,9];
print(list.sublist(0, list.length));
print(list.sublist(0, list.length - 1));
}
void main() {
var list = [1,2,3,4,5,6,7,78,9];
print(list.sublist(0, list.length));
print(list.sublist(0, list.length - 1));
}
@DRSchlaubi
DRSchlaubi / config.json
Created June 2, 2019 13:06
RulesBot json
{
"json": "TOKEN",
"database": {
"host": "localhost",
"user": "rulesbot",
"database": "rules_bot",
"password": "IfYouReadThatYouAreDumb"
},
"statuspage": null,
"botlists": null