Skip to content

Instantly share code, notes, and snippets.

jamiesun jamiesun

Block or report user

Report or block jamiesun

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jamiesun
jamiesun / daemon.py
Created Jul 12, 2012
一个python守护进程的例子
View daemon.py
#! /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
@jamiesun
jamiesun / gevent-multiprocess
Created Sep 8, 2012
gevent wsgi服务器定义,可利用多进程
View gevent-multiprocess
class GEventServer():
""" gevent wsgi服务器定义,可利用多进程
"""
def __init__(self,handler,host,port):
self.handler = handler
self.host = host
self.port = port
def start(self):
@jamiesun
jamiesun / log_test11.py
Created Apr 1, 2018 — forked from anonymous/log_test11.py
Test script showing usage of a buffering SMTP handler.
View log_test11.py
#!/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
@jamiesun
jamiesun / udpserver.py
Created May 25, 2014
tornado UDP server
View udpserver.py
#!/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):
@jamiesun
jamiesun / nextid.py
Created May 18, 2014
生成有时间规则的id
View nextid.py
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]))
View paginator.py
#!/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):
@jamiesun
jamiesun / rsa_aes.py
Created Dec 18, 2016 — forked from ficapy/rsa_aes.py
pycrypto使用AES/RSA加解密
View rsa_aes.py
# !/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')
@jamiesun
jamiesun / centos7.sh
Created Sep 11, 2016 — forked from yyang/centos7.sh
centos 7 pptpd firewalld
View centos7.sh
#!/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.
View echoserver.py
#!/usr/bin/env python
#coding:utf-8
import sys, os, re
import logging
from tornado.ioloop import IOLoop
from tornado.iostream import IOStream
from tornado.netutil import TCPServer
@jamiesun
jamiesun / redis
Created Jan 12, 2014
redis service script
View redis
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
#
# redis This is the init script for starting up the Redis server
#
# chkconfig: 2345 85 15
# description: Starts and stops the redis daemon that handles \
# all redis session requests.
You can’t perform that action at this time.