This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run --rm -it -v "$GOPATH":/go -w /go/build/path dockercore/golang-cross:1.10.2 sh -c ' | |
for GOOS in darwin linux windows; do | |
for GOARCH in 386 amd64; do | |
echo "Building $GOOS-$GOARCH" | |
export GOOS=$GOOS | |
export GOARCH=$GOARCH | |
go build -o bin/ironcli-$GOOS-$GOARCH | |
done | |
done | |
' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ceph pg dump | awk ' | |
/^pg_stat/ { col=1; while($col!="up") {col++}; col++ } | |
/^[0-9a-f]+\.[0-9a-f]+/ { match($0,/^[0-9a-f]+/); pool=substr($0, RSTART, RLENGTH); poollist[pool]=0; | |
up=$col; i=0; RSTART=0; RLENGTH=0; delete osds; while(match(up,/[0-9]+/)>0) { osds[++i]=substr(up,RSTART,RLENGTH); up = substr(up, RSTART+RLENGTH) } | |
for(i in osds) {array[osds[i],pool]++; osdlist[osds[i]];} | |
} | |
END { | |
printf("\n"); | |
printf("pool :\t"); for (i in poollist) printf("%s\t",i); printf("| SUM \n"); | |
for (i in poollist) printf("--------"); printf("----------------\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
def ensure_unicode(s): | |
if not s: | |
return s | |
if isinstance(s, unicode): | |
return s | |
elif isinstance(s, str): | |
return s.decode('utf-8') | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Singleton(type): | |
def __init__(cls, name, bases, dict): | |
super(Singleton, cls).__init__(name, bases, dict) | |
cls.instance = None | |
def __call__(cls, *args, **kw): | |
if cls.instance is None: | |
cls.instance = super(Singleton, cls).__call__(*args, **kw) | |
return cls.instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -* | |
""" | |
把一个复杂对象转为一个字典 | |
""" | |
class ToDictMixin(object): | |
def to_dict(self): | |
return self._traverse_dict(self.__dict__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0,北京,province | |
1,北京,city,0 | |
2,东城区,area,1 | |
3,西城区,area,1 | |
4,崇文区,area,1 | |
5,宣武区,area,1 | |
6,朝阳区,area,1 | |
7,丰台区,area,1 | |
8,石景山区,area,1 | |
9,海淀区,area,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
下载m3u8格式视频的小组件,使用python3 asyncio | |
使用ffmpeg合并ts成mp4 | |
""" | |
import asyncio | |
import os | |
import shutil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
给定一个pdf路径,以及一个列表,可修改pdf内容,删除所有符合条件的文字。 | |
""" | |
from PyPDF2 import PdfFileReader, PdfFileWriter | |
from PyPDF2.generic import TextStringObject, NameObject | |
from PyPDF2.pdf import ContentStream | |
from PyPDF2.utils import b_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import heapq | |
import time | |
class DelayJobQueue(object): | |
""" | |
延迟执行任务队列 | |
q = DelayJobQueue() | |
q.add(task,at=time.time() + 10) | |
q.pop_ready() # None |
NewerOlder