Skip to content

Instantly share code, notes, and snippets.

View cloverstd's full-sized avatar
🀄
Working for living

cloverstd cloverstd

🀄
Working for living
View GitHub Profile
@cloverstd
cloverstd / qiniu_download.sh
Created July 24, 2014 01:48
七牛批量下载
#!/bin/bash
key="infopush.debug.log.2014-07-"
suffix=".tar.gz"
for ((j=16; j<24; j++)); do
key_day=${key}${j}"-"
for ((i=0; i<24; i++)); do
if ((${i} < 10));then
key22="22/"${key_day}"0"${i}
@cloverstd
cloverstd / cache.py
Last active October 27, 2021 05:35
tornado cache
# coding: utf-8
try:
import cPickle as pickle
except ImportError:
import pickle
try:
import hashlib
sha1 = hashlib.sha1
# -*- coding: utf-8 -*-
# http://boxcar.io
# send message to mobile
__author__ = "Cloverstd"
import urllib
import urllib2
import json
@cloverstd
cloverstd / cache.py
Created November 25, 2013 14:23
Tornado Cache
# coding: utf-8
import redis
import functools
try:
import cPickle as pickle
except ImportError:
import pickle
try:
import hashlib
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
@cloverstd
cloverstd / app.py
Last active August 13, 2018 19:16
Tornado Session
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import tornado.web
import tornado.ioloop
import tornado.httpserver
from session import Session, RedisSessionBackend
import redis
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
[supervisord]
logfile=/var/log/supervisord/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=error ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false ; run supervisord as a daemon
@cloverstd
cloverstd / app.py
Created November 2, 2013 06:28 — forked from ayang/app.py
class Application(tornado.web.Application):
def __init__(self):
tornado.web.Application.__init__(self, handlers, **settings)
self.db_session = db_session
self.redis = redis.StrictRedis()
self.session_store = RedisSessionStore(self.redis)
class BaseHandler(tornado.web.RequestHandler):
# Torndb is a very thin wrapper around MySQLdb that makes it even easier to use MySQL.
# Because it is very light, one can just go through the one-file python source
# to learn how to use it.
# Installation: pip install torndb
# Official doc: http://torndb.readthedocs.org/en/latest/
# Source: https://github.com/bdarnell/torndb/blob/master/torndb.py
from torndb import Connection
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
class BaseHandler(tornado.web.RequestHandler):
pass
class HandlerMixin(object):
listeners = []