Skip to content

Instantly share code, notes, and snippets.

View AllanWang's full-sized avatar

Allan Wang AllanWang

View GitHub Profile
@AllanWang
AllanWang / flyweight.kt
Last active December 26, 2018 04:49
Kotlin Flyweight
/**
* Flyweight to keep track of values so long as they are valid.
* Values that have been fetched within [maxAge] from the time of use will be reused.
* If multiple requests are sent with the same key, then the value should only be fetched once.
* Otherwise, they will be fetched using [fetcher].
* All requests will stem from the supplied [scope].
*/
class Flyweight<K, V>(
val scope: CoroutineScope,
val maxAge: Long,
@AllanWang
AllanWang / hw2_test.ml
Created October 4, 2017 02:35
Tester for Assignment 2 - Comp 302 - Fall 2017
(*
Test code for hw1 - Comp 302
*Warning* - I have no prior experience with OCaml.
If you encounter an issue that is not obviously solvable, let me know;
I may have made a mistake!
To use this, put this file in the same drectory as your hw1.ml,
launch ocaml, and execute:
```
@AllanWang
AllanWang / C202Y2017A1.java
Created September 28, 2017 02:45
Comp 202 - 2017 - Assignment 1 Tester
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Allan Wang on 2017-09-27.
* <p>
* Tester class for Comp 202, Fall 2017, Assignment 1
* You may choose to run tasks selectively by commenting
* out the method you don't want to run
@AllanWang
AllanWang / UniversalComparator.java
Last active September 21, 2017 21:33
UniversalComparator
package test;
import com.sun.istack.internal.NotNull;
import java.util.Comparator;
/**
* Created by Allan Wang on 2017-09-21.
*/
public class UniversalComparator implements Comparator<UniversalComparator.Card> {
@AllanWang
AllanWang / hw1-test.ml
Last active September 21, 2017 02:16
Comp 302 Assignment 1 Tester Code
(*
Test code for hw1 - Comp 302
*Warning* - I have no prior experience with OCaml.
If you encounter an issue that is not obviously solvable, let me know;
I may have made a mistake!
To use this, put this file in the same drectory as your hw1.ml,
launch ocaml, and execute:
```
package com.pitchedapps.theme.tools;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**