Skip to content

Instantly share code, notes, and snippets.

@tiancheng91
tiancheng91 / jsonhandler.py
Last active August 29, 2015 14:26 — forked from mminer/jsonhandler.py
A JSON request handler for Tornado.
import json
import tornado.web
class JsonHandler(BaseHandler):
"""Request handler where requests and responses speak JSON."""
def prepare(self):
# Incorporate request JSON into arguments dictionary.
if self.request.body:
try:
@tiancheng91
tiancheng91 / osx.sh
Last active June 3, 2018 14:10
初始化脚本
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap caskroom/cask
brew tap caskroom/drivers
brew tap caskroom/versions
brew tap homebrew/core
brew tap homebrew/services
# set mirror
cd "$(brew --repo)"
@tiancheng91
tiancheng91 / mysql_low.cnf
Created March 9, 2015 02:02
mysql config for low memory vps
[mysqld]
# datadir = /var/lib/mysql
max_connections = 100
# wait_timeout = 180
# connect_timeout = 180
performance_schema = 0
# Maximum allowed size for a single HEAP (in memory) table. This option
@tiancheng91
tiancheng91 / nginx_laravel.conf
Last active August 29, 2015 14:14
nginx config for laravel app
server{
listen 80;
server_name laravel.com;
root /root/laravel/public;
index index.php index.html;
location / {
location /static/ {
access_log off;
expires 10d;
@tiancheng91
tiancheng91 / iptables_rules_simple
Last active March 4, 2017 04:29
iptables simple
# 1. Delete all existing rules
iptables -F
iptables -X
# 2. Set default chain policies
iptables -P INPUT DROP
# 3. Allow ssh
iptables -A INPUT -i eth0 -p tcp --dport 9022 -m state --state NEW,ESTABLISHED -j ACCEPT
# Modify this file accordingly for your specific requirement.
# http://www.thegeekstuff.com
# 1. Delete all existing rules
iptables -F
# 2. Set default chain policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
[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
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}