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
class GemBox | |
attr_accessor :filPattern | |
def initialize(boxSize, gemPattern, targetPattern) | |
@boxSize = boxSize | |
@gemPattern = gemPattern | |
@filPattern = Hash.new | |
@targetPattern = targetPattern | |
@dayNum = 0 | |
end |
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
class SegmentPatternSearch | |
attr_accessor :patternCache | |
def initialize() | |
@segPattern = Array.new(10) | |
@segPattern[0] = '1111110' | |
@segPattern[1] = '0110000' | |
@segPattern[2] = '1101101' | |
@segPattern[3] = '1111001' | |
@segPattern[4] = '0110011' |
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
app.get('/proxy', function(req,res){ | |
var url, proxyReq, proxyRequest; | |
if (req.param('url')) { | |
url = require('url').parse(req.param('url')); | |
options = { | |
host: url.hostname, | |
port: '80', | |
path: url.pathname, | |
method: 'GET' |
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 pylab import * | |
gcf().canvas.mpl_connect('key_press_event', lambda event: event.key == 'q' and close(event.canvas.figure)) |
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
use Digest::MD5 qw(md5_hex); | |
use File::Slurp; | |
use utf8; | |
my @fileList = <STDIN>; | |
shift @fileList; |
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 heapq import heappush, heappop | |
def dijkstra(adjList,s): | |
num = len(adjList) | |
dist = [10**8 for i in range(num)] | |
prev = [-1 for i in range(num)] | |
queue = [] | |
heappush(queue,(0,s)) | |
dist[s] = 0 | |
while len(queue) != 0: |
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 os | |
nltkdata_wn = '/path/to/nltk_data/corpora/wordnet/' | |
wn31 = "http://wordnetcode.princeton.edu/wn3.1.dict.tar.gz" | |
if not os.path.exists(nltkdata_wn+'wn3.0'): | |
os.mkdir(nltkdata_wn+'wn3.0') | |
os.system('mv '+nltkdata_wn+"* "+nltkdata_wn+"wn3.0/") | |
if not os.path.exists('wn3.1.dict.tar.gz'): | |
os.system('wget '+wn31) | |
os.system("tar zxf wn3.1.dict.tar.gz -C "+nltkdata_wn) |
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
struct edge{ | |
int to; | |
int cost; | |
bool operator>(const edge &e)const{ | |
return cost > e.cost; | |
} | |
bool operator<(const edge &e)const{ | |
return cost < e.cost; |
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
# st = SegmentTree(n, lambda a,b: a if a > b else b) | |
class SegmentTree: | |
def __init__(self,n,f): | |
self.N = 1 | |
self.f = f | |
while(self.N < n): | |
self.N *= 2 | |
self.seg = [0] * (self.N * 2 -1) | |
def update(self,k,a): |
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
struct rootedtree{ | |
int V; | |
vector<vector<int> > T; | |
vector<vector<int> > parents; | |
vector<int> depth; | |
int log_N = 20; | |
rootedtree(int N, vector<vector<int> > &Tree){ | |
V = N; | |
T = Tree; |
OlderNewer