Skip to content

Instantly share code, notes, and snippets.

View ResolveWang's full-sized avatar
🎯
Focusing

resolvewang ResolveWang

🎯
Focusing
View GitHub Profile
@ResolveWang
ResolveWang / resume.py
Created December 8, 2016 03:20 — forked from dongweiming/resume.py
Python版本简历
#/usr/bin/env python
# coding=utf-8
import random
import re
def color(messages):
color = '\x1B[%d;%dm' % (1,random.randint(30,37))
return '%s %s\x1B[0m' % (color,messages)
""" User-Agents """
mobile_agents = [
"Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
"Avant Browser/1.2.789rel1 (http://www.avantbrowser.com)",
"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.0 Safari/532.5",
"Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Chrome/5.0.310.0 Safari/532.9",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.514.0 Safari/534.7",
"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/534.14 (KHTML, like Gecko) Chrome/9.0.601.0 Safari/534.14",
"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.14 (KHTML, like Gecko) Chrome/10.0.601.0 Safari/534.14",
"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.20 (KHTML, like Gecko) Chrome/11.0.672.2 Safari/534.20",
# -*- coding: utf-8 -*-
# fabfile.py这个名字固定不能改变
from datetime import datetime
from fabric.api import env, local, cd, run, put, settings, lcd
from fabric.context_managers import prefix
def production():
env.hosts = ["[email protected]:22"]
env.key_filename = "/path/to/key_file"
@ResolveWang
ResolveWang / bobp-python.md
Created June 24, 2017 13:18 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
#!/bin/bash
# supervisord This scripts turns supervisord on
# chkconfig: 345 83 04
# description: supervisor is a process control utility. It has a web based
# xmlrpc interface as well as a few other nifty features.
#
# source function library
. /etc/rc.d/init.d/functions
:: run it with administrator rights
netsh interface ipv6 isatap set router 202.115.39.98
netsh interface ipv6 isatap set state enabled
:: then assign your dns to the value of "2001:4860:4860::8888" or "2001:470:20::2"

Python Socket 编程详细介绍

Python 提供了两个基本的 socket 模块:

  • Socket 它提供了标准的BSD Socket API。
  • SocketServer 它提供了服务器重心,可以简化网络服务器的开发。

下面讲解下 Socket模块功能。

Socket 类型

# according to the blog:http://blog.csdn.net/Bone_ACE/article/details/55000101
import socket
# from gevent import socket
_dnscache = {}
def _setDNSCache():
""" DNS缓存 """
@ResolveWang
ResolveWang / gist:9bb648e87eb159b484315a60ec5850de
Created December 12, 2017 09:54
使用python获取当天零点的时间戳
def get_zero_timestamp(self):
cur_timestamp = time.time()
cur_time = time.localtime(cur_timestamp)
zero_time_stamp = cur_timestamp - (
cur_time.tm_sec + 60 * cur_time.tm_min + 3600 * cur_time.tm_hour)
return zero_time_stamp
@ResolveWang
ResolveWang / gist:337beb6ecdf24af5019d952c94d6508b
Created January 15, 2018 02:17
supervisord.conf with python virutalenv
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
[supervisord]
logfile=/home/aaa/project/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)