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
{-# LANGUAGE TemplateHaskell #-} | |
module Polysemy.Socket where | |
import Control.Exception (bracketOnError) | |
import Data.ByteString qualified as BS | |
import Network.Socket (AddrInfo (addrAddress), SockAddr, Socket, SocketOption (ReuseAddr), accept, bind, gracefulClose, listen, openSocket, setCloseOnExecIfNeeded, setSocketOption, withFdSocket) | |
import Network.Socket qualified as S | |
import Network.Socket.ByteString | |
import Polysemy (Member, Members, Sem, interpret, makeSem, pureT, reinterpretH) |
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
(ns enterprise.core | |
(:require [clojure.string :as str]) | |
(:gen-class)) | |
(def names ["event" "parameter" "factory" "service" "builder" "executor" "implementation" "impl" "predicate" "delegate" "resolver" "exporter" "abstract" "boostrap" "bean" "visitor" "method" "interpreter" "template" "advisor" "adapter" "object" "candiate" "context" "pattern" "exception" "component" | |
"utils" "mapper" "adapter" "pool" "response" "listener"]) | |
(def prefixes ["I" "Abstract" "Stub" "Mock" "Delegating" ""]) | |
(defn rand-prefix [] (rand-nth prefixes)) |
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 me.bristermitten.warzone.config.loading; | |
import com.google.gson.Gson; | |
import com.google.gson.TypeAdapter; | |
import com.google.gson.TypeAdapterFactory; | |
import com.google.gson.annotations.SerializedName; | |
import com.google.gson.reflect.TypeToken; | |
import com.google.gson.stream.JsonReader; | |
import com.google.gson.stream.JsonToken; | |
import com.google.gson.stream.JsonWriter; |
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
. |
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
/** | |
* Convert a second time to a "pretty" string | |
* Credit: https://stackoverflow.com/a/7663966 (modified for correct English if there's only 1 unit) | |
* @param seconds the time | |
* @return a pretty string | |
*/ | |
public static String getDurationBreakdown(long seconds) { | |
if (seconds < 0) { | |
throw new IllegalArgumentException("Duration must be greater than zero!"); | |
} |
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 me.bristermitten.enchant; | |
import org.bukkit.Bukkit; | |
import org.bukkit.NamespacedKey; | |
import org.bukkit.enchantments.Enchantment; | |
import org.bukkit.enchantments.EnchantmentTarget; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.block.BlockBreakEvent; | |
import org.bukkit.inventory.ItemStack; |
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 me.bristermitten.teamed.util | |
import java.util.concurrent.BlockingQueue | |
import java.util.concurrent.LinkedBlockingQueue | |
/** | |
* A buffer of objects with a fixed size. | |
* These objects cannot be reused so the given [compute] function is continuously run asynchronously | |
* to ensure that the buffer is always populated. | |
* If the objects are polled faster than [compute] can create new objects, |
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
public class Downloader { | |
public static void downloadKnightzAPI(Plugin yourPlugin) { | |
try { | |
URL gitHubURL = new URL("https://api.github.com/repos/knightzmc/knightzapi/releases/latest"); | |
HttpURLConnection connection = (HttpURLConnection) gitHubURL.openConnection(); | |
connection.setRequestMethod("GET"); | |
if (connection.getResponseCode() == 200) { | |
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); | |
String content = in.lines().collect(Collectors.joining()); |
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.Scanner; | |
class CoderbyteLongString { | |
private static final String REGEX = "[^0-9+a-z+A-Z ]*"; | |
public static String LongestWord(String sen) { | |
String[] words = | |
sen.replaceAll(REGEX, "") //filter out any characters that aren't a normal letter or number - remove punctuation |