This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.Objects; | |
/** | |
* A utility class that can be used to easily create String tables in Java without any extra frameworks. | |
* This can be useful to display table-like structures in Discord codeblocks, for example. | |
* | |
* <p>If framing is activated, the tables usually look like this (but with box drawing characters): | |
* <code> | |
* ------------------------------------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.johnnyjayjay.testplugin; | |
import org.bukkit.Bukkit; | |
import org.bukkit.event.Event; | |
import org.bukkit.event.EventPriority; | |
import org.bukkit.event.HandlerList; | |
import org.bukkit.event.Listener; | |
import org.bukkit.plugin.Plugin; | |
import java.util.function.Consumer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.dv8tion.jda.core.JDABuilder | |
import net.dv8tion.jda.core.events.GuildMessageReceivedEvent | |
import khttp.get | |
import org.json.JSONObject | |
fun main(args: Array<String>) { | |
JDABuilder("bot token").addEventListener(event -> { | |
if (event is GuildMessageReceivedEvent && event.guild.selfMember in event.message.mentionedMembers) { | |
val response = get("https://api.thecatapi.com/v1/images/search", headers = mapOf("x-api-key" to "key")) | |
val cat = (response.jsonArray[0] as JSONObject).getString("url") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.johnnyjayjay.titanbot.utils | |
import net.dv8tion.jda.core.EmbedBuilder | |
import net.dv8tion.jda.core.MessageBuilder | |
import net.dv8tion.jda.core.entities.Message | |
import net.dv8tion.jda.core.entities.MessageEmbed | |
import net.dv8tion.jda.core.entities.MessageEmbed.* | |
import java.awt.Color | |
import java.time.Instant | |
import java.time.temporal.TemporalAccessor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.TimeUnit; | |
import java.util.Map; | |
import java.util.HashMap; | |
import java.util.function.Function; | |
public class RateLimiter<T> { | |
private final long rateLimit; | |
private final Function<T, ?> keyMapper; | |
private final Map<?, Long> timestamps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.dv8tion.jda.api.events.GenericEvent; | |
import net.dv8tion.jda.api.hooks.EventListener; | |
import java.util.HashMap; | |
import java.util.HashSet; | |
import java.util.Map; | |
import java.util.Set; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.ScheduledExecutorService; | |
import java.util.concurrent.TimeUnit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import org.bukkit.command.*; | |
public final class DelegatingCommand implements CommandExecutor { | |
private final Map<String, ? extends CommandExecutor> children; | |
private final CommandExecutor defaultCase; | |
public DelegatingCommand(Map<String, ? extends CommandExecutor> children) { | |
this((s, c, l, a) -> false, children); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def duplicates(vigenere): | |
strings = [] | |
duplicates = set() | |
for index in range(len(vigenere)): | |
string = "" | |
for i in range(3): | |
if index + i < len(vigenere): | |
string += vigenere[index + i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extended_euclidian(a, b): | |
if b == 0: | |
return a, 1, 0 | |
gcd, s, t = extended_euclidian(b, a % b) | |
s, t = t, s - int(a / b) * t | |
return gcd, s, t | |
print("Alphabet length:") | |
length = int(input()) | |
print("Key:") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import string | |
def crypt(key, str): | |
x, n = key | |
return string.join([chr(c) for c in map(lambda element: (element ** x) % n, [ord(c) for c in str])]) | |
def get_primes(r): | |
primes = [] | |
for possible_prime in r: |
OlderNewer