Skip to content

Instantly share code, notes, and snippets.

View oiuww09fn's full-sized avatar

bob oiuww09fn

View GitHub Profile
@oiuww09fn
oiuww09fn / hash_set.go
Created January 6, 2015 14:41
hash_set // go并发编程实战
package set
import (
"bytes"
"fmt"
)
type HashSet struct {
m map[interface{}]bool
}
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import fcntl
import sys
import time
def lockFile(f):
try:
@oiuww09fn
oiuww09fn / SquareService.wsdl
Last active November 9, 2015 06:51
wsdl2py -f SquareService.wsdl && wsdl2dispatch -f SquareService.wsdl http://pywebsvcs.sourceforge.net/holger.pdf
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="SquareService"
targetNamespace="http://services.zsiserver.net:8080/SquareService"
xmlns:tns="http://services.zsiserver.net:8080/SquareService"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="getSquareRequest">
<part name="x" type="xsd:double"/>
</message>
@oiuww09fn
oiuww09fn / remote_cmd.py
Last active November 9, 2015 06:53
Running command on remote machine.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from paramiko import SSHClient, AutoAddPolicy
class RemoteCMD(object):
def __init__(self):
self.client = None
<% had_seen = [] %>
% for i in data:
<%
if i["method"] in had_seen:
continue
else:
had_seen.append(i["method"])
%>Valid ${i["method"]}
[Documentation]
%for j in i["cmd"]:
@oiuww09fn
oiuww09fn / caipiao.py
Last active November 9, 2015 06:55
parse live.caipiao.163.com
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
soup = BeautifulSoup(requests.get("http://live.caipiao.163.com/jcbf/").text)
# soup = BeautifulSoup(requests.get("http://live.caipiao.163.com/dcbf/").text)
dd = soup.find_all("dd")
@oiuww09fn
oiuww09fn / read_xls.py
Created September 11, 2014 03:22
read xls, and return line by line.
def read_xls(filepath, encoding="cp1251"):
book = xlrd.open_workbook(filepath)
for sheetid in xrange(book.nsheets):
sheet = book.sheet_by_index(sheetid)
if not sheet:
raise RuntimeError("Sheet %i Not Found" % sheetid)
continue
for i in xrange(sheet.nrows):
row = [""] * sheet.ncols
ctys = sheet.row_types(i)
@oiuww09fn
oiuww09fn / module_package.md
Last active August 29, 2015 14:04
python module and package

模块

通常来说一个模块对应一个python源码文件,可通过sys.modules查看当前python解释器可导入的模块。

In [16]: sys.modules
{...
'sys': <module 'sys' (built-in)>,
'sysconfig': ,
@oiuww09fn
oiuww09fn / intro.md
Last active August 29, 2015 14:04
import this

安装及开发环境

  • 安装

  • 开发环境

  • 开发工具: 文本编辑器(记事本、sublimetext、vim……) + ipython

@oiuww09fn
oiuww09fn / encoding.py
Created July 23, 2014 14:06
robotframework encoding
# Copyright 2008-2014 Nokia Solutions and Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,