-
install zbar on windows with include and library files
-
make sure mingw installed and bin directory added to the path
-
in PYTHONPATH\Lib\distutils, create a file distutils.cfg and add two lines:
[build]
compiler=mingw32
-
get
dll
lib
andinclude
file from ftp://sourceware.org/pub/pthreads-win32/dll-latest copy files toPATH_MINGW32/[lib,bin,include]
separately, just need file name likepthreadGC2
and remember to chang the name tolibpthread
-
change or add lines in
setup.py
:
This file contains hidden or 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
def search_json(data, s): | |
""" | |
search in json | |
example data is {"items": [{"url": "1"}, {"url": "2"}]} | |
s is items->[]->url then get ["1", "2"] | |
s is items->[0]->url then get ["1"] | |
:rtype: generator | |
""" | |
structs = s.split('->') |
This file contains hidden or 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
# coding=utf-8 | |
def get_ip(inner=True): | |
""" | |
get local ip addr | |
default get inner ip address, set `inner` to False to | |
get public ip if exists, or it will return None | |
it returns 'localhost' when failed | |
""" |
This file contains hidden or 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
#coding=utf-8 | |
def kmp(s1, s2): | |
""" | |
search s1 in s2 | |
""" | |
i = 0 | |
j = 0 | |
l1 = len(s1) | |
l2 = len(s2) |
This file contains hidden or 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 python | |
# | |
# Converts any integer into a base [BASE] number. I have chosen 62 | |
# as it is meant to represent the integers using all the alphanumeric | |
# characters, [no special characters] = {0..9}, {A..Z}, {a..z} | |
# | |
# I plan on using this to shorten the representation of possibly long ids, | |
# a la url shortenters | |
# |