Skip to content

Instantly share code, notes, and snippets.

@qhhonx
qhhonx / ArrayExtensions.swift
Last active August 18, 2017 07:21
Implementations of lowerBound and upperBound for Array.
// Write some awesome Swift code, or import libraries like "Foundation",
// "Dispatch", or "Glibc"
extension Array where Element: Comparable {
func lowerBound(in range: CountableRange<Index>, for value: Element) -> Index {
return lowerBound(in: range, for: value, by: <)
}
func lowerBound(for value: Element) -> Index {
@qhhonx
qhhonx / TwoInheritedPathClassesMapping.swift
Last active August 3, 2017 09:14
Use Swift generic technique to implement two inherited path classes that behaves like dynamic synthesis in Objective-C.
// Write some awesome Swift code, or import libraries like "Foundation",
// "Dispatch", or "Glibc"
// +------------------------+ +------------------------+
// | | | |
// | AnimalViewController | - - - - - -> | AnimalViewModel |
// | | | |
// +------------------------+ +------------------------+
// ^ ^
// | |
@qhhonx
qhhonx / weibocn.py
Created November 3, 2014 07:55
weibo.cn登录助手(Login assist for weibo.cn)
# coding=utf8
from pyquery import PyQuery as pq
import requests
class Weibo(object):
""""Login Assist for weibo.cn"""
@qhhonx
qhhonx / weibo.py
Last active December 20, 2016 08:26
Login assist for Sina Weibo which can process verify code required situation.(新浪微博登录实现,包含验证码解析)
# coding=utf8
import base64
import binascii
import cookielib
import json
import os
import random
import re
import rsa
import time
@qhhonx
qhhonx / new_house.py
Last active September 20, 2016 05:36
爬取搜房网·新房·数据信息。 (Python Multi-threading requests BeautifulSoup)
#coding=utf8
import sys
__author__ = 'xohozu'
import Queue
import threading
import traceback
from time import sleep