Skip to content

Instantly share code, notes, and snippets.

View tawateer's full-sized avatar
Focusing

wateer tawateer

Focusing
  • Tencent
  • Beijing
View GitHub Profile
@tawateer
tawateer / multi_thread.py
Last active September 23, 2019 10:57
python multi thread example
#!/bin/env python
# -*- coding:utf-8 -*-
import threading
sem = threading.Semaphore(10)
result = []
@tawateer
tawateer / publisher.go
Created August 11, 2019 08:17
simple pubsub code
package pubsub // import "github.com/docker/docker/pkg/pubsub"
import (
"sync"
"time"
)
var wgPool = sync.Pool{New: func() interface{} { return new(sync.WaitGroup) }}
// NewPublisher creates a new pub/sub publisher to broadcast messages.
@tawateer
tawateer / README.md
Last active March 26, 2019 04:24
根据网段和掩码计算起始 IP 和终止 IP

下载 ip.py 到本机, 执行 python ip.py 网段 掩码

> python ip.py 111.10.40.128 255.255.255.192

 111.10.40.128 111.10.40.191

输出即是起始和终止 IP。

@tawateer
tawateer / ip_laiyuan.py
Created March 21, 2019 11:02
写 excel 相关操作
#!/bin/env python
# -*- coding:utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from IPy import IP
import xlwt
@tawateer
tawateer / ip.py
Last active February 19, 2019 07:30
根据网段和掩码查询起始和结束 IP
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from IPy import IP
file_path = "/Users/wateer/Downloads/1"
"""
file content like this:
183.232.67.128 255.255.255.240
183.232.76.98 255.255.255.248
@tawateer
tawateer / gen_etcd_cert.sh
Created November 30, 2017 07:02
生成 etcd 证书
#!/bin/bash
cfssl gencert -initca ca-csr.json | cfssljson -bare ca -
cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=server server.json | cfssljson -bare server
cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=peer member.json | cfssljson -bare member
#!/usr/bin/env sh
### Download and install megaraidcli for Ubuntu;
FILE="megacli_8.07.14.orig.tar.gz"
LINK="http://hwraid.le-vert.net/ubuntu/sources/$FILE"
wget $LINK -O /tmp/$FILE
cd /tmp
@tawateer
tawateer / cmdtimeout.go
Created June 16, 2017 10:39 — forked from scottcagno/cmdtimeout.go
Golang exec.Command Timeout Wrapper
package main
import (
"bytes"
"fmt"
"os/exec"
"time"
)
func run(timeout int, command string, args ...string) string {
@tawateer
tawateer / filter_log.sh
Created December 20, 2016 16:11
过滤系统日志
#!/bin/bash
key_word="USB|usb|eth1|CPU|time|softirq|CD-ROM|IPMI|ipmi|tcpdump|flooding|debugging|ffffffff|UDP|cf_|wzp"
if [ -f "/var/log/message" ];then
log_time=`date -r /var/log/message +%s`
real_time=`date +%s`
diff_time=`expr $real_time - $log_time`
if [ $diff_time -lt 60 ];then
@tawateer
tawateer / 0_pw_hash.rb
Created December 14, 2016 04:23 — forked from pschyska/0_pw_hash.rb
PW hashing with puppet parser function
# lib/puppet/parser/functions/pw_hash.rb
module Puppet::Parser::Functions
newfunction(:pw_hash, type: :rvalue) do |args|
raise Puppet::ParseError, "pw_hash takes exactly two arguments, #{args.length} provided" if args.length != 2
# SHA512 ($6), default number of rounds (5000)
# rounds could be specified by prepending rounds=<n>$ parameter before the salt, i.e.
# args[0].crypt("$6$rounds=50000$#{args[1]}")
args[0].crypt("$6$#{args[1]}")
end