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 / scan_redis_and_delete_some.py
Last active December 22, 2016 10:20
扫描 redis key 并删除部分 key。
#!/bin/env python
import urllib2
from multiprocessing.dummy import Pool as ThreadPool
import redis
hosts_d = {
"host1": [6360, 6361, 6362, 6363],
@tawateer
tawateer / default_http1.1.py
Last active May 23, 2016 17:23
urllib2 关于 proxy 和 http version
#!/bin/env python
import urllib2, httplib
handler=urllib2.HTTPHandler(debuglevel=1)
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)
url = "http://www.baidu.com"
print urllib2.urlopen(url).read()[:10]
#!/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
@tawateer
tawateer / GrabUrl2.py
Created April 7, 2016 17:02 — forked from presci/GrabUrl2.py
Semaphore example in python 2
import threading
import urllib2
import time, random
class GrabUrl(threading.Thread):
def __init__(self, arg0):
threading.Thread.__init__(self)
self.host=arg0
def run(self):
k=random.randint(10,20)
@tawateer
tawateer / __init__.py
Created April 6, 2016 16:15
python concurrent futures source
# Copyright 2009 Brian Quinlan. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Execute computations asynchronously using threads or processes."""
__author__ = 'Brian Quinlan ([email protected])'
from concurrent.futures._base import (FIRST_COMPLETED,
FIRST_EXCEPTION,
ALL_COMPLETED,
@tawateer
tawateer / servicetag.py
Last active December 24, 2015 15:05
从 DELL 官网 API 通过 SN 查询「快速服务编码」
#!/bin/env python
import requests
def get_servicetag_from_sn(sn):
url = "http://www.dell.com/support/troubleshooting/cn/zh/cndhs1/ExpressService/ExpressService/GetSpecificExpressServiceTag"
data = {
"TagCode": sn
}
@tawateer
tawateer / client.go
Created December 22, 2015 15:40 — forked from jordanorelli/client.go
rpc server example in go
package main
import (
"bufio"
"log"
"net/rpc"
"os"
)
func main() {
@tawateer
tawateer / check_idrac_alive.py
Last active December 15, 2015 06:39
检查 idrac 是否存活和检查机器电源状态
#!/usr/bin/env
import os
import sys
import re
import logging
import time
import argparse
import pexpect
import subprocess
@tawateer
tawateer / build_docker_base_image.py
Last active December 29, 2015 14:13
基础镜像构建脚本
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" 基础镜像构建脚本.
会自动构建依赖的镜像, 比如构建基础镜像 centos6, 则以 centos6 开头的镜像都会构建, 比如:
centos6-java8
centos6-java8-tomcat8
根据镜像长度判断依赖关系.
@tawateer
tawateer / main.go
Created November 5, 2015 04:00
go 的单例
import (
"singleton"
)
func main() {
mSingleton, nSingleton := singleton.NewSingleton("hello"), singleton.NewSingleton("hi")
mSingleton.SaySomething()
nSingleton.SaySomething()
c := make(chan int)