Skip to content

Instantly share code, notes, and snippets.

View hellowac's full-sized avatar
💖
I may be slow to respond.

hello_wac hellowac

💖
I may be slow to respond.
View GitHub Profile
@hellowac
hellowac / dnsmasq.conf
Created October 30, 2024 07:47 — forked from ruanbekker/dnsmasq.conf
Tinkering with Loki, Promtail, Grafana, Prometheus, Nginx and Dnsmasq
log-queries
log-facility=/var/log/dnsmasq.log
no-resolv
server=8.8.4.4
server=8.8.8.8
address=/router/10.1.1.1
address=/server/10.1.1.2
@hellowac
hellowac / README.md
Created August 9, 2024 05:39 — forked from liviaerxin/README.md
FastAPI and Uvicorn Logging #python #fastapi #uvicorn #logging

FastAPI and Uvicorn Logging

When running FastAPI app, all the logs in console are from Uvicorn and they do not have timestamp and other useful information. As Uvicorn applies python logging module, we can override Uvicorn logging formatter by applying a new logging configuration.

Meanwhile, it's able to unify the your endpoints logging with the Uvicorn logging by configuring all of them in the config file log_conf.yaml.

Before overriding:

uvicorn main:app --reload
@hellowac
hellowac / aspect_ratio.py
Created May 7, 2024 05:59 — forked from Integralist/aspect_ratio.py
[Calculate Aspect Ratio] #aspect #ratio #python
def calculate_aspect(width: int, height: int) -> str:
def gcd(a, b):
"""The GCD (greatest common divisor) is the highest number that evenly divides both width and height."""
return a if b == 0 else gcd(b, a % b)
r = gcd(width, height)
x = int(width / r)
y = int(height / r)
return f"{x}:{y}"
@hellowac
hellowac / readme.md
Created November 16, 2023 07:38 — forked from VetaZhang/Switch-ctrl-and-alt.md
ubuntu 下 ctrl 和 alt 互换

Alt 和 Ctrl 互换,将 Alt 键改成 Command 键

sudo vim /usr/share/X11/xkb/keycodes/evdev

找到LCTL和LALT, 将系统默认的LCTL=37, LALT=64的值互相交换即可。

terminal 终端的复制粘贴修改

终端输入:

@hellowac
hellowac / rst_to_md.sh
Created October 6, 2023 05:24 — forked from zaiste/rst_to_md.sh
Convert RST to Markdown using Pandoc
FILES=*.rst
for f in $FILES
do
filename="${f%.*}"
echo "Converting $f to $filename.md"
`pandoc $f -f rst -t markdown -o $filename.md`
done
@hellowac
hellowac / Git_Behind_Proxy.md
Created September 28, 2023 14:17 — forked from ozbillwang/Git_Behind_Proxy.md
Configure Git to use a proxy (https or SSH+GIT)
@hellowac
hellowac / supervisord.service
Last active May 12, 2022 08:03 — forked from mozillazg/supervisord.service
在centos7中 安装以及配置 supervisord 服务
[Unit]
Description=supervisord - Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target
[Service]
Type=forking
ExecStart=/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecReload=/bin/supervisorctl reload
ExecStop=/bin/supervisorctl shutdown
@hellowac
hellowac / webshell.py
Created December 26, 2018 01:54 — forked from phoemur/webshell.py
Basic webshell with Python + Flask and WebSockets (Flask-SocketIO)
#!/usr/bin/env python
import subprocess
from flask import Flask, render_template
from flask_socketio import SocketIO, send, emit
HTML = '''
<html>
<head>
<title>WEBSHELL</title>
@hellowac
hellowac / ocr.markdown
Created March 8, 2018 09:07 — forked from henrik/ocr.markdown
OCR on OS X with tesseract

Install ImageMagick for image conversion:

brew install imagemagick

Install tesseract for OCR:

brew install tesseract --all-languages

Or install without --all-languages and install them manually as needed.