Skip to content

Instantly share code, notes, and snippets.

@Badbird5907
Badbird5907 / Unicode.java
Last active April 28, 2021 02:50
regex pattern to check if a string has unicode
public class Unicode{
public static boolean containsUnicode(String s){
//you're welcome i did it for you :D
Pattern p = Pattern.compile("[^a-z0-9~!@#$%^&*()_+-={}\\[\\]|:\";'<>?,./\\\\ ]", Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(s);
return m.find();
}
}
@Badbird5907
Badbird5907 / VelocityTemplateBuilder.java
Last active June 11, 2021 21:21
A builder I made for apache's velocity template
import lombok.Getter;
import lombok.Setter;
import spark.ModelAndView;
import spark.template.velocity.VelocityTemplateEngine;
import java.util.HashMap;
@Getter
@Setter
public class VelocityTemplateBuilder {
@Badbird5907
Badbird5907 / BoilerPlate.java
Created June 16, 2021 18:37
Boilerplate code to start a swing GUI
public BoilerPlate(){
JFrame frame = new JFrame();
JPanel panel = new JPanel();
frame.add(panel, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("title");
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | UnsupportedLookAndFeelException | IllegalAccessException | InstantiationException e) {
e.printStackTrace();
@Badbird5907
Badbird5907 / .gitignore
Created September 11, 2021 23:15
gitignore template
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
@Badbird5907
Badbird5907 / ROTCipher.java
Created September 22, 2021 03:20
ROT decoder/encoder
public class ROTCipher {
private static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz";
public static String encode(String text,int rotations){
String rotated = rotate(rotations);
rotated += rotated.toUpperCase();
String alphabet = ALPHABET + ALPHABET.toUpperCase();
StringBuilder sb = new StringBuilder();
for (char c : text.toCharArray()) {
String s = c + "";
if (s == " ")
@Badbird5907
Badbird5907 / Poll.java
Created October 20, 2021 15:25
OctoCord Polls
package net.octopvp.octocord.object;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.interactions.components.ActionRow;
import net.dv8tion.jda.api.interactions.components.Button;
import net.dv8tion.jda.api.interactions.components.Component;
@Badbird5907
Badbird5907 / EventManager.java
Created December 13, 2021 04:36
Event manager
import com.google.common.base.Preconditions;
import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.lang.reflect.InvocationTargetException;
@Badbird5907
Badbird5907 / config.yml
Last active December 5, 2023 01:23
GPTP Config
messages: # See https://docs.adventure.kyori.net/minimessage/format.html
claim-created: '<green>Claim created! Spawn block set to %1 %2 %3. You can change it by typing /setspawn.'
must-be-standing-in-claim: '<red>You must be standing in a claim!'
no-permission: '<red>You do not own this claim, or do not have permission to do that!'
teleporting: '<yellow>Teleporting in 5 seconds, don''t move...'
teleported: '<green>Teleported.'
moved: '<red>Pending teleportation request cancelled.'
damaged: '<red>Pending teleportation request cancelled.'
public-on: '<green>Your claim is now public!' # Add the '%1' placeholder for cost, if it is enabled. The placeholder system will be revamped in the future.
#For example: '<green>Your claim is now public!<red>-$%1.'
@Badbird5907
Badbird5907 / TDSB.md
Last active September 10, 2022 01:35
Mapping Out TDSB's App API
@Badbird5907
Badbird5907 / DmojQuestionCopier.user.js
Last active March 5, 2023 17:37
Dmoj Question Copier
// ==UserScript==
// @name DMOJ Question Copier
// @version 1.1
// @author Badbird5907
// @source https://gist.github.com/Badbird5907/7fd28dcda1c92d5393863743b23d26db
// @namespace badbird.dev
// @license MIT
// @description Adds a button to copy the current question to the clipboard on DMOJ problem pages.
// @match https://dmoj.ca/problem/*
// @grant GM_setClipboard