Skip to content

Instantly share code, notes, and snippets.

@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 / .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 / 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 / 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 / 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 / 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 / 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 / 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 / phantomjs,yml
Created January 26, 2017 09:45
pyspider docker conf
version: '2'
services:
phantomjs:
image: 'binux/pyspider:latest'
command: phantomjs
cpu_shares: 512
environment:
- 'EXCLUDE_PORTS=5000,23333,24444'
expose:
- '25555'
@tiancheng91
tiancheng91 / base62.py
Last active February 13, 2017 08:21
base62 encode
"""
Tiny
A reversible base62 ID obfuscater
Authors:
Jacob DeHart (original PHP version) and Kyle Bragger (Ruby port)
and Lee Semel (python port)
Usage:
obfuscated_id = to_tiny(123)
original_id = from_tiny(obfuscated_id)
Configuration: