This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
# Note: | |
# 1. 使用Redis缓存用户信息,减少重复调用 | |
# 2. 只通过用户的location字段看是否包含beijing、shanghai、guangzhou、 | |
# shenzhen、china这几个关键词判断是否是国人 | |
from collections import defaultdict | |
import redis | |
import requests | |
USENAME = '<YOUR USERNSME>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
# pip install zhihu_oauth | |
import os | |
import time | |
import json | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) | |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}!') |
NewerOlder