Skip to content

Instantly share code, notes, and snippets.

View keweishang's full-sized avatar
🐳

Kewei Shang keweishang

🐳
  • bolt.eu
  • Tallinn, Estonia
  • 20:08 (UTC +03:00)
  • X @keweishang
View GitHub Profile
@keweishang
keweishang / JsonFormatter.java
Created April 9, 2018 13:16
My stupid JsonFormatter
/**
* Format a JSON string and make it more readable
* Created by kshang on 20/04/2017.
*/
public class JsonFormatter {
public String format(String input) {
StringBuilder sb = new StringBuilder();
char[] chars = input.toCharArray();
boolean inQuote = false;
#!/usr/bin/python
# docdist8.py - treat whole file as a single "line"
#
# Original version by Erik D. Demaine on January 31, 2011,
# based on code by Ronald L. Rivest (see docdist[1-7].py).
#
# Usage:
# docdist8.py filename1 filename2
#
# This program computes the "distance" between two text files
@keweishang
keweishang / ListFactory.java
Created April 12, 2016 21:11
Compiled version
public class ListFactory {
public ListFactory() {
super();
}
public static List newInstance(final int[] numbers) {
return new ListFactory$1(numbers);
}
}
@keweishang
keweishang / ListFactory.java
Last active April 12, 2016 21:22
Original version
public class ListFactory {
public static List<Integer> newInstance(final int[] numbers) {
return new AbstractList<Integer>() {
@Override
public Integer get(int index) {
return numbers[index];
}