Skip to content

Instantly share code, notes, and snippets.

Avatar

dequn dequn

View GitHub Profile
@dequn
dequn / file_lock.py
Created Dec 17, 2017
A custom-file-lock wrapper for fcntl in python
View file_lock.py
#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秒钟.
View log.py
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 / lsyncd.service
Created May 8, 2018 — forked from Finkregh/lsyncd.service
systemd-service file for lsyncd
View lsyncd.service
[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`'
@dequn
dequn / channels.py
Created Jun 30, 2018
channel layers subscribe redis and using outside of consumer
View channels.py
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 / nginx.conf
Created Aug 17, 2018 — forked from lciolecki/nginx.conf
Nginx config for django rest framework + angular application
View nginx.conf
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 / aliyun_sms_api.py
Last active Aug 24, 2018
阿里云短信api url构造
View aliyun_sms_api.py
import base64
import datetime
import hashlib
import hmac
import json
import urllib.parse
import uuid
access_key_id = ''
access_secret = ''
@dequn
dequn / huginn_wechat_public_subscribers.json
Created Aug 1, 2019
Huginn 微信公众号订阅 scenario
View huginn_wechat_public_subscribers.json
{
"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 / huginn_wechat_public_subscribers_v2.json
Created Aug 3, 2019
Huginn抓取微信公众号文章,只能抓取最近一篇,20190803更新
View huginn_wechat_public_subscribers_v2.json
{
"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",
You can’t perform that action at this time.