Skip to content

Instantly share code, notes, and snippets.

View suminb's full-sized avatar

Sumin Byeon suminb

View GitHub Profile
abstract class Tree
case class Add(l: Tree, r: Tree) extends Tree
case class Sub(l: Tree, r: Tree) extends Tree
case class Mul(l: Tree, r: Tree) extends Tree
case class Square(c:Const, b: Tree, e:Const) extends Tree
case class Var(n: String) extends Tree
case class Const(v: Int) extends Tree
trait Comparable {
def < (that: Any): Boolean
@suminb
suminb / pandoc.sh
Last active December 30, 2015 20:29
Pandoc LaTeX template for CJK
pandoc \
--latex-engine=xelatex \
--template=template.tex \
-V geometry:margin=1.25in \
-o Final\ Paper.pdf \
Final\ Paper.md
@suminb
suminb / defective.c
Last active December 30, 2015 17:59
Explain why the following code does not (always) work. Discuss, if there is any, potential security vulnerabilities.
char* concat(char *s, char *t) {
char strbuf[BUF_SIZE];
strcpy(strbuf, s);
strcpy(strbuf+strlen(s), t);
return strbuf;
}
@suminb
suminb / analytics.py
Last active December 22, 2015 10:49
Analytics
from multiprocessing import Pool
from collections import Counter
from operator import add, itemgetter
import os, sys
import csv
def substrings(s):
n = len(s)
for i in xrange(0, n):
@suminb
suminb / substrings.py
Created September 3, 2013 21:41
Compute all non-empty substrings of a given string
def substrings(s):
n = len(s)
for i in xrange(0, n):
for j in xrange(i+1, n+1):
yield s[i:j]
@suminb
suminb / memory_usage.sh
Last active December 20, 2015 19:19
Memory usage of Better Translator (in KB)
ps aux | grep translator/apache | awk '{ mem+=$6 } END { print mem } '
@suminb
suminb / histogram.sql
Created July 9, 2013 08:35
Better Translator translation demand histogram
SELECT CASE
WHEN text_length < 10 THEN '< 10'
WHEN text_length BETWEEN 10 AND 100 THEN '< 100'
WHEN text_length BETWEEN 100 AND 1000 THEN '< 1000'
WHEN text_length BETWEEN 1000 AND 10000 THEN '< 10000'
ELSE '> 10000' END AS length_bucket,
COUNT(*) AS qty
FROM (SELECT *, length(original_text) AS text_length FROM translation) AS t GROUP BY length_bucket;
# Takes any arbitray data, splits it into multiple peices and encode into QR code.
# python-qrcode package can be obtained from https://github.com/lincolnloop/python-qrcode
import qrcode
import base64
from multiprocessing import Pool
BLOCK_SIZE = 100 # in bytes
@suminb
suminb / pylint.txt
Created April 28, 2013 16:37
Pylint output example
************* Module spider.spider
C: 47,0: Line too long (90/80)
C:125,0: Line too long (87/80)
C:137,0: Line too long (94/80)
W: 74,0: FIXME: This does not cover all possible forms of URLs, but we'll
C: 1,0: Missing docstring
W: 1,0: Relative import 'proxy', should be 'spider.proxy'
W: 2,0: Relative import 'database', should be 'spider.database'
F: 5,0: Unable to import 'bs4'
W: 6,0: Relative import 'utils', should be 'spider.utils'
import java.net.URL;
import de.l3s.boilerpipe.extractors.ArticleExtractor;
public class Main {
public static void main(String[] args) throws Exception {
URL url = new URL("http://m.bbc.co.uk/news/science-environment-22307863");