Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/env python
#coding=utf-8
import re
import os
import sys
import shutil
import types
import time
import socket
@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
@zhangchunlin
zhangchunlin / decorator_demo.py
Created August 25, 2014 06:25
python decorator demo
#! /usr/bin/env python
#coding=utf-8
#from http://www.cnblogs.com/rhcad/archive/2011/12/21/2295507.html
#第一步:最简单的函数,准备附加额外功能
def test1():
'''示例1: 最简单的函数,表示调用了两次'''
def myfunc():
@zhangchunlin
zhangchunlin / scancopyright.md
Last active August 29, 2015 14:08
Scancopyright install&usage

Scancopyright is a tool which can be used to scan copyright info of source code,you can use it to identity source code as GPL/other license or propriertary. I wrote it for the open source of our android source code. You can submit issue for improvement or questions.

Install

Scancopyright can be run cross platform(linux/windows...) in theory,but only linux installration is tested.

Install dependent modules

Scancopyright depend on python(2.6+)/uliweb/plugs/sqlalchemy,you should install them firstly. Example steps in ubuntu:

@zhangchunlin
zhangchunlin / views.py
Created July 31, 2015 13:14
uliweb gevent long polling test
#coding=utf-8
from uliweb import expose, functions
import gevent
from gevent.queue import Queue, Empty
import json as json_
data_source = Queue()
@zhangchunlin
zhangchunlin / snippet.txt
Created December 4, 2015 02:25
postgresql hot standby replication
[1]
listen_addresses = 'localhost,IP_address_of_THIS_host'
wal_level = 'hot_standby'
archive_mode = on
archive_command = 'cd .'
max_wal_senders = 1
hot_standby = on
[2]
host replication rep 10.125.159.101/32 md5
@zhangchunlin
zhangchunlin / models.py
Last active December 4, 2015 02:44
linci.artifact models
#! /usr/bin/env python
#coding=utf-8
from uliweb.orm import *
import logging
log = logging.getLogger('linci.artifact')
class LinciArtifact(Model):
#artifact id = "%s-%s"%(asite,aindex)
@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 / 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 / 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)