Skip to content

Instantly share code, notes, and snippets.

View dequn's full-sized avatar

dequn dequn

  • PayPal
  • Shanghai, China
View GitHub Profile
@dequn
dequn / huginn_wechat_public_subscribers_v2.json
Created August 3, 2019 10:16
Huginn抓取微信公众号文章,只能抓取最近一篇,20190803更新
{
"schema_version": 1,
"name": "微信公众号订阅【第二版只有最新的一篇文章】",
"description": "2019.08.03 更新,最新可用",
"source_url": false,
"guid": "a0be876a712baf52fa4270d6b174443a",
"tag_fg_color": "#ffffff",
"tag_bg_color": "#00b050",
"icon": "eye",
"exported_at": "2019-08-03T10:05:30Z",
@dequn
dequn / huginn_wechat_public_subscribers.json
Created August 1, 2019 08:48
Huginn 微信公众号订阅 scenario
{
"schema_version": 1,
"name": "微信公众号订阅",
"description": "2019.08.01 更新,最新可用",
"source_url": "http://104.224.190.22:3000/scenarios/8/export",
"guid": "c0be876a712baf52fa4270d6b1744432",
"tag_fg_color": "#ffffff",
"tag_bg_color": "#00b050",
"icon": "eye",
"exported_at": "2019-08-01T08:46:10Z",
@dequn
dequn / aliyun_sms_api.py
Last active August 24, 2018 06:09
阿里云短信api url构造
import base64
import datetime
import hashlib
import hmac
import json
import urllib.parse
import uuid
access_key_id = ''
access_secret = ''
@dequn
dequn / nginx.conf
Created August 17, 2018 08:19 — forked from lciolecki/nginx.conf
Nginx config for django rest framework + angular application
server {
listen 80;
listen 443 ssl;
server_name your-domain.com;
charset utf-8;
client_max_body_size 32M;
root /project/static;
index index.html;
@dequn
dequn / channels.py
Created June 30, 2018 06:36
channel layers subscribe redis and using outside of consumer
def handle(self, *args, **options):
redis = get_redis_connection()
ps = redis.pubsub()
ps.subscribe([RELAY_CONTROL_RESULT_CHANNEL])
for item in ps.listen():
if item['type'] == 'message':
data = item['data']
equipment_id, return_state = data.decode('ascii').split(':')
# equipment_id is group name
@dequn
dequn / lsyncd.service
Created May 8, 2018 01:51 — forked from Finkregh/lsyncd.service
systemd-service file for lsyncd
[Unit]
Description=Live Syncing (Mirror) Daemon
After=network.target
[Service]
Restart=always
Type=simple
Nice=19
#EnvironmentFile=-/etc/default/lsyncd
#ExecStart=/usr/bin/sh -c 'eval `/usr/bin/lsyncd -nodaemon $LSYNCD_OPTIONS /etc/lsyncd/lsyncd.conf.lua`'
import os
import logging
import logging.handlers
def init_log(log_path, level=logging.INFO, when="D", backup=7,
format="%(levelname)s: %(asctime)s: %(filename)s:%(lineno)d * %(thread)d %(message)s",
datefmt="%m-%d %H:%M:%S"):
"""
init_log - initialize log module
@dequn
dequn / file_lock.py
Created December 17, 2017 02:03
A custom-file-lock wrapper for fcntl in python
#coding: utf-8
import os
import time
import fcntl
import contextlib
import logging
@contextlib.contextmanager
def open_file(filename, pattern = 'r', timeout = 5):
""" 以加锁的方式读取文件,尝试timeout * 10 次,每次sleep 1秒钟.