Skip to content

Instantly share code, notes, and snippets.

View iamsk's full-sized avatar
🎯
Focusing

Bin iamsk

🎯
Focusing
View GitHub Profile
@iamsk
iamsk / words
Created May 11, 2013 08:54
words.txt
a[ei, ә]art.一个
an[әn, æn]art.一个
ability[ә'biliti]n.能力,才干
able['eibl]a.有才能的,能够的
about[ә'baut]prep.关于
above[ә'bʌv]prep.在…之上
accident['æksidәnt]n.意外;偶然事故
according to[әˌkɔ:diˌ tu:]依照
achieve[ә'tʃi:v]vt.完成
across[ә'krɔs]ad.交叉;横过
import requests
from db import db
"""
The Douban Group API which not display on http://developers.douban.com/wiki/?title=api_v2
Base url: https://api.douban.com/v2
Group info: /group/:id
@iamsk
iamsk / db
Created September 2, 2014 12:16
import sqlsoup
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
def singleton(cls, *args, **kwargs):
instances = {}
def get_instance():
if cls not in instances:
# -*- coding: utf-8 -*-
import os
import slugify
from selenium import webdriver
DIR = os.path.dirname(os.path.abspath(__file__))
def capture_with_proxy(url, proxy_url, username, password):
import unittest
I = 'I'
V = 'V'
X = 'X'
L = 'L'
C = 'C'
M = 'M'
from collections import defaultdict
def defaultdict2dict(d):
_d = {}
for k, v in d.items():
if isinstance(v, defaultdict):
_d[k] = defaultdict2dict(v)
else:
_d[k] = v
import collections
def sort_by_frequency_with_original_order_fake(_list):
"""
1. Sortd by frequency at first;
2. When some items have the same frequency, follow the original order. (failed!!!)
"""
counter = collections.Counter(_list)
_counter = sorted(counter.items(), key=lambda t: t[1], reverse=True)

local branches

List local branches which have been merged in master

git branch --merged master

Remove these local merged branches, make sure you are on master and updated to newest

#!-*- coding:utf-8 -*-
import re
from pdfminer.pdfparser import PDFParser
from pdfminer.pdfdocument import PDFDocument
from pdfminer.pdftypes import resolve1
from pdfrw import PdfReader