Skip to content

Instantly share code, notes, and snippets.

View BlackHacked's full-sized avatar
📷
Hello World

Latin BlackHacked

📷
Hello World
View GitHub Profile
import loguru_logger
logger = loguru_logger.get_logger()
@BlackHacked
BlackHacked / main.py
Created May 24, 2023 07:36 — forked from Kludex/main.py
Run Gunicorn with Uvicorn workers in code
""" Snippet that demonstrates how to use Gunicorn with Uvicorn workers in code.
Feel free to run:
- `python main.py` - to use uvicorn.
- `ENV=prod python main.py` - to use gunicorn with uvicorn workers.
Reference: https://docs.gunicorn.org/en/stable/custom.html
"""
import logging
import gunicorn.app.base
from fastapi import FastAPI
from loguru import logger
class InterceptHandler(logging.StreamHandler):
def emit(self, record):
# Get corresponding Loguru level if it exists

Fastapi+Supervisor+Gunicorn+Nginx部署

创建用户

sudo adduser tonytan

chmod -R 640 /etc/sudoers
sudo vim /etc/sudoers
chmod -R 440 /etc/sudoers
# -*- coding: utf-8 -*-
# 14-8-20
# create by: snower
import os
import time
import struct
import fcntl
from logging.handlers import RotatingFileHandler, TimedRotatingFileHandler
@BlackHacked
BlackHacked / .drone.yml
Created July 27, 2023 08:27 — forked from fortis/.drone.yml
drone docker plugins with layers cache
pipeline:
restore-cache:
image: drillster/drone-volume-cache
restore: true
ttl: 7
mount:
- /drone/docker
# Mount the cache volume, needs "Trusted"
volumes:
- /tmp/cache:/cache
  1. 通过 pip install pandora-chatgpt 安装依赖。
  2. 保存以下代码到auto_pool_token.py文件。
  3. 同目录新建文件credentials.txt一行一个账号密码。
  4. 账号和密码之间用,分隔,不需要额外的引号。
  5. 如果需要修改代理,unique_name等,自行修改再运行。
  6. 运行这个auto_pool_token.py
  7. 你会看到运行进度,运行完成可看到pool token
  8. 运行中间结果分别保存在同目录tokens.txtshare_tokens.txt中。
@BlackHacked
BlackHacked / docker-registry-mirrors.md
Created October 26, 2023 06:46 — forked from y0ngb1n/docker-registry-mirrors.md
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized

Docker Hub 镜像加速器

国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。Docker 官方和国内很多云服务商都提供了国内加速器服务。

Dockerized 实践 https://github.com/y0ngb1n/dockerized

配置加速地址

Ubuntu 16.04+、Debian 8+、CentOS 7+

@BlackHacked
BlackHacked / docker_images.sh
Created May 10, 2024 10:58 — forked from hydra1983/docker_images.sh
Save and load docker images in batch
#!/bin/bash
readonly DB_FILE="$(pwd)/images.db"
readonly IMG_DIR="$(pwd)/images"
save-images() {
echo "Create ${DB_FILE}"
echo "$(docker images|grep -v 'IMAGE ID'|awk '{printf("%s %s %s\n", $1, $2, $3)}'|column -t)" > "${DB_FILE}"
echo "Read ${DB_FILE}"
@BlackHacked
BlackHacked / md2pdf.md
Created May 17, 2024 08:18 — forked from dcchambers/md2pdf.md
Generate a PDF from Markdown files with Pandoc

Generate a PDF from a Markdown file with Pandoc

Easy Steps For Mac OS

  1. Have Homebrew installed and a markdown file you want to render to PDF.
  2. Install Pandoc brew install pandoc
  3. Install basictex brew cask install basictex - needed for the pdflatex tool.
  4. Symlink the pdflatex to your /usr/local/bin so pandoc can easily find it. ln -s /Library/TeX/Root/bin/x86_64-darwin/pdflatex /usr/local/bin/pdflatex
  5. Use Pandoc to generate a PDF from a Markdown file. pandoc input.md -o output.pdf
  • By default the margins are pretty large. To optionally change the margins: pandoc input.md -o output.pdf -V geometry:margin=1in