Skip to content

Instantly share code, notes, and snippets.

View axiaoxin's full-sized avatar
🌙
不忙着圆缺 春天不走远

axiaoxin axiaoxin

🌙
不忙着圆缺 春天不走远
View GitHub Profile
@axiaoxin
axiaoxin / 桂林行程计划.txt
Last active July 13, 2017 07:47
桂林行程计划
### line1->line5->深圳北
27d 07:30前必须出门
### 深圳北->桂林北->龙脊梯田
27d 09:04从深圳北出发到广州南换乘,10:12从广州南出发12:50到达桂林北。坐100路到桂林站(一个小时左右)新凯悦酒店或香江饭店附近14:30左右上车 入住龙胜龙脊景园山庄  
COMMENT: 入住安排勉强可以,山上很多住宿,可以再往景点走些,道路曲折,尽快打电话让人出来带路
@axiaoxin
axiaoxin / tree.md
Created May 16, 2017 06:42 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@axiaoxin
axiaoxin / humanize_bytes.py
Created May 12, 2017 08:31
humanize_bytes
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'),
@axiaoxin
axiaoxin / get_uncontinue_id_range.py
Last active May 12, 2017 08:54
获取不连续的id区间
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])
@axiaoxin
axiaoxin / logrotate-demo
Last active December 29, 2016 07:34
logrotate-demo
/data/log/capacity-service/*.log {
daily
rotate 30
sharedscripts
dateext
compress
delaycompress
missingok
create 644 root root
postrotate
#! /usr/bin/env python3
'''pyCookieCheat.py
2015022 Now its own GitHub repo, and in PyPi.
- For most recent version: https://github.com/n8henrie/pycookiecheat
- This gist unlikely to be maintained further for that reason.
20150221 v2.0.1: Now should find cookies for base domain and all subs.
20140518 v2.0: Now works with Chrome's new encrypted cookies.
See relevant post at http://n8h.me/HufI1w
@axiaoxin
axiaoxin / nginx.conf
Created November 22, 2016 03:16 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# 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
@axiaoxin
axiaoxin / create_tb.sql
Last active October 10, 2016 01:37
createtable mysql datetime 5.5 5.6
-- 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 '更新时间',
@axiaoxin
axiaoxin / 0. description.md
Created May 17, 2016 08:17 — forked from Integralist/0. description.md
Clojure deftype, defrecord, defprotocol
  • defprotocol: defines an interface
  • deftype: create a bare-bones object which implements a protocol
  • defrecord: creates an immutable persistent map which implements a protocol

Typically 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: defprotocol allows you to add new abstractions in a clean way Rather than (like OOP) having polymorphism on the class itself,

@axiaoxin
axiaoxin / enc_dec_test.py
Created March 31, 2016 10:22 — forked from justinfx/enc_dec_test.py
Speed test of common serializers on python 2.7.2 (pickle, cPickle, ujson, cjson, simplejson, json, yajl, msgpack)
"""
Dependencies:
pip install tabulate simplejson python-cjson ujson yajl msgpack-python
"""
from timeit import timeit
from tabulate import tabulate