Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| ### line1->line5->深圳北 | |
| 27d 07:30前必须出门 | |
| ### 深圳北->桂林北->龙脊梯田 | |
| 27d 09:04从深圳北出发到广州南换乘,10:12从广州南出发12:50到达桂林北。坐100路到桂林站(一个小时左右)新凯悦酒店或香江饭店附近14:30左右上车 入住龙胜龙脊景园山庄 | |
| COMMENT: 入住安排勉强可以,山上很多住宿,可以再往景点走些,道路曲折,尽快打电话让人出来带路 |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| def humanize_bytes(bytesize, precision=2): | |
| """ | |
| Humanize byte size figures | |
| """ | |
| abbrevs = ( | |
| (1 << 50, 'PB'), | |
| (1 << 40, 'TB'), | |
| (1 << 30, 'GB'), | |
| (1 << 20, 'MB'), | |
| (1 << 10, 'kB'), |
| In [25]: from itertools import groupby | |
| In [26]: f = open('Fattrid.csv') | |
| In [27]: lines = f.readlines() | |
| In [28]: f.close() | |
| In [29]: ids = sorted([int(line.split()[0]) for line in lines]) |
| /data/log/capacity-service/*.log { | |
| daily | |
| rotate 30 | |
| sharedscripts | |
| dateext | |
| compress | |
| delaycompress | |
| missingok | |
| create 644 root root | |
| postrotate |
| # | |
| # CORS header support | |
| # | |
| # One way to use this is by placing it into a file called "cors_support" | |
| # under your Nginx configuration directory and placing the following | |
| # statement inside your **location** block(s): | |
| # | |
| # include cors_support; | |
| # | |
| # As of Nginx 1.7.5, add_header supports an "always" parameter which |
| -- MySQL 5.6+ | |
| CREATE TABLE `t_proc_info` ( | |
| `id` INT NOT NULL AUTO_INCREMENT COMMENT '主键id', | |
| `pkg_name` VARCHAR(64) NULL COMMENT '包名', | |
| `version` VARCHAR(24) NULL COMMENT '版本号', | |
| `proc_name` VARCHAR(64) NULL COMMENT '进程名', | |
| `task_id` VARCHAR(48) NULL COMMENT '命令管道task_id', | |
| `ip_list` TEXT NULL COMMENT 'ip列表', | |
| `created_at` DATETIME NOT NULL DEFAULT NOW() COMMENT '创建时间', | |
| `updated_at` DATETIME NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT '更新时间', |
defprotocol: defines an interfacedeftype: create a bare-bones object which implements a protocoldefrecord: creates an immutable persistent map which implements a protocolTypically you'll use defrecord (or even a basic map);
unless you need some specific Java inter-op,
where by you'll want to use deftype instead.
Note:
defprotocolallows you to add new abstractions in a clean way Rather than (like OOP) having polymorphism on the class itself,
| """ | |
| Dependencies: | |
| pip install tabulate simplejson python-cjson ujson yajl msgpack-python | |
| """ | |
| from timeit import timeit | |
| from tabulate import tabulate |