Skip to content

Instantly share code, notes, and snippets.

View sublee's full-sized avatar
✔️
Hello, world!

Heungsub Lee sublee

✔️
Hello, world!
View GitHub Profile
@sublee
sublee / result
Last active December 17, 2015 21:49
Python couchbase>=0.9 doesn't work with gevent.
version=0.8.0
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 0 1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
version=0.9
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
>>> worker1 = Worker('Hello, world')
>>> worker2 = Worker('Hello, world')
>>> spawn(worker1.run)
>>> spawn(worker2.run)
>>> remote_obj = customer.reflect([worker1, worker2])
>>> remote_obj
<Remote 'Hello, world'>
>>> remote_obj + '!'
'Hello, world!'
>>> remote_obj.startswith('Hell')
>>> cond = True
>>> pause = Pause(lambda: cond)
>>> def p1():
... print 'before pause'
... pause.wait()
... print 'after pause'
...
>>> def p2():
... global cond, pause
... time.sleep(0.5)
@sublee
sublee / chris.py
Last active December 15, 2015 00:59
# -*- coding: utf-8 -*-
from collections import namedtuple
from ranking import Ranking
Player = namedtuple('Player', ['score', 'weight'])
players = [Player(100, 1), Player(80, 1), Player(80, 2.5), Player(80, 2.5),
Player(70, 1), Player(60, 1.5), Player(60, 1.5)]
@sublee
sublee / comedy_big_league.py
Last active December 13, 2015 20:08
Comedy Big League TrueSkill ratings
# -*- coding: utf-8 -*-
"""
<`Comedy Big League`_ Season 4> TrueSkill rating calculator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This small code collects match results and calculate `TrueSkill`_ ratings
of the teams. The match results are provided from `Enhawiki mobile
mirror`_.
It depends on :mod:`trueskill`, :mod:`ranking`, :mod:`lxml` and
@sublee
sublee / regular_crossword.py
Last active December 12, 2015 06:19
Test suite for a regular crossword
# Question: http://www.coinheist.com/rubik/a_regular_crossword/grid.pdf
# My Answer: http://sphotos-h.ak.fbcdn.net/hphotos-ak-prn1/534798_4778312810689_972807554_n.jpg
import re
assert re.match(r'.*H.*H.*', 'NHPEHAS')
assert re.match(r'(DI|NS|TH|OM)*', 'DIOMOMTH')
assert re.match(r'F.*[AO].*[AO].*', 'FOXNXAXPH')
assert re.match(r'(O|RHH|MM)*', 'MMOMMMMRHH')
assert re.match(r'.*', 'MCXNMMCRXEM')
assert re.match(r'C*MC(CCC|MM)*', 'CMCCCCMMMMMM')
"""
spawn...
3.56747082911
builtin_function_or_method 100727
18.2844139451
dict 200500
20.1863144234
dict 300500
22.0894001079
dict 400500
@suite.test
def deprecated():
r1, r2, r3 = Rating(), Rating(), Rating()
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always', DeprecationWarning)
transform_ratings([(r1,), (r2,), (r3,)])
match_quality([(r1,), (r2,), (r3,)])
assert len(w) == 2
assert w[0].category is DeprecationWarning
assert w[-1].category is DeprecationWarning
@sublee
sublee / README.md
Last active October 10, 2015 18:58
WebOffice Login for Google Chrome

WebOffice Login for Google Chrome

소개

Google Chrome으로 WebOffice에서 출근체크할 수 있도록 해주는 사용자 스크립트입니다. 아주 빠른 Google Chrome으로 남들보다 빨리 출근해보세요.

만든이: 루팡팀 이흥섭

사용법

@sublee
sublee / quine.py
Created January 27, 2011 05:48
A quine in Python I made at 2007
x='print"x=\'%s\'\\n%s"%(x.replace("\\\\","\\\\\\\\").replace("\'","\\\\\'"),x)'
print"x='%s'\n%s"%(x.replace("\\","\\\\").replace("'","\\'"),x)