Skip to content

Instantly share code, notes, and snippets.

# download latest libevent2 and tmux sources, and extract them somewhere
#
# at the time of writing:
# https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# http://downloads.sourceforge.net/tmux/tmux-1.7.tar.gz
#
# install deps
yum install gcc kernel-devel make ncurses-devel
@hyunjun
hyunjun / timeit.py
Last active August 29, 2015 14:05
timeit
# https://docs.python.org/2/library/timeit.html
>>> def foo(n):
... res = []
... for i in range(n): res.append(n)
... return res
...
>>> def foo2(n):
... return [i for i in range(n)]
...
>>> foo(10) == foo2(10)
@hyunjun
hyunjun / url2json.py
Created September 12, 2014 07:59
ValueError from url to json
import json
import re
import urllib
someUrl = '...'
f = urllib.urlopen(someUrl)
try:
myDict = json.load(f)
except ValueError:
# ValueError: Invalid control character at: line xxx column yyy (char zzz)
@hyunjun
hyunjun / socialite.md
Last active August 29, 2015 14:07
Socialite
@hyunjun
hyunjun / lxml.py
Last active August 29, 2015 14:08
python lxml
# -*- coding: utf8 -*-
# http://lxml.de/tutorial.html
from lxml import etree
with open('test.xml', 'r') as f:
'''doc = etree.parse(f)
for elem in doc.iter('*'):
print elem.tag, elem.text.encode('utf8')
for k, v in elem.items():
print ('\t%s\t%s' % (k, v)).encode('utf8')'''
@hyunjun
hyunjun / hangul_phoneme.py
Created November 5, 2014 07:52
python hangul
# -*- coding: utf8 -*-
# http://ask.python.kr/question/67705/%ED%95%9C%EA%B8%80%EC%9E%90%EC%86%8C%EB%B6%84%ED%95%B4-%EB%B0%A9%EB%B2%95/
# http://soooprmx.com/wp/archives/2165
# http://sugarcube.cvs.sourceforge.net/viewvc/sugarcube/plugins/HangulConvert/hangul.py
# https://kldp.org/node/116891?destination=node%2F116891
# http://warmz.tistory.com/717
# 유니코드 한글 시작 : 44032, 끝 : 55199
@hyunjun
hyunjun / numba.md
Last active August 29, 2015 14:09
numba

installation

  • http://numba.pydata.org/
  • http://continuum.io/downloads 사용이 편리
    • root로 설치할 필요 없음
  • centos 6.3에서 하나씩 설치해보려 했으나 dependency 문제로 실패
    ...
    python numba ImportError: No module named llvm.core
    ...
    http://www.llvmpy.org/llvmpy-doc/0.11.2/doc/getting_started.html#installation
    
@hyunjun
hyunjun / python_strip_punctuation_from_string.md
Created November 11, 2014 08:24
python strip punctuation from string
@hyunjun
hyunjun / addressbook.proto
Last active August 29, 2015 14:09
protocol-buffer
package tutorial;
message Person {
required string name = 1;
required int32 id = 2;
optional string email = 3;
enum PhoneType {
MOBILE = 0;
HOME = 1;