Skip to content

Instantly share code, notes, and snippets.

View limboinf's full-sized avatar
🎯
Focusing

limbo limboinf

🎯
Focusing
View GitHub Profile
@limboinf
limboinf / Thread_MinIn_server.py
Created May 11, 2016 13:33
在套接字服务器中使用ThreadingMinIn类
# coding=utf-8
"""
在套接字服务器中使用ThreadingMinIn类
:copyright: (c) 2016 by fangpeng(@beginman.cn).
:license: MIT, see LICENSE for more details.
"""
import os
import socket
import threading
import SocketServer
@limboinf
limboinf / .gitconfig
Last active May 20, 2016 02:26 — forked from samsalisbury/.gitconfig
Git diff and merge with p4merge (OSX)
[merge]
keepBackup = false
tool = p4merge
[mergetool "p4merge"]
cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$PWD/$BASE\"" "\"$PWD/$REMOTE\"" "\"$PWD/$LOCAL\"" "\"$PWD/$MERGED\""
keepTemporaries = false
trustExitCode = false
keepBackup = false
[diff]
tool = p4merge
@limboinf
limboinf / go_file_print.go
Created May 26, 2016 02:35
golang print file content
//打印文件内容
package main
import (
"bufio"
"bytes"
"fmt"
"os"
"io"
"path/filepath"
@limboinf
limboinf / simple_http_v1.py
Last active May 31, 2016 09:52
Python implements a simple http server (version 1.0, blocking socket.)
# coding=utf-8
"""
简单的HTTP服务器 V1
:copyright: (c) 2016 by fangpeng(@beginman.cn).
:license: MIT, see LICENSE for more details.
"""
import socket
EOL1 = b'\n\n'
EOL2 = b'\n\r\n'
@limboinf
limboinf / simple_http_v2.py
Last active May 31, 2016 10:01
Python implements a http server by epoll(version 2.0, epoll, level-triggered)
# coding=utf-8
"""
:copyright: (c) 2016 by fangpeng(@beginman.cn).
:license: MIT, see LICENSE for more details.
"""
import socket
import select # select模块带有epoll功能
EOL1 = b'\n\n'
EOL2 = b'\n\r\n'
@limboinf
limboinf / simple_http_v2.1.py
Created May 31, 2016 10:16
Python implements a http server by epoll(version 2.1, epoll, edge-triggered)
# coding=utf-8
"""
:copyright: (c) 2016 by fangpeng(@beginman.cn).
:license: MIT, see LICENSE for more details.
"""
import socket
import select
EOL1 = b'\n\n'
EOL2 = b'\n\r\n'
@limboinf
limboinf / simple_http_v2.2.py
Created May 31, 2016 10:29
Python implements a http server by epoll(version 2.2, epoll, level-triggered, TCP_CORK)
# coding=utf-8
"""
TCP_CORK 参数可以设置缓存消息直到一起被发送
这个选项, 在下例中的45和53行使用
适合给一个实现 http/1.1pipelining 的服务器来使用.
:copyright: (c) 2016 by fangpeng(@beginman.cn).
:license: MIT, see LICENSE for more details.
"""
import socket
@limboinf
limboinf / 00-hello-web.py
Created June 17, 2016 03:02
Base webServer.
# coding=utf-8
"""
desc..
:copyright: (c) 2015 by fangpeng.
:license: MIT, see LICENSE for more details.
"""
__date__ = '16/6/17'
import BaseHTTPServer
# coding=utf-8
"""
This version responds to HTTP requests with static HTML files or
directory listings.
* Run with `python server.py .` (or some other base directory name).
* Point browser at `http://localhost:8080/some/path`.
Usage:
curl localhost:9000/demo.html
@limboinf
limboinf / decorator-wraper-inspect.py
Created June 28, 2016 13:16
装饰器会用一个动态创建的新函数替换原来的。然而新函数缺少很多原函数的属性,如__doc__, __name__等,需要 from functools import wraps 复制这些属性给装饰器。 inspect模块运行提取函数的签名,如参数。
# coding=utf-8
"""
装饰器会用一个动态创建的新函数替换原来的。
然而新函数缺少很多原函数的属性,如__doc__, __name__等,
需要 from functools import wraps 复制这些属性给装饰器。
inspect模块运行提取函数的签名,如参数。
:copyright: (c) 2016 by fangpeng(@beginman.cn).
:license: MIT, see LICENSE for more details.