This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#coding=utf-8 | |
import socket | |
import os | |
import errno | |
from tornado.ioloop import IOLoop | |
from tornado.platform.auto import set_close_exec | |
class UDPServer(object): | |
def __init__(self, io_loop=None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python2.7 | |
#encoding:utf-8 | |
#@description:一个python守护进程的例子 | |
#@tags:python,daemon | |
import sys | |
import os | |
import time | |
import atexit | |
from signal import SIGTERM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#coding:utf-8 | |
import sys | |
import os | |
import subprocess | |
import time | |
class ToughError(Exception): | |
def __init__(self, message): | |
self.message = message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
def __next_id(): | |
_inum = [10000] | |
def _next(): | |
if _inum[0] >= 99999: | |
_inum[0] = 10000 | |
_inum[0] += 1 | |
_prefix = datetime.datetime.now().strftime('%Y%m%d%H%M%S') | |
return int("%s%s"%(_prefix,_inum[0])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ip route rule remove [find comment~"CNIP"] | |
/ip route rule { | |
add dst-address=1.0.1.0/24 src-address=10.79.0.0/24 table=main comment=CNIP; | |
add dst-address=1.0.2.0/23 src-address=10.79.0.0/24 table=main comment=CNIP; | |
add dst-address=1.0.8.0/21 src-address=10.79.0.0/24 table=main comment=CNIP; | |
add dst-address=1.0.32.0/19 src-address=10.79.0.0/24 table=main comment=CNIP; | |
add dst-address=1.1.0.0/24 src-address=10.79.0.0/24 table=main comment=CNIP; | |
add dst-address=1.1.2.0/23 src-address=10.79.0.0/24 table=main comment=CNIP; | |
add dst-address=1.1.4.0/22 src-address=10.79.0.0/24 table=main comment=CNIP; | |
add dst-address=1.1.8.0/21 src-address=10.79.0.0/24 table=main comment=CNIP; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GEventServer(): | |
""" gevent wsgi服务器定义,可利用多进程 | |
""" | |
def __init__(self,handler,host,port): | |
self.handler = handler | |
self.host = host | |
self.port = port | |
def start(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Copyright 2001-2002 by Vinay Sajip. All Rights Reserved. | |
# | |
# Permission to use, copy, modify, and distribute this software and its | |
# documentation for any purpose and without fee is hereby granted, | |
# provided that the above copyright notice appear in all copies and that | |
# both that copyright notice and this permission notice appear in | |
# supporting documentation, and that the name of Vinay Sajip | |
# not be used in advertising or publicity pertaining to distribution |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#coding=utf-8 | |
from __future__ import division | |
import math | |
class Paginator(): | |
"""系统查询分页工具 | |
""" | |
def __init__(self, url_func, page=1, total=0, page_size=20): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from Crypto.Cipher import PKCS1_v1_5 | |
from Crypto.PublicKey import RSA | |
from Crypto.Hash import SHA | |
from Crypto import Random | |
from Crypto.Cipher import AES | |
aes_obj_enc = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# pptpd installation script on my own CentOS 7 box. | |
# inspired by: https://www.digitalocean.com/community/questions/how-to-install-pptp-vpn-on-centos-7 | |
# and http://unix.stackexchange.com/questions/150837/redhat-centos-7-firewalld-best-practice-for-pptp-or-l2tp-ipsec-rules | |
# | |
# Author: 2015 Steve Yang <me@iyyang.com> | |
# The script comes with ABSOLUTELY NO WARRANTY. | |
NewerOlder