Skip to content

Instantly share code, notes, and snippets.

View Shengaero's full-sized avatar
🔎
Looking for work

Kaidan Gustave Shengaero

🔎
Looking for work
View GitHub Profile
@Shengaero
Shengaero / URLRegexWalkthrough.md
Created October 20, 2022 20:56
URL Regex Walkthrough

URL Regex Walkthrough

One of the biggest challenges of programming with web interfaces and various web applications is consistently parsing through URLs.

It can often be incredibly difficult and messy to find certain pieces of a URL, or even just simply determining if a user input is a URL to begin with.

Thankfully most general purpose programming languages these days have built in or third party libraries that allow usage of matchers called Regular Expressions (often called "regex" or "regexp"). These handy character sequences allow developers to easily detect and parse through strings fitting a particular pattern.

Summary

In this gist, I'll be breaking down one to help with URLs:

@Shengaero
Shengaero / ratelimiterPOC.kt
Created November 9, 2018 23:12
Simple Proof of Concept for a kotlin-coroutine based rate-limiter API
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import org.junit.jupiter.api.*
import java.util.concurrent.TimeUnit
import kotlin.coroutines.CoroutineContext
import kotlin.math.min
import kotlin.system.measureTimeMillis
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue
@Shengaero
Shengaero / annotation.kt
Created April 18, 2018 21:27
Annotation Property Delegate for Kotlin JVM
/*
* Copyright 2018 Kaidan Gustave
*
* 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
@Shengaero
Shengaero / CoroutineEventWaiter.kt
Created March 26, 2018 23:04
Example implementation of IEventWaiter
import kotlinx.coroutines.experimental.*
import net.dv8tion.jda.core.events.Event
import net.dv8tion.jda.core.hooks.EventListener
import org.slf4j.Logger
import xyz.laxus.util.collections.concurrentSet
import xyz.laxus.util.createLogger
import xyz.laxus.util.ignored
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.TimeUnit
import kotlin.coroutines.experimental.CoroutineContext
@Shengaero
Shengaero / JSONGuildSettings.java
Last active February 11, 2018 17:55
GuildSettingsManager and GuildSettingsProvider example implemenations using JSON
/*
* Copyright 2016-2018 John Grosh (jagrosh) & Kaidan Gustave (TheMonitorLizard)
*
* 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
@Shengaero
Shengaero / catalogue.md
Last active November 19, 2017 00:05
A catalogue of various submitted CSS stylesheets for the MHGHApp

How to Submit

DM Shengaero#9090 with the following.

  1. The unique name of your CSS stylesheet.
  2. Any pictures of your CSS to use as a preview (otherwise I have to take them myself).
  3. The CSS file upload.
  4. Any credits if it's an adaptation of another CSS.

Very low effort CSS will not be accepted, please try to do something with it.

@Shengaero
Shengaero / stylesheet-guide.md
Last active November 18, 2017 22:26
A cheatsheet for MHGHApp CSS stylesheet elements

A Quick Forword On This Gist

This gist is for people who are willing to learn some basic skills regarding Cascading Style Sheets to create their own custom CSS for the MHGHApp.

In it we will have a quick overview of what CSS looks like, how to properly write it, and some examples of how you can apply it to the MHGHApp layout.

I know what some of you are thinking: "... But wait... Isn't this supposed to be a cheatsheet?"

@Shengaero
Shengaero / intellij_vcs_guide.md
Last active September 18, 2018 05:05
A starters guide to using the Version Control System (VCS) in Intellij IDEA

Cloning a repository from GitHub locally

First open Intellij's starting window and find the Checkout from Version Control drop-down menu:

If this is your first time doing anything like this, you'll more than likely be asked to provide your GitHub account username and password to gain access to the GitHub VCS features. >

@Shengaero
Shengaero / change_avy.js
Last active October 30, 2017 04:17
A nashorn script to change a JDA bot's avatar.
IOException = Java.type("java.io.IOException");
InputStream = Java.type("java.io.InputStream");
URL = Java.type("java.net.URL");
URLConnection = Java.type("java.net.URLConnection");
Icon = Java.type("net.dv8tion.jda.core.entities.Icon");
function downloadImage(url) {
try {
var u = new URL(url);
var urlConnection = u.openConnection();
@Shengaero
Shengaero / SimpleHL.java
Last active November 15, 2017 23:52
Logback configuration similar in style to SimpleLog format
package path.to; // Make sure to replace this with the path to the file in your project.
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.pattern.color.ForegroundCompositeConverterBase;
import static ch.qos.logback.core.pattern.color.ANSIConstants.*;
import static ch.qos.logback.classic.Level.*;
/**
* A simple highlighter for console text using logback classic.
*