Skip to content

Instantly share code, notes, and snippets.

@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 / AioPool.md
Last active August 29, 2015 14:16
Gevent pool/group alike in python3 asyncio

Gevent Pool/Group Alike in Python3 Asyncio

Python3 Asyncio implements an event loop, but in quite low level, it's missing some basic helpers that can make your life a lot easier.

The Pool and Group are typical missing ones. Compare these codes below

Simple Loop

  • without group
{
"metadata": {
"name": "",
"signature": "sha256:f7fc0e66200bb5a9cae8e5e59abfaa99691caa881252e9266f11e7cffc7dafe6"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@observerss
observerss / GLOW_PUZZLE.md
Last active January 4, 2016 07:59
glowing's job puzzle
@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 / 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:

#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db