Redis is very performant, due to performance consideration, sometimes we need to use Redis as a database, when querying a redis database, we need to consider indexing and filtering.
We can use SortedSet as Index.
// EDIT: 2013/10/20 | |
// google has updated its kwt UI, this script doesn't work any more! | |
// may be I will update this script when I have time to investigate their new Interface. | |
// requires | |
var utils = require('utils'); | |
var casper = require('casper').create() | |
var casper = require('casper').create({ | |
verbose: true, |
[ | |
{ | |
"label": "内网网关地址", | |
"name": "gateway", | |
"value": "10.86.30.1" | |
}, | |
{ | |
"label": "上班打卡时间范围", | |
"name": "clockInRange", | |
"value": "07:00-11:00" |
! function (t) { | |
if ("object" == typeof exports && "undefined" != typeof module) module.exports = t(); | |
else if ("function" == typeof define && define.amd) define([], t); | |
else { | |
("undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this).buffer = t() | |
} | |
}(function () { | |
return function () { | |
return function t(r, e, n) { | |
function i(f, u) { |
# EDIT: 2013/10/20 | |
# google has updated its kwt UI, this script doesn't work any more! | |
# may be I will update this script when I have time to investigate their new Interface. | |
from selenium import webdriver | |
from selenium.common.exceptions import TimeoutException | |
import selenium.webdriver.support.wait | |
selenium.webdriver.support.wait.POLL_FREQUENCY = 0.05 | |
import re |
import sys | |
from gevent import server | |
from gevent.baseserver import _tcp_listener | |
from gevent.monkey import patch_all; patch_all() | |
from multiprocessing import Process, current_process, cpu_count | |
def note(format, *args): | |
sys.stderr.write('[%s]\t%s\n' % (current_process().name, format%args)) |
seeing this puzzle in glowing's jobs page
https://glowing.com/jobs/mobiledeveloper#mtop
here's my solution
import time | |
from collections import deque | |
def throttled_call(func, args=(), kwargs={}, threshold_per_minute=60): | |
"""Throttling the function call with ``threshold_per_minute`` calls per minute. | |
This is useful when the function request a remote service that having throttling policy. | |
We must honor the throttling, otherwise we will be banned. | |
:param func: the function to be called |
def chop(matrix, box, direction, results=None): | |
if results is None: | |
results = [] | |
x1, y1, x2, y2 = box | |
w = x2 - x1 + 1 | |
h = y2 - y1 + 1 | |
if w <= 0 or h <= 0: | |
return results | |
else: | |
if direction == 0: |