Skip to content

Instantly share code, notes, and snippets.

View DRSchlaubi's full-sized avatar

Michael Rittmeister DRSchlaubi

View GitHub Profile
@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 / Arrays.kt
Created February 5, 2022 18:21
Exposed support for arrays
import org.jetbrains.exposed.sql.Column
import org.jetbrains.exposed.sql.ColumnType
import org.jetbrains.exposed.sql.CustomStringFunction
import org.jetbrains.exposed.sql.EqOp
import org.jetbrains.exposed.sql.Expression
import org.jetbrains.exposed.sql.ExpressionWithColumnType
import org.jetbrains.exposed.sql.Table
import org.jetbrains.exposed.sql.statements.api.PreparedStatementApi
import org.jetbrains.exposed.sql.statements.jdbc.JdbcPreparedStatementImpl
import org.jetbrains.exposed.sql.stringLiteral
@DRSchlaubi
DRSchlaubi / kotlin.xml
Last active May 27, 2022 01:34
Proper kotlin inspections
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Kotlin Inspection Pack" />
<inspection_tool class="AddOperatorModifier" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="AddVarianceModifier" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="ConvertLambdaToReference" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ConvertPairConstructorToToFunction" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="Destructure" enabled="true" level="SERVER PROBLEM" enabled_by_default="true" />
<inspection_tool class="FromClosedRangeMigration" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="ImplicitThis" enabled="true" level="SERVER PROBLEM" enabled_by_default="true" />
@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
@DRSchlaubi
DRSchlaubi / Info.java
Created November 27, 2021 04:03
Update keys in java files using gradle
public class Info {
public static final String VERSION = "@VERSION@";
}
@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
@DRSchlaubi
DRSchlaubi / GoogleFuture.kt
Created September 21, 2021 16:19
GoogleFutureUtil
package dev.schlaubi.util
import com.google.api.core.ApiFuture
import com.google.common.util.concurrent.MoreExecutors
import kotlinx.coroutines.CancellableContinuation
import kotlinx.coroutines.suspendCancellableCoroutine
import java.util.concurrent.ExecutionException
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
@DRSchlaubi
DRSchlaubi / package-list
Created September 28, 2020 19:29
Spigot mc api package list
org.bukkit
org.bukkit.advancement
org.bukkit.attribute
org.bukkit.block
org.bukkit.block.banner
org.bukkit.block.data
org.bukkit.block.data.type
org.bukkit.block.structure
org.bukkit.boss
org.bukkit.command
@DRSchlaubi
DRSchlaubi / why_its_better.java
Created April 11, 2021 20:01
Java 8 is outdated ;)
// alt
void onCommand(CommandSender sender) {
if (sender instanceof Player) {
Player player = (Player) sender;
}
}
// neu
void onCommand(CommandSender sender) {
if (sender instanceof Player player) {
@DRSchlaubi
DRSchlaubi / jda
Created March 31, 2021 16:37
Package-lists
net.dv8tion.jda.annotations
net.dv8tion.jda.api
net.dv8tion.jda.api.audio
net.dv8tion.jda.api.audio.factory
net.dv8tion.jda.api.audio.hooks
net.dv8tion.jda.api.audit
net.dv8tion.jda.api.entities
net.dv8tion.jda.api.events
net.dv8tion.jda.api.events.channel.category
net.dv8tion.jda.api.events.channel.category.update