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 / __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 / 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)
#!/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 / 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]
@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 / 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 ..
#!/bin/env python
"""
https://github.com/juliensobrier/google-safe-browsing-lookup-python
"""
import safebrowsinglookup
API_KEY = ""
@tawateer
tawateer / iptables_example.sh
Last active June 13, 2016 06:59
iptables 例子
#!/bin/bash
accept_net="124.205.206.0/24 124.254.7.0/24 119.161.240.0/24 211.152.0.0/16 10.0.11.17/32 10.0.11.11/32 59.151.16.0/24 10.9.1.0/24"
/sbin/iptables -F
/sbin/iptables -Z
/sbin/iptables -X
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT DROP
@tawateer
tawateer / kernel_conf.py
Last active July 3, 2016 02:28
配置内核参数
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
def shell(cmd):
""" 执行命令.
@tawateer
tawateer / ldap_op.py
Last active July 4, 2016 14:15
ldap example
#!/usr/bin/env python
import ldap
import base64
import hashlib
import binascii
import ldap.modlist as modlist
import subprocess