Skip to content

Instantly share code, notes, and snippets.

View zqqf16's full-sized avatar
:electron:
Focusing

zqqf16 zqqf16

:electron:
Focusing
View GitHub Profile
@zqqf16
zqqf16 / gen_manifest.py
Created March 16, 2014 13:53
根据ipa包来生成Manifest的工具
#!/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">
@zqqf16
zqqf16 / jijin.py
Last active August 29, 2015 14:08
抓取基金收益信息
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals
import requests
import unicodedata
import re
from datetime import datetime
#!/bin/sh
PLIST_BUDDY=/usr/libexec/PlistBuddy
function add_compatibility() {
"$PLIST_BUDDY" -c "Add DVTPlugInCompatibilityUUIDs:10 string $2" \
"$1/Contents/Info.plist"
}
function has_compatibility() {
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import os
from datetime import datetime
FILE_NAME = 'messages.json'
class DataBase(object):
@zqqf16
zqqf16 / simple_regexp.c
Created June 6, 2013 15:13
一个简单的正则表达式匹配器,摘自《代码之美》第一章
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 December 20, 2015 03:09
A simple http server based on "SimpleHttpServer". Supports uploading files.
"""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 December 20, 2015 13:19
Implement the Levenshtein-distance algorithm.
#!/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 October 22, 2013 03:10
Get changed files from diff
#!/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 October 25, 2013 10:14
Print color in terminal
#!/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 December 28, 2015 07:59
获取天弘基金以及华夏基金最近5天收益信息
#!/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