Skip to content

Instantly share code, notes, and snippets.

@zhangchunlin
zhangchunlin / prun
Created August 5, 2014 08:11
prun, a little tool to run cmds parallel.
#! /usr/bin/env python
#coding=utf-8
import gevent
from gevent.subprocess import Popen, PIPE
import sys
def run(cmd,name="",index=1,color=True):
fc = 32 + index%5
if name:
@zhangchunlin
zhangchunlin / UliPad.desktop
Last active August 29, 2015 14:03
ulipad linux desktop file
[Desktop Entry]
Exec=python /home/zhangclb/oss/ulipad/UliPad.pyw
Name=UliPad
Path=/home/zhangclb/oss/ulipad/
StartupNotify=true
Terminal=false
Type=Application
X-KDE-SubstituteUID=false
Icon=/home/zhangclb/oss/ulipad/ulipad.ico
#! /usr/bin/env python
#coding=utf-8
import re
import os
import sys
import shutil
import types
import time
import socket
@zhangchunlin
zhangchunlin / master.py
Created April 1, 2014 03:26
gevent master slave example
#! /usr/bin/env python
#coding=utf-8
import gevent
from gevent.server import StreamServer
from gevent.queue import Queue
import json
def sendmsg2fobj(fobj,msg):
@zhangchunlin
zhangchunlin / tmp.py
Last active March 11, 2016 00:47
tmp
from gevent.pywsgi import WSGIServer
def application(environ, start_response):
status = '200 OK'
headers = [
('Content-Type', 'text/html')
]
start_response(status, headers)
@zhangchunlin
zhangchunlin / genmani.py
Created November 5, 2013 02:45
repo manifest
#! /usr/bin/env python
#coding=utf-8
MANIFEST_HEADER = r'''<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote fetch="https://github.com/" name="github" review="review.cyanogenmod.org"/>
<default remote="github" revision="refs/heads/cm-10.2"/>
'''
@zhangchunlin
zhangchunlin / avalon-ajax-example.js
Last active December 25, 2015 08:39
avalon ajax example
var model = avalon.define("test", function(vm) {
vm.array =[]
})
$.ajax({
type:"GET",
url:"xxx",
success:function(json){
model.array = json.list || []
}
})
@zhangchunlin
zhangchunlin / setiptables.py
Created December 23, 2011 09:46
a little python script using to set iptables
#! /usr/bin/env python
#coding=utf-8
#----config part----
INIT_CMDS = ["iptables -F",#clean all
"iptables -X",
"iptables -t nat -F",
"iptables -t nat -X",
"iptables -P INPUT DROP",#forbid all
"iptables -A INPUT -i lo -j ACCEPT"#accept all localhost