├── ConfigParser ├── cf_init.py ├── musite.py ├── muti-site.ini ├── test.ini └── test.py ├── Jinja2 ├── ghtml.py ├── output.html └── templates │ └── index.html ├── ansible ├── api │ ├── aa.sh │ ├── df_api.py │ ├── dfscript.py │ ├── playbook_api.py │ └── uptime_api.py └── playbook │ ├── debug.yaml │ ├── file │ └── migu_mirror.repo │ └── insalt_rhel7.yaml ├── bin_oct_hex └── convert.py ├── blackhatpython ├── 01tcpclient.py ├── 02udpclient.py ├── 03tcpserver.py └── 04nc.py ├── cs_mode ├── cs_command │ ├── client.py │ ├── readme │ └── server.py └── serversocket │ ├── client.py │ └── server.py ├── excel ├── add_macros.py ├── analyse_spider.py ├── chart_col.py ├── date_report.py ├── diff_excel.py ├── get_img.py ├── openexcel.py └── pyxlchart.py ├── fanyi.py ├── flask ├── PostMail │ ├── LICENSE │ ├── README.md │ ├── postmail.py │ └── run.py ├── chartkick │ ├── readme.txt │ ├── run.py │ ├── static │ │ ├── chartkick.js │ │ ├── highcharts.js │ │ └── jquery.min.js │ └── templates │ │ └── index.html ├── login │ ├── run.py │ ├── static │ │ └── css │ │ │ ├── bootstrap.min.css │ │ │ └── style.css │ └── templates │ │ ├── index.html │ │ └── login.html └── mysql_query │ ├── beautiful │ ├── main.py │ ├── static │ │ ├── bootstrap-3.3.4-dist.zip │ │ ├── css │ │ │ ├── bootstrap-theme.css │ │ │ ├── bootstrap-theme.css.map │ │ │ ├── bootstrap-theme.min.css │ │ │ ├── bootstrap.css │ │ │ ├── bootstrap.css.map │ │ │ └── bootstrap.min.css │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ └── js │ │ │ ├── bootstrap.js │ │ │ ├── bootstrap.min.js │ │ │ ├── jquery-2.1.4.min.js │ │ │ └── npm.js │ └── templates │ │ └── new.html │ └── simple │ ├── demo.py │ ├── main.py │ ├── readme.txt │ ├── static │ └── jquery.min.js │ └── templates │ ├── index.html │ ├── index.html.bak │ └── layout.html ├── flask_monitor ├── monitems.py └── web │ ├── flask_web.py │ ├── static │ ├── exporting.js │ ├── highstock.js │ └── jquery.min.js │ └── templates │ └── mon.html ├── get_pid.py ├── get_user.py ├── getattr ├── funab.py ├── get.py ├── get2.py ├── main.py ├── map.py ├── web │ ├── backend │ │ ├── __init__.py │ │ ├── account.py │ │ └── admin.py │ ├── index.py │ └── web.py └── xg.py ├── gevent ├── echoserver.py ├── mgeturl.py └── talkserver.py ├── grab ├── 51cto │ ├── 51cto.tar.gz │ ├── img.py │ ├── insert.py │ ├── moudle │ │ ├── cto.py │ │ ├── curl.py │ │ ├── curl.py.bak │ │ ├── curl.pyc │ │ ├── iconv.py │ │ ├── iconv.pyc │ │ ├── test.html │ │ └── test.py │ ├── py.tar.gz │ ├── python │ │ ├── pycurl │ │ │ ├── async.py │ │ │ ├── init.py │ │ │ ├── muit.py │ │ │ ├── split.py │ │ │ ├── test.py │ │ │ ├── url.py │ │ │ ├── wordpress.py │ │ │ └── wp.html │ │ ├── title_url.py │ │ ├── url.py │ │ └── urlib3.py │ └── split.py ├── mirror_rpmpackage.py ├── reconn.py ├── segment │ ├── cto.py │ ├── curl.py │ ├── pre.py │ ├── tag.py │ └── title_url.py └── xisai.py ├── leetcode └── 01sum.py ├── mail ├── linux │ ├── httpdisk.sh │ ├── mail.py │ ├── mail2.py │ ├── pngmail.py │ ├── sendPmail.py │ └── sslmail.py └── windows │ └── mail.py ├── md5sum.py ├── netstat ├── netinfo ├── pynetstat.py ├── pyss.py ├── pyss_ex.py └── ss++.cc ├── ocr └── baiduocr.py ├── oracle_awr_analys ├── awr_backup.py ├── awr_configure.py ├── awr_constant.py ├── awr_constant2.py ├── awr_db.py ├── awr_debug.py ├── awr_main.py ├── awr_regular.py ├── awr_regular2.py ├── doc │ ├── create_awr.sql │ └── readme.txt ├── exec_awr_analysed.sh └── readme.txt ├── os ├── log_timedRotate.py ├── smem └── tcping.py ├── pcmd ├── agent-python2_201712212138.zip ├── config.conf ├── key.txt ├── p2agent.py └── pcmd.py ├── peewee ├── 1-createdb.py ├── 2-mode-query.py └── 3-date-notes.py ├── persist ├── cpickle │ ├── exp1.py │ └── exp2.py └── shelve │ └── m_shelve.py ├── pexecpt ├── 01pipe.py ├── 02logfile.py ├── ftpsync.py └── sysinfo.py ├── queue ├── fifo.py ├── lifo.py ├── priority.py ├── queue_thread.py ├── queue_thread1.py └── queue_thread2.py ├── requests ├── addcookies.py ├── headers.py ├── multipart.py ├── postjson.py └── urlencoded.py ├── selenium ├── def_selenium.py ├── front.py ├── open_switch.py ├── random │ ├── 1.py │ ├── fenbianlv.py │ ├── flower.html │ ├── proxy - ����.txt │ ├── proxy-test.py │ ├── proxy.py │ ├── proxy.txt │ ├── randomchoice - ����.py │ ├── randomchoice.py │ ├── siteurl.txt │ └── test.py ├── selenium_tab.py ├── selenium_test.py ├── sendkeys.py └── win32_test.py ├── stock ├── all.py ├── all_data_excel.py ├── calc │ ├── prettytable.py │ ├── prettytable.pyc │ └── rate.py ├── diagstock.py ├── hismoney.py ├── htmltable_xlsx.py ├── last.py ├── moneyin-multiprocess.py ├── moneyin.py ├── moneyin │ ├── moneyin.py │ └── prettytable.pyc ├── mult-in-excel.py ├── pe │ ├── get_pe.py │ ├── pe.py │ ├── stock_exp.txt │ └── thread_pe.py ├── readme │ ├── 163.txt │ ├── dfcf.txt │ ├── qq.txt │ ├── readme.txt │ ├── sina.txt │ ├── ths.txt │ └── zqzx.txt ├── she_codes.py ├── stock-wave.py ├── talib │ ├── 01-kdj.py │ ├── 02-kdjall.py │ ├── 03-macd.py │ ├── 04-macdall.py │ ├── 05-kdj-macd.py │ └── 06-kdj-macd-weixin.py ├── toexcel.py └── tosql.py ├── thread ├── Thread-Pool.py ├── condition │ ├── con1.py │ ├── con2.py │ └── con3.py └── lock │ ├── dead-lock1.py │ ├── dead-lock2.py │ ├── lock1.py │ └── lock2.py ├── tomcat_deamon ├── cfg │ └── config.ini ├── logs │ └── output.log └── monitor.py └── tree.py /ConfigParser/cf_init.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | #--------------------- 4 | # mysite: www.361way.com 5 | #--------------------- 6 | import sys,os,time 7 | import ConfigParser 8 | 9 | class Config: 10 | def __init__(self, path): 11 | self.path = path 12 | self.cf = ConfigParser.ConfigParser() 13 | self.cf.read(self.path) 14 | def get(self, field, key): 15 | result = "" 16 | try: 17 | result = self.cf.get(field, key) 18 | except: 19 | result = "" 20 | return result 21 | def set(self, filed, key, value): 22 | try: 23 | self.cf.set(field, key, value) 24 | cf.write(open(self.path,'w')) 25 | except: 26 | return False 27 | return True 28 | 29 | def read_config(config_file_path, field, key): 30 | cf = ConfigParser.ConfigParser() 31 | try: 32 | cf.read(config_file_path) 33 | result = cf.get(field, key) 34 | except: 35 | sys.exit(1) 36 | return result 37 | 38 | def write_config(config_file_path, field, key, value): 39 | cf = ConfigParser.ConfigParser() 40 | try: 41 | cf.read(config_file_path) 42 | cf.set(field, key, value) 43 | cf.write(open(config_file_path,'w')) 44 | except: 45 | sys.exit(1) 46 | return True 47 | 48 | if __name__ == "__main__": 49 | if len(sys.argv) < 4: 50 | sys.exit(1) 51 | 52 | config_file_path = sys.argv[1] 53 | field = sys.argv[2] 54 | key = sys.argv[3] 55 | if len(sys.argv) == 4: 56 | print read_config(config_file_path, field, key) 57 | else: 58 | value = sys.argv[4] 59 | write_config(config_file_path, field, key, value) 60 | -------------------------------------------------------------------------------- /ConfigParser/musite.py: -------------------------------------------------------------------------------- 1 | 2 | from ConfigParser import SafeConfigParser 3 | 4 | parser = SafeConfigParser() 5 | parser.read('multisection.ini') 6 | 7 | for section_name in parser.sections(): 8 | print 'Section:', section_name 9 | print ' Options:', parser.options(section_name) 10 | for name, value in parser.items(section_name): 11 | print ' %s = %s' % (name, value) 12 | print 13 | -------------------------------------------------------------------------------- /ConfigParser/muti-site.ini: -------------------------------------------------------------------------------- 1 | [site] 2 | url = http://www.361way.com/ 3 | username = 361way 4 | password = nothing 5 | 6 | [site2] 7 | url = http://www.91it.org/ 8 | username = 91it 9 | password = org 10 | -------------------------------------------------------------------------------- /ConfigParser/test.ini: -------------------------------------------------------------------------------- 1 | [site] 2 | url = http://www.361way.com/ 3 | username = 361way 4 | password = SECRET 5 | -------------------------------------------------------------------------------- /ConfigParser/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | from ConfigParser import SafeConfigParser 4 | 5 | parser = SafeConfigParser() 6 | parser.read('test.ini') 7 | 8 | print parser.get('site', 'url') 9 | -------------------------------------------------------------------------------- /Jinja2/ghtml.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | # code from www.361way.com 4 | import os 5 | from jinja2 import Environment, FileSystemLoader 6 | 7 | PATH = os.path.dirname(os.path.abspath(__file__)) 8 | TEMPLATE_ENVIRONMENT = Environment( 9 | autoescape=False, 10 | loader=FileSystemLoader(os.path.join(PATH, 'templates')), 11 | trim_blocks=False) 12 | 13 | 14 | def render_template(template_filename, context): 15 | return TEMPLATE_ENVIRONMENT.get_template(template_filename).render(context) 16 | 17 | 18 | def create_index_html(): 19 | fname = "output.html" 20 | urls = ['http://www.361way.com/tag/python', 'http://www.361way.com/tag/linux', 'http://www.361way.com/tag/mysql'] 21 | context = { 22 | 'urls': urls 23 | } 24 | # 25 | with open(fname, 'w') as f: 26 | html = render_template('index.html', context) 27 | f.write(html) 28 | 29 | 30 | def main(): 31 | create_index_html() 32 | 33 | ######################################## 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /Jinja2/output.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |3 links
11 |{{ urls|length }} links
11 |来源:运维之路
60 |#ifndef PHP_ARRAY_H
6 | #define PHP_ARRAY_H
7 | PHP_FUNCTION(uasort);
8 | PHP_FUNCTION(uksort);
9 | ……
10 |
11 | 上面定义的排序函数:
12 |/* {{{ proto bool sort(array &array_arg [, int sort_flags])
13 | Sort an array */
14 | PHP_FUNCTION(sort)
15 | {
16 | zval *array;
17 | long sort_type = PHP_SORT_REGULAR;
18 |
19 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) {
20 | RETURN_FALSE;
21 | }
22 |
23 | php_set_compare_func(sort_type TSRMLS_CC);
24 |
25 | if (zend_hash_sort(Z_ARRVAL_P(array), zend_qsort, php_array_data_compare, 1 TSRMLS_CC) == FAILURE) {
26 | RETURN_FALSE;
27 | }
28 | RETURN_TRUE;
29 | }
30 | /* }}} */
31 |
32 |
33 | 在代码中,看到了
34 | ''' 35 | 36 | #print re.sub(r'(?ims)', r'"(.+?)
', r'\1', text) 37 | r = re.compile(r'',re.S|re.I|re.M) 38 | x = r.sub(r'(.+?) \1', text) 39 | print x 40 | 41 | 42 | string = '''43 | Bla blabla 44 |
45 | bla bla bla''' 46 | 47 | print re.sub(r'
Hi!
27 | How are you?
28 | Here is the 运维之路 you wanted.
29 | 给我捐赠:
30 |
打败了99%的股票
\s+打败了(.+?)%的股票
',html.text,re.I) 35 | suggest = re.findall("