Skip to content

Instantly share code, notes, and snippets.

@tiancheng91
tiancheng91 / tornado.lock.event.py
Last active January 20, 2017 07:58
Tornado Demo
from tornado import gen
from tornado.ioloop import IOLoop
from tornado.locks import Event
event = Event()
@gen.coroutine
def waiter():
print("Waiting for event")
yield event.wait()
@tiancheng91
tiancheng91 / robots.txt
Created December 26, 2016 07:06
robots example
User-agent: Baiduspider
Crawl-delay: 1
Allow: /article
Disallow: /
User-Agent: Googlebot
Crawl-delay: 1
Allow: /article
Disallow: /
@tiancheng91
tiancheng91 / redsocks.conf
Created November 19, 2016 18:47 — forked from afriza/redsocks.conf
Setup iptables for RedSocks in OpenWRT
base {
// debug: connection progress & client list on SIGUSR1
log_debug = on;
// info: start and end of client session
log_info = on;
/* possible `log' values are:
* stderr
* file:/path/to/file
@tiancheng91
tiancheng91 / promise.js
Created November 4, 2016 01:43 — forked from wavded/promise.js
Promise A+ Implementation
"use strict"
var Promise = function () {
this.state = 'pending'
this.thenables = []
}
Promise.prototype.resolve = function (value) {
if (this.state != 'pending') return
this.state = 'fulfilled'
@tiancheng91
tiancheng91 / shell_bind_tcp.asm
Created November 2, 2016 11:21 — forked from geyslan/shell_bind_tcp.asm
Shell Bind TCP in Assembly (Linux/x86)
; This is a snippet of the original file in https://github.com/geyslan/SLAE/blob/master/1st.assignment/shell_bind_tcp.asm
global _start
section .text
_start:
; syscalls (/usr/include/asm/unistd_32.h)
; socketcall numbers (/usr/include/linux/net.h)
@tiancheng91
tiancheng91 / git.bash
Created September 29, 2016 01:54
git cheat sheet
# git svn
git svn clone -s repo (git svn init -T trunk -b branches -t tags repo)
git svn clone -T trunk repo
git svn clone -r 100:HEAD repo
git svn fetch
git svn rebase
git svn dcommit
branches = <svn-path>:<git-refspec>
branches = branches/*:refs/remotes/*
@tiancheng91
tiancheng91 / .env
Created July 9, 2016 15:09
常用环境变量
HOSTNAME=ip-72-167-112-17.ip.secureserver.net
RUBYPATH=/usr/bin
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
SSH_CLIENT=122.169.131.179 1742 22
SSH_TTY=/dev/pts/1
USER=amrood
JRE_HOME=/usr/java/jdk/jre
J2RE_HOME=/usr/java/jdk/jre
@tiancheng91
tiancheng91 / crawler.py
Created April 21, 2016 08:14 — forked from jmoiron/crawler.py
Simple gevent/httplib2 web crawler.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Simple async crawler/callback queue based on gevent."""
import traceback
import logging
import httplib2
import gevent
@tiancheng91
tiancheng91 / bash.sh
Last active November 30, 2015 07:46
常用脚本
# pip重新安装所有包
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
@tiancheng91
tiancheng91 / 01_Laravel 5 Simple ACL manager_Readme.md
Created November 13, 2015 01:31 — forked from amochohan/01_Laravel 5 Simple ACL manager_Readme.md
Laravel 5 Simple ACL - Protect routes by an account / role type

#Laravel 5 Simple ACL manager

Protect your routes with user roles. Simply add a 'role_id' to the User model, install the roles table and seed if you need some example roles to get going.

If the user has a 'Root' role, then they can perform any actions.

Installation

Simply copy the files across into the appropriate directories, and register the middleware in App\Http\Kernel.php