This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def parse_column(line): | |
cols = line.split('\t') | |
col_count = len(cols) | |
if col_count == 13: | |
return cols | |
elif col_count == 12: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Main { | |
abstract class Tree | |
case class Sum(l: Tree, r: Tree) extends Tree | |
case class Var(n: String) extends Tree | |
case class Const(v: Int) extends Tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import codecs | |
import re | |
f = codecs.open('freq.txt', 'r', 'utf-8') | |
data = f.read() | |
f.close() | |
freq = {} | |
for word in re.findall(r'\w+', data, re.UNICODE): | |
if not word in freq: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pandoc \ | |
--latex-engine=xelatex \ | |
--template=template.tex \ | |
-V geometry:margin=1.25in \ | |
-o Final\ Paper.pdf \ | |
Final\ Paper.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char* concat(char *s, char *t) { | |
char strbuf[BUF_SIZE]; | |
strcpy(strbuf, s); | |
strcpy(strbuf+strlen(s), t); | |
return strbuf; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def substrings(s): | |
n = len(s) | |
for i in xrange(0, n): | |
for j in xrange(i+1, n+1): | |
yield s[i:j] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ps aux | grep translator/apache | awk '{ mem+=$6 } END { print mem } ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |