Skip to content

Instantly share code, notes, and snippets.

View axiaoxin's full-sized avatar
🌙
不忙着圆缺 春天不走远

axiaoxin axiaoxin

🌙
不忙着圆缺 春天不走远
View GitHub Profile
@axiaoxin
axiaoxin / snmpsimd.supervisor.conf
Created March 2, 2018 03:38
snmpsimd.supervisor.conf
[program:snmpsimd]
command=snmpsimd.py --process-user=root --process-group=root --agent-udpv4-endpoint=0.0.0.0:161
process_name=%(program_name)s ; process_name expr (default %(program_name)s)
numprocs=1 ; number of processes copies to start (def 1)
;directory=/tmp ; directory to cwd to before exec (def no cwd)
;umask=022 ; umask for process (default None)
priority=999 ; the relative start priority (default 999)
autostart=true ; start at supervisord start (default: true)
startsecs=1 ; # of secs prog must stay up to be running (def. 1)
startretries=3 ; max # of serial start failures when starting (default 3)
@axiaoxin
axiaoxin / celery_tasks_error_handling.py
Created January 30, 2018 08:41 — forked from darklow/celery_tasks_error_handling.py
Celery tasks error handling example
from celery import Task
from celery.task import task
from my_app.models import FailedTask
from django.db import models
@task(base=LogErrorsTask)
def some task():
return result
class LogErrorsTask(Task):
@axiaoxin
axiaoxin / change_commit_author.sh
Created December 22, 2017 08:41
change_commit_author.sh
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL=""
CORRECT_NAME="axiaoxin"
CORRECT_EMAIL="254606826@qq.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
@axiaoxin
axiaoxin / yield协程
Created December 21, 2017 02:49
yield协程
# -*- coding: utf-8 -*-
import random
def get_data():
"""返回0到9之间的3个随机数,模拟异步操作"""
return random.sample(range(10), 3)
def consume():
"""显示每次传入的整数列表的动态平均值"""
running_sum = 0
@axiaoxin
axiaoxin / ngx_lua_restructure_influxdb_response.conf
Last active December 13, 2017 10:36
wrap some json fields for influxdb api response by nginx_lua
upstream influxdb{
server 127.0.0.1:8086;
}
server {
listen 18086;
proxy_pass_request_headers off; # handle gziped capture <https://github.com/openresty/lua-nginx-module/issues/12>
location / {
proxy_pass http://influxdb/query;
@axiaoxin
axiaoxin / strace.twisted.txt
Created November 27, 2017 12:43
strace.twisted.txt
14480 18:37:23 sendto(15, "<9>Nov 27 18:37:23 apiserver-1: [-] Temporarily disabling observer LegacyLogObserverWrapper(<bound method MyLoggingObserver.emit of <uni.app.MyLoggingObserver object at 0x31f0650>>) due to exception: [Failure instance: Traceback: <type 'exceptions.RuntimeError'>: maximum recursion depth exceeded while calling a Python object", 326, MSG_NOSIGNAL, NULL, 0) = 326
14480 18:37:23 sendto(15, "<9>Nov 27 18:37:23 apiserver-1: [-] \t/usr/lib64/python2.7/traceback.py:124:print_exception", 90, MSG_NOSIGNAL, NULL, 0) = 90
14480 18:37:23 sendto(15, "<9>Nov 27 18:37:23 apiserver-1: [-] \t/usr/lib64/python2.7/traceback.py:13:_print", 80, MSG_NOSIGNAL, NULL, 0) = 80
14480 18:37:23 sendto(15, "<9>Nov 27 18:37:23 apiserver-1: [-] \t/tmp/zm/lib/python2.7/site-packages/twisted/logger/_io.py:170:write", 104, MSG_NOSIGNAL, NULL, 0) = 104
14480 18:37:23 sendto(15, "<9>Nov 27 18:37:23 apiserver-1: [-] \t/tmp/zm/lib/python2.7/site-packages/twisted/logger/_logger.py:132:emit", 107, MSG_NOSIGNAL, NULL, 0) = 1
@axiaoxin
axiaoxin / daemon.md
Created November 7, 2017 09:26 — forked from andreif/daemon.md
A simple unix/linux daemon in Python

A simple unix/linux daemon in Python

Source: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

Access: http://web.archive.org/web/20131025230048/http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

by Sander Marechal

I've written a simple Python class for creating daemons on unix/linux systems. It was pieced together for various other examples, mostly corrections to various Python Cookbook articles and a couple of examples posted to the Python mailing lists. It has support for a pidfile to keep track of the process. I hope it's useful to someone.

@axiaoxin
axiaoxin / daemon.py
Created November 7, 2017 09:23 — forked from marazmiki/daemon.py
Python daemon example
#!/usr/bin/env python
# coding: utf-8
import argparse
import os
import sys
import time
import atexit
import logging
import signal
@axiaoxin
axiaoxin / 活动一下.xml
Created October 12, 2017 06:43
活动一下.xml
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2017-09-15T18:09:42.7298</Date>
<Author>ashinchen-PC0\Administrator</Author>
<Description>活下去</Description>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<Repetition>
@axiaoxin
axiaoxin / 桂林行程计划.txt
Last active July 13, 2017 07:47
桂林行程计划
### line1->line5->深圳北
27d 07:30前必须出门
### 深圳北->桂林北->龙脊梯田
27d 09:04从深圳北出发到广州南换乘,10:12从广州南出发12:50到达桂林北。坐100路到桂林站(一个小时左右)新凯悦酒店或香江饭店附近14:30左右上车 入住龙胜龙脊景园山庄  
COMMENT: 入住安排勉强可以,山上很多住宿,可以再往景点走些,道路曲折,尽快打电话让人出来带路