Skip to content

Instantly share code, notes, and snippets.

View Xyene's full-sized avatar
🦆

Tudor Brindus Xyene

🦆
View GitHub Profile
@Xyene
Xyene / Random.java
Created January 25, 2013 20:35
Faster implementation of java.util.Random.
/**
* A random number generator based on the simple and fast xor-shift pseudo
* random number generator (RNG) specified in:
* Marsaglia, George. (2003). Xorshift RNGs.
* http://www.jstatsoft.org/v08/i14/xorshift.pdf
* Translated from:
* http://www.codeproject.com/Articles/9187/A-fast-equivalent-for-System-Random.
*/
@SuppressWarnings("SuspiciousNameCombination")
public class Random extends java.util.Random {
@Xyene
Xyene / I3-WSL-INSTALL.txt
Created December 12, 2019 22:43
Instructions for installing i3 on WSL (https://github.com/Xyene/wsl-dotfiles/)
# These instructions assume a clean install of a Debian image from the Windows store
sudo mkdir /code
sudo chmod 777 /code
cd /code
sudo apt install -y git vim
git clone https://github.com/Xyene/wsl-dotfiles.git
cd wsl-dotfiles
@Xyene
Xyene / Morse.java
Last active July 17, 2019 13:31
Possibly the most concise String -> Morse code converter / player possible in Java.
package jmorse;
import java.io.*;
import java.util.*;
import javax.sound.sampled.*;
public class Morse {
private static final int DOT = 200, DASH = DOT * 3, FREQ = 800;
private static String[] morse = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."};
@Xyene
Xyene / ReflectCommand.java
Created November 7, 2012 23:13
Dynamic Reflection-Based Command Registrator & Handler
import com.google.common.collect.Sets;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.SimplePluginManager;
import java.lang.annotation.ElementType;
@Xyene
Xyene / list2cmdline.c
Created April 20, 2018 23:42
Port of Python's `subprocess.list2cmdline` to C.
#define MAX_CMDLINE 8191
wchar_t result[MAX_CMDLINE];
memset(result, 0, sizeof(result));
BOOL needquote = FALSE;
for (int i = 2; i < argc; i++) {
wchar_t *arg = argv[i];
wprintf(L"arg %d = %ls\n", i, arg);
from piazza_api import Piazza
import time
import requests
import json
EMAIL = 'you@mail.utoronto.ca'
PASSWORD = 'hunter2'
WEBHOOK_URL = 'https://hooks.slack.com/services/#####/##########'
CLASS_NAME = 'CSC209'
NETWORK_ID = 'jbcmehb923110u'

Keybase proof

I hereby claim:

  • I am Xyene on github.
  • I am tbrindus (https://keybase.io/tbrindus) on keybase.
  • I have a public key whose fingerprint is A820 1E45 7FA2 F46C 8E6D 64DB 68D2 26AF B0EA 8BAB

To claim this, I am signing this object:

@Xyene
Xyene / ErrorLogger.java
Last active December 1, 2017 17:58
ErrorLogger - Better Error Logging
import net.minecraft.server.v1_4_R1.CrashReport;
import net.minecraft.server.v1_4_R1.MinecraftServer;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_4_R1.CraftServer;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginLogger;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;

Setting up the Judge on Windows

Windows 10 Anniversary Update

This is the recommended way to run the DMOJ on Windows, but requires the Windows Subsystem for Linux (WSL) that was added in the Windows 10 Anniversary Update. You will need to enable the subsystem before proceeding.

Open Bash by tying bash in command prompt, or running it directly.

We'll need a couple of packages to get started, after which we can begin setting up the judge.

init.yml specifies signatures for all methods, e.g.:

    int findSwapPairs(int, int[], int, int[])
    functions:
        findSwapPairs: (I[II[I[I[I[I)I

There are two types of functions: functions that the grader calls from C->Java, and functions that Java calls that are implemented in C. The latter is slightly easier to discuss.

We can autogenrate Java classes binding those methods statically, e.g.: