Skip to content

Instantly share code, notes, and snippets.

View dongweiming's full-sized avatar
:octocat:
🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔

Weiming Dong dongweiming

:octocat:
🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔
View GitHub Profile
@dongweiming
dongweiming / resume.py
Created October 11, 2016 02:56
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)
@dongweiming
dongweiming / .zshrc
Created November 27, 2019 09:07 — forked from SlexAxton/.zshrc
My gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@dongweiming
dongweiming / cn_participation.py
Last active September 5, 2019 15:57
Get chinese contributor
# coding=utf-8
# Note:
# 1. 使用Redis缓存用户信息,减少重复调用
# 2. 只通过用户的location字段看是否包含beijing、shanghai、guangzhou、
# shenzhen、china这几个关键词判断是否是国人
from collections import defaultdict
import redis
import requests
USENAME = '<YOUR USERNSME>'
@dongweiming
dongweiming / test.py
Created August 15, 2019 12:32
requests 中间件的写法
from requests import Session, Response
from requests.adapters import HTTPAdapter
class MiddlewareHTTPAdapter(HTTPAdapter):
def __init__(self, middlewares=None, *args, **kwargs):
self.middlewares = middlewares or []
super().__init__(*args, **kwargs)
def register(self, middleware):
@dongweiming
dongweiming / xiaoe.py
Created February 16, 2019 15:38
小鹅通新用户抽奖脚本
from datetime import datetime
from collections import defaultdict
from http.cookies import SimpleCookie
import requests
URL = 'https://admin.xiaoe-tech.com/new/customerList?is_pay=0&ruler=0&search=&page={page}'
cookie = SimpleCookie()
with open('cookie.txt') as f:
@dongweiming
dongweiming / send_message.py
Last active December 18, 2018 06:49
send_message.py
# coding=utf-8
# pip install zhihu_oauth
import os
import time
import json
@dongweiming
dongweiming / 0_urllib2.py
Last active December 18, 2018 06:49 — forked from kennethreitz/0_urllib2.py
urllib2 vs requests
# coding=utf-8
import json
import urllib2
from cookielib import CookieJar
hb_url = 'https://httpbin.org/basic-auth/user/pass'
req = urllib2.Request(hb_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
# coding=utf-8
from mapreduce import SimpleMapReduce
from simple import FILES, file_parser
def count_err_log(item):
word, occurances = item
return (word, sum(occurances))
@dongweiming
dongweiming / benchmarks.ipynb
Created March 16, 2015 02:27
benchmarks.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import sys
import antigravity
if sys.version_info < (3, 6):
print('Python 3.6+ is the future!')
exit()
def say(name: str) -> None:
print(f'Life is short, you need {name}!')