Skip to content

Instantly share code, notes, and snippets.

View MerleLiuKun's full-sized avatar
🎯
Focusing

klein MerleLiuKun

🎯
Focusing
View GitHub Profile
@MerleLiuKun
MerleLiuKun / reg.py
Created April 8, 2021 10:25
Regex Demo
import re
# 获取 script 标签中的变量数据 ex: var abc = {data: {"actionModule": "abc"}};
get_script_var_re = re.compile('var abc = (.*?};)?')
@MerleLiuKun
MerleLiuKun / pyproject.toml
Created September 9, 2020 14:10
poetry relative
# Install with source
[[tool.poetry.source]]
name = "aliyun"
url = "https://mirrors.aliyun.com/pypi/simple"
@MerleLiuKun
MerleLiuKun / nginx_log_parse.py
Created May 19, 2020 07:59
Nginx log 的解析
from dataclasses import dataclass
@dataclass
class LogInfo:
req: str
body: str
ua: str
def handle_line_by_re(line) -> LogInfo:
"""
# 确认再 Python 虚拟环境下
export PATH="/usr/local/Cellar/mysql@5.7/5.7.29/bin/:$PATH" # 将本机的 MySQL 路径加到 PATH
# 如果出现 ld: library not found for -lssl
# 但此问题已在 2020年2月被 mysqlclient在主分支修复,暂未发布
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
# 执行安装
pip install mysqlclient
@MerleLiuKun
MerleLiuKun / git_pr.sh
Created December 21, 2019 14:55
modify PR
git fetch origin refs/pull/10/head:patch-2
# 10 是 PR 对应的编号
git checkout patch-2
# 你的修改
git add -u
git commit -m "描述你的修改"
git remote add LalZzy https://github.com/LalZzy/cosx.org.git
@MerleLiuKun
MerleLiuKun / selenium_driver.py
Created October 21, 2019 11:40
browser screenshot with selenium
from PIL import Image
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
class Driver:
""" selenium web driver instance """
def __init__(self):
self.chrome = None
comments = []
comment_tasks = []
# loop and add part one all tasks
for comment in comments:
comment_info = {
'id': comment.id,
'message': comment.message
}
comment_tasks.append(do_analyze.si(task_info, comment_info))
@MerleLiuKun
MerleLiuKun / mydocker.sh
Created May 13, 2019 09:33
docker commn command
# show container's IP
sudo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container_id or container_name>
@MerleLiuKun
MerleLiuKun / mygit.sh
Created May 13, 2019 03:29
git common
# 批量删除远程分支
git push origin --delete <branch1> <branch2> <branch3>
# 移除本地的无对应远程的分支
git remote prune origin
@MerleLiuKun
MerleLiuKun / mongo_server.sh
Created April 18, 2019 09:12
mongo db docker
# run a simple mongo server
docker run --rm --name mymongo -p 27017:27017 -d mongo
# run mongo web
docker run --rm --name mymongo-express --link mymongo:mongo -p 8081:8081 -d mongo-express