Skip to content

Instantly share code, notes, and snippets.

@observerss
observerss / gist:3798922
Last active August 6, 2023 12:03
Google Keyword Tool Scraper(casperjs version)
// 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,
@observerss
observerss / index.conf
Created September 1, 2022 10:11
Hamibot飞书打卡
[
{
"label": "内网网关地址",
"name": "gateway",
"value": "10.86.30.1"
},
{
"label": "上班打卡时间范围",
"name": "clockInRange",
"value": "07:00-11:00"
@observerss
observerss / dmss.js
Created February 1, 2020 14:45
dmss
! 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) {
@observerss
observerss / gist:3798896
Last active May 8, 2020 03:50
Google Keyword Tool Scraper(selenium+python version)
# 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
@observerss
observerss / RedisAsDB.rst
Last active June 4, 2019 01:45
Redis as database: dealing with indexes and composite indexes

Using Reids As Database

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.

Single Index

We can use SortedSet as Index.

@observerss
observerss / gevent-multiprocess.py
Created September 26, 2012 07:55 — forked from denik/gevent-multiprocess.py
Python: Gevent multiprocessing server
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))
@observerss
observerss / GLOW_PUZZLE.md
Last active January 4, 2016 07:59
glowing's job puzzle
@observerss
observerss / throttled_call.py
Created October 12, 2013 03:24
Python snippet that throttles a function call. This is useful when the function request a remote service that having throttling policy. We must honor the throttling, otherwise we will be banned.
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:

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install: