Skip to content

Instantly share code, notes, and snippets.

View lwzm's full-sized avatar
🎯
Focusing

Weizhao Li lwzm

🎯
Focusing
View GitHub Profile
@lwzm
lwzm / f.conf
Last active September 19, 2019 05:55
gunicorn and pyinstaller and file-upload-app
upstream f {
server 127.0.0.4:3000;
keepalive 16;
}
server {
server_name f.*;
root /home/xxxx;
location / {
proxy_buffering off;
@lwzm
lwzm / gunicorn.py
Last active September 11, 2019 13:44
#!/usr/bin/env python3
bind = '0.0.0.0:8000'
workers = 4
keepalive = 60
timeout = 600
#max_requests = 1000
worker_class = 'tornado'
worker_class = 'meinheld.gmeinheld.MeinheldWorker'
worker_class = 'gevent'
-- _ 是老数据,想把 t 作为补丁更新至 _ , 参考下面
-- 执行速度只和 t 的数据量有关,和目标 _ 数据量关系不大(索引),t 数据量有 100W 时,2秒搞定
select 'edit';
replace into _ (k, v)
select t.k, t.v from t inner JOIN _ on t.k=_.k where t.v!=_.v; -- update exists
select changes();
select 'new';
insert into _ (k, v)
#!/usr/bin/env python3
import re
from entities import App, db_session, select
pattern = r'Downloaded (\d+) times'
def get_downloaded(id):
with db_session:
#!/usr/bin/env python3
import gzip
import io
import shutil
import falcon
'''
@lwzm
lwzm / urlopen.py
Last active December 25, 2018 03:11
from urllib.request import urlopen
url = "http://mg.bxs.tyio.net/static/logo.png"
url = "http://ng.tyio.net"
url = "http://google.com"
with urlopen(url, timeout=1) as f:
print(f.read()) # bytes
@lwzm
lwzm / .gitignore
Last active December 30, 2018 12:18
websockets gateway
.*
@lwzm
lwzm / grids-9.py
Last active December 11, 2018 04:07
import collections
import math
class Grids9:
unit_width = 10
unit_height = 10
def __init__(self, w, h):
#!/usr/bin/env python3
import asyncio
import collections
import time
import json
import pendulum
import redis
import tornado.web
@lwzm
lwzm / firefox-headless-cleaner.sh
Created November 18, 2018 02:29
clean firefox-headless
function clean_junk() {
JUNK=$(ps axo pid,ppid,comm | awk '$2==1' | grep $1 | awk '{print $1}')
if [ -n "${JUNK}" ]; then
echo kill $JUNK
kill $JUNK
fi
}
while true; do
clean_junk geckodriver