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 / argparse_example.py
Last active August 15, 2022 19:14
python argparse example
#!/bin/env python
""" argparse example.
url: https://mkaz.com/2014/07/26/python-argparse-cookbook/
"""
import argparse
@tawateer
tawateer / parallel_timed_rotating_handler.py
Last active January 11, 2021 06:07
重写 Python logging 的 TimedRotatingFileHandler doRollover 方法,解决多进程切割日志的问题。
#!/bin/env python
# -*- coding: utf-8 -*-
import os
import time
import logging
from logging.handlers import TimedRotatingFileHandler
LOG_DIR = "/tmp/"
#!/bin/sh
# create self-signed server certificate:
read -p "Enter your domain [www.example.com]: " DOMAIN
echo "Create server key..."
openssl genrsa -des3 -out $DOMAIN.key 1024
#!/bin/env python
#-*- coding: utf-8 -*-
""" 发布特定分支的 Nginx conf, 这里发布以 autodeploy 开头的分支.
此脚本跑在 Jenkins 任务下, 此任务通过 Jenkins 的 Gerrit Trigger
插件监控 Nginx conf (Gerrit 项目) 的 Ref Updated 和 Change Merged 事件,
而且分支要匹配 **/autodeploy*, 满足条件触发此任务.
1. 先计算出最近一次修改的以 autodeploy 开头的分支,
@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 / dnscrypt-proxy.sh
Last active January 9, 2019 02:50
sniproxy + dnscrypt-proxy + dnscrypt-wrapper + dnsmasq 相关脚本
#!/bin/bash
sudo su -
wget http://download.dnscrypt.org/dnscrypt-proxy/dnscrypt-proxy-1.6.0.tar.gz
tar xvzf dnscrypt-proxy-1.6.0.tar.gz
cd dnscrypt-proxy-1.6.0
./configure
make
make install
cd ..