Skip to content

Instantly share code, notes, and snippets.

@wangxiaodong
wangxiaodong / baidu_img_crawl.py
Created November 16, 2017 18:08
抓百度图片的
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import requests
import json
import time
import os
import hashlib
# 用的是就是改page_num下载需要的页数就好了
#!/usr/bin/env python
# -*- coding: utf8 -*-
import subprocess
import os
import threading
import time
import sys
rep = [("www.google.com/", "android.local/"),
@wangxiaodong
wangxiaodong / Terminal.sublime-settings
Last active August 28, 2015 03:12 — forked from dkordik/Terminal.sublime-settings
Sublime Text 2 Terminal config with mintty/cygwin/bash to open a terminal in the current directory
{
"terminal": "C:/cygwin/bin/mintty.exe",
"parameters": ["/bin/env", "CHERE_INVOKING=1", "/bin/xhere", "/bin/bash", "`%CWD%`"]
}
$ kill -9 `ps aux|grep -E "S.+python.+"|awk '{print $2}'`
s = "\u4F60\u8FD8\u6CA1\u9009\u4E2D\u8868\u60C5\uFF0C\u53EB\u6211\u600E\u4E48\u53D1\u9001\u554A\uFF1F"
def unicodeToString(uniString):
newString = uniString.split("\u")
ret = "".join([unichr(int(i, 16)).encode("utf8") for i in newString if i ])
print ret
return ret
unicodeToString(s)
大多数时候看到的unicode字符串都是带\u开头的,处理起来简单的静态的办法就是加入prefix `u`
@wangxiaodong
wangxiaodong / apt-get-install
Created May 5, 2015 09:35
apt-get install package from list
#!/bin/sh
if [ $USER != "root" ]; then
echo "The library installation must be under root user."
exit 1;
fi
PKGS="g++ gcc python-dev subversion git"
for pkg in $PKGS; do
@wangxiaodong
wangxiaodong / thunderUrl decoder
Created August 13, 2014 12:12
thunder url decoder
import base64
thunderUrl = raw_input("thunder url:")
header = "thunder://"
# thunderUrl = "thunder://QUFodHRwOi8vZGwxMTcuODBzLmxhOjkyMC8xNDA3L+S/oeWPty/kv6Hlj7dfaGQubXA0Wlo="
thunderUrl = thunderUrl[len(header):]
print base64.b64decode(thunderUrl)[2:-2]
@wangxiaodong
wangxiaodong / gist:6724361
Created September 27, 2013 04:58
条形码查询的一个可用网站api
POST /tiaoma/query.php HTTP/1.1
Host: www.liantu.com
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
ean=69012341
@wangxiaodong
wangxiaodong / PKCS7Encoder
Created September 11, 2013 02:12
PKCS7Encoder.py
class PKCS7Encoder():
"""
Technique for padding a string as defined in RFC 2315, section 10.3,
note #2
"""
class InvalidBlockSizeError(Exception):
"""Raised for invalid block sizes"""
pass
def __init__(self, block_size=16):
@wangxiaodong
wangxiaodong / makedoc.py
Created August 6, 2013 11:49
webpy make doc error webpy/tools/makedoc.py
# ori:
#def arg_string(func):
# """Returns a nice argstring for a function or method"""
# return inspect.formatargspec(*inspect.getargspec(func))
# the module tamplete :
# class Template ctor
# def __init__(self, text, filename='<template>', filter=None, globals=None, builtins=None, extensions=None):
# the '<' and '>' cause the html break
# using markdown.htmlquote replace '<' and '>'
# work profectly