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
#!/bin/sh | |
set -e | |
sudo -s | |
apt-get update | |
apt-get install openjdk-6-jre openjdk-6-jdk mailtools git nginx build-essential -y | |
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add - | |
echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list | |
apt-get update | |
apt-get install jenkins -y |
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
# python 2+ | |
from itertools import takewhile, ifilter, izip, tee, starmap, chain | |
def uniq_substrings(origin): | |
suffixes = chain([""], sorted(tails(origin))) | |
return sum(starmap(suffix, pairwise(suffixes))) | |
def pairwise(iterable): | |
a, b = tee(iterable) | |
next(b, None) |
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
# python 2.7+ | |
from itertools import dropwhile, tee, izip | |
def repeatfunc(f, zero): | |
curr = zero | |
while 1: | |
yield curr | |
curr = f(curr) | |
def pairwise(origin): |
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
>>> (let (a=2, b=4) (a + b)) | |
6 | |
>>> (let (x=20, y=40, z=1) (x*y*z)) | |
800 |
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
# python 2.7+ | |
class Node(object): | |
def __init__(self, value, left, right): | |
self.value = value | |
self.left = left | |
self.right = right | |
def __iter__(self): | |
yield self.value |
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
$ mkdir p1 | |
$ cd p1/ | |
$ rebar create-app appid=hotdo | |
$ ls | |
$ mkdir deps | |
$ touch rebar.config | |
$ # feeling rebar config file | |
$ wget -O rebar.config https://gist.github.com/kachayev/5657307/raw/fb9b0cd0d62e053efe54774bf2033e6e651c6622/hotdo.rebar.config | |
$ rebar get-deps | |
$ tree -L 2 |
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
## More infromation about SkipList data structure one can find: | |
## on Wikipedia http://en.wikipedia.org/wiki/Skip_list | |
## on Stackoverflow http://stackoverflow.com/questions/256511/skip-list-vs-binary-tree | |
from math import log | |
from random import randint, random | |
class SkipNode(object): | |
__slots__ = "value", "next" |
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 Tkinter as tk | |
import time | |
from operator import itemgetter | |
from math import sqrt | |
from random import randint | |
from Queue import Queue | |
from threading import Thread | |
def vdist(q, (x1,y1), (x2,y2)): |
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
%% Pairing Heap implementation | |
%% more information on wiki: | |
%% http://en.wikipedia.org/wiki/Pairing_heap | |
%% pq :: {pq, heap(), int()} | |
%% heap :: nil | {Item, [heap()]} | |
%% ============================= | |
%% API | |
%% ============================= |
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
## Solve LCA taks with binary path method | |
## Complexity is <O(NlogN), O(logN)> | |
tree = { | |
0: [1,2], | |
1: [3,4,5], | |
2: [6,7,8,9], | |
3: [10,11,12,13], | |
4: [14,15], | |
5: [16,17,18,19,20], |