Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Focusing

上山打老虎 zqqf16

:shipit:
Focusing
View GitHub Profile
@zqqf16
zqqf16 / t.py
Last active Sep 28, 2018
A command line translation tool.
View t.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import sys
import json
green = '\033[0;32m%s\033[0m: \033[0;34m%s\033[0m'
opener = urllib2.build_opener()
@zqqf16
zqqf16 / simple_regexp.c
Created Jun 6, 2013
一个简单的正则表达式匹配器,摘自《代码之美》第一章
View simple_regexp.c
int match(char *regexp, char *text)
{
if (regexp[0] == '^')
return matchhere(regexp+1, text);
do {
if (matchhere(regexp, text))
return 1;
} while (*text++ != '\0');
@zqqf16
zqqf16 / http.py
Last active Dec 20, 2015
A simple http server based on "SimpleHttpServer". Supports uploading files.
View http.py
"""Simple HTTP Server.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
Support upload files
"""
@zqqf16
zqqf16 / levenshtein.py
Last active Dec 20, 2015
Implement the Levenshtein-distance algorithm.
View levenshtein.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''Implement the Levenshtein-distance Algorithm'''
def levenshtein(source, dest):
'''Return the levenshteiin distance between source and dest'''
row_len = len(source) + 1
col_len = len(dest) + 1
@zqqf16
zqqf16 / getfile.py
Created Oct 22, 2013
Get changed files from diff
View getfile.py
#!/usr/bin/env python
import re
import sys
import argparse
FILE_RE = re.compile(r'^Index: (.*)$')
def get_files_from_diff(diff):
res = []
@zqqf16
zqqf16 / colorit.py
Created Oct 25, 2013
Print color in terminal
View colorit.py
#!/usr/bin/env python
#-*- coding: utf-8 -*-
__all__ = ['paint']
COLOR_FORMAT = '\033[%dm\033[%d;%dm%s\033[0m'
COLOR_NAME = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']
ATTRIBUTE_NAME = ['blod', 'underscore', 'blink', 'reverse', 'concealed']
@zqqf16
zqqf16 / crawl.py
Last active Dec 28, 2015
获取天弘基金以及华夏基金最近5天收益信息
View crawl.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import re
import requests
class Spider(object):
def __init__(self, url, pattern, encoding):
self.url = url
self.pattern = pattern
@zqqf16
zqqf16 / meta.py
Created Dec 26, 2013
A simple code to learn meta class.
View meta.py
#!/usr/bin/env python
class Meta(type):
def __new__(self, name, bases, attrs):
print('Meta: __new__: {} | {} | {} | {}'.format(self, name, bases, attrs))
return super(Meta, self).__new__(self, name, bases, attrs)
def __init__(cls, name, bases, attrs):
print('Meta: __init__: {} | {} | {} | {}'.format(cls, name, bases, attrs))
super(Meta, cls).__init__(name, bases, attrs)
@zqqf16
zqqf16 / get_scheme.sh
Last active Nov 5, 2018
Get the URL scheme from ipa file
View get_scheme.sh
#!/bin/bash
ipa_name=$1
plist_path=$(unzip -l "$ipa_name" | grep "Payload/[^/]*\/Info.plist" | sed 's/.*\(Payload.*Info.plist\)/\1/g')
#unzip
unzip -jo "$ipa_name" "$plist_path" >/dev/null
#convert to xml1 format
plutil -convert xml1 Info.plist
@zqqf16
zqqf16 / gen_manifest.py
Created Mar 16, 2014
根据ipa包来生成Manifest的工具
View gen_manifest.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
import shutil
import zipfile
import biplist
PLIST_STR = '''<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">