Skip to content

Instantly share code, notes, and snippets.

View lisabug's full-sized avatar
😇
Focusing

Yuanqin Lu lisabug

😇
Focusing
View GitHub Profile
@lisabug
lisabug / default_list_value_in_dict.py
Created March 11, 2016 09:31
[Python] use list as dict default value
a_dict = {}
for i in xrange(100):
for j in xrange(100):
a_dict.setdefault(i, []).append(j)
def unsign32RightShift(num, sn):
return (num & (2**32-1)) >> sn
@lisabug
lisabug / java_String_hashcode.py
Created March 10, 2016 09:13 — forked from hanleybrand/java_String_hashcode.py
python function that produces the same result as java's String.hashCode() found at http://garage.pimentech.net/libcommonPython_src_python_libcommon_javastringhashcode/
def java_string_hashcode(s):
h = 0
for c in s:
h = (31 * h + ord(c)) & 0xFFFFFFFF
return ((h + 0x80000000) & 0xFFFFFFFF) - 0x80000000