Skip to content

Instantly share code, notes, and snippets.

View Scarsz's full-sized avatar
🐒
Programming Primate

Austin Shapiro Scarsz

🐒
Programming Primate
View GitHub Profile
@Scarsz
Scarsz / discord-minecraft-chat-color-table
Created March 12, 2016 01:41
Table for converting colors from Discord to Minecraft (roughly)
#99AAB5 &f
#1ABC9C &a
#2ECC71 &a
#3498DB &9
#9B59B6 &5
#E91E63 &d
#F1C40F &e
#E67E22 &6
#E74C3C &c
#95A5A6 &7
package com.scarsz;
import java.util.concurrent.TimeUnit;
public class Main {
public static void main(String[] args) {
long millis = TimeUnit.MINUTES.toMillis(37) + TimeUnit.SECONDS.toMillis(19);
String message = getDurationBreakdown(millis);
System.out.println(message);
<?php
define("GAME_DIR", "/home/steam/gmod_server/garrysmod");
define("CACHE_DIR", "./fastdl_cache"); // Must be in public folder, and must start with "."
define("SCAN_ADDONS", true);
define("SCAN_GAMEMODES", true);
define("ATTEMPTS_LOG_FILE", "./attempts.log");
$content_dirs = [
"maps",
"resource",
@Scarsz
Scarsz / download_imgs.js
Created November 6, 2016 23:33
JavaScript bookmarklet to get links to all imgs on the current page and optionally download them
(function() {
var images = [].slice.call(document.querySelectorAll('img'));
var urls = [];
images.forEach(function(img) {
if (!urls.includes(img.src)) urls.push(img.src);
});
if (confirm("Download all the things?")) {
var link = document.createElement('a');
link.setAttribute('download', '');
@Scarsz
Scarsz / mega-backup
Last active December 28, 2019 03:01
crontab-able nightly backup to mega.nz via megatools
#!/bin/bash
locationstocompress=( "/home" "/var/www" )
identifier="WEB-1"
megaemail="email@provider.com"
megapass="password"
# Edit below this if you're feeling lucky
masterfile="$identifier-$(date +"%Y-%m-%d").tar.gz"
package github.scarsz;
import org.bukkit.Material;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import java.util.HashMap;
// create an empty source file
File sourceFile = File.createTempFile("Hello", ".java");
sourceFile.deleteOnExit();
// generate the source code, using the source filename as the class name
String classname = sourceFile.getName().split("\\.")[0];
String sourceCode = "public class " + classname + "{ public void hello() { System.out.print(\"Hello world\");}}";
// write the source code into the source file
FileWriter writer = new FileWriter(sourceFile);
@Scarsz
Scarsz / BukkitGetOnlinePlayerCount.java
Created February 2, 2017 08:55
Backwards-compatible Server::getOnlinePlayers::size
private int getOnlinePlayers() {
try {
Method onlinePlayerMethod = Server.class.getMethod("getOnlinePlayers");
if (onlinePlayerMethod.getReturnType().equals(Collection.class)) {
return ((Collection<?>) onlinePlayerMethod.invoke(Bukkit.getServer())).size();
} else {
return ((Player[]) onlinePlayerMethod.invoke(Bukkit.getServer())).length;
}
} catch (Exception e) {
e.printStackTrace();
@Scarsz
Scarsz / PokemonGenerationThreeWithTypes.java
Created February 12, 2017 00:10
Pokemon generation 3 pokes with types
public enum PokemonGenerationThreeWithTypes {
Bulbasaur(Type.Grass, Type.Poison),
Ivysaur(Type.Grass, Type.Poison),
Venusaur(Type.Grass, Type.Poison),
Charmander(Type.Fire),
Charmeleon(Type.Fire),
Charizard(Type.Fire, Type.Flying),
Squirtle(Type.Water),
Wartortle(Type.Water),
@Scarsz
Scarsz / RandomObjectFromProbabilities.java
Last active June 12, 2018 14:47
Get a random object from a given map containing objects and their probabilities
package com.scarsz.playground;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Made by Scarsz