Skip to content

Instantly share code, notes, and snippets.

View Zephor5's full-sized avatar

Eric Zephor5

View GitHub Profile
  1. install zbar on windows with include and library files

  2. make sure mingw installed and bin directory added to the path

  3. in PYTHONPATH\Lib\distutils, create a file distutils.cfg and add two lines:

    [build]

    compiler=mingw32

  4. get dll lib and include file from ftp://sourceware.org/pub/pthreads-win32/dll-latest copy files to PATH_MINGW32/[lib,bin,include] separately, just need file name like pthreadGC2 and remember to chang the name to libpthread

  5. change or add lines in setup.py:

@Zephor5
Zephor5 / search_json.py
Last active November 12, 2015 03:09
a simple json search
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('->')
@Zephor5
Zephor5 / get_ip.py
Last active May 8, 2017 03:50
get the inner or public ip addr for linux sys
# 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
"""
@Zephor5
Zephor5 / kmp_algorithm.py
Last active October 23, 2018 06:50
kmp algorithm in python
#coding=utf-8
def kmp(s1, s2):
"""
search s1 in s2
"""
i = 0
j = 0
l1 = len(s1)
l2 = len(s2)
#!/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
#