Skip to content

Instantly share code, notes, and snippets.

View Xyene's full-sized avatar
🦆

Tudor Brindus Xyene

🦆
View GitHub Profile
@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 / 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);

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:

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'

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.:

@Xyene
Xyene / Makefile
Created July 3, 2016 16:56
Old ptbox files
CXX=g++
CXXFLAGS=-g -fPIC -Wall -O3 -march=native -I/usr/include/python$(PYVER) -D_FILE_OFFSET_BITS=64
LIBS=-lrt
SOURCES=ptbox.cpp ptdebug.cpp ptdebug32.cpp ptdebug64.cpp ptproc.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=ptbox
all: $(SOURCES) $(EXECUTABLE) _cptbox.so
$(EXECUTABLE): $(OBJECTS)
@Xyene
Xyene / __main__.py
Created July 1, 2016 17:20
WBox tests
import sys
import os
from dmoj.wbox.sandbox import WBoxPopen
def main():
dir = os.path.dirname(__file__)
print ' wbox Test Script'
@Xyene
Xyene / Structures.java
Created November 30, 2013 23:41
Dynamic structure allocator for JNA.
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
@Xyene
Xyene / conex.py
Created November 6, 2013 00:35
A bunch of methods to make your Windows Pythons console apps more flashy.
import ctypes
from ctypes.wintypes import *
from ctypes import *
# Standard colours
FOREGROUND_BLUE = 0x0001
FOREGROUND_GREEN = 0x0002
FOREGROUND_RED = 0x0004
FOREGROUND_INTENSITY = 0x0008
BACKGROUND_BLUE = 0x0010