Skip to content

Instantly share code, notes, and snippets.

View baobuiquang's full-sized avatar
👋
Hi there!

baobuiquang baobuiquang

👋
Hi there!
View GitHub Profile

GitHub Flavored Markdown

View the source of this content.

Let's get the whole "linebreak" thing out of the way. The next paragraph contains two phrases separated by a single newline character:

Roses are red Violets are blue

import sys
import logging
logging.basicConfig(filename='_log_crash.log', level=logging.ERROR, format='--------------------------------------------------\n%(asctime)s\n%(levelname)s: %(message)s\n')
def log_crashes(exc_type, exc_value, exc_traceback):
logging.error("CRASHED - Unhandled exception occurred", exc_info=(exc_type, exc_value, exc_traceback))
sys.excepthook = log_crashes
def simulate_memory_error():
massive_list = [bytearray(1024 * 1024 * 1000) for _ in range(1000)]
git clone https://github.com/OneLevelStudio/FORGE
cd FORGE
python3 -m venv venv
source venv/bin/activate
pip install -U pip
pip install torch==2.3.1 torchvision==0.18.1 --extra-index-url https://download.pytorch.org/whl/cu121
pip install -r requirements_versions.txt
wget -P models/Stable-diffusion https://huggingface.co/onelevelstudio/diffusion/resolve/main/573152/LVSTIFY_V5.0.safetensors
wget -P models/Lora https://huggingface.co/onelevelstudio/diffusion/resolve/main/375993/LORA_GHOST.safetensors
List IMG docker images
List CON docker ps -a
Build IMG docker-compose build
Run CON detached docker-compose up -d
Build IMG + Run CON detached docker-compose up -d --build
Stop CON + Remove CON docker-compose down
Remove everything unused docker system prune -a --volumes -f
Remove everything 1. docker stop $(docker ps -a -q)

Install Python3.10 on Ubuntu24.04

Install Python3.10

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install -y python3.10

Set default

@baobuiquang
baobuiquang / Zrok
Created August 29, 2024 08:01
Zrok
zrok reserve public 1234 --unique-name baobuiquang
zrok share reserved baobuiquang public
@baobuiquang
baobuiquang / Linux
Created August 29, 2024 08:00
Linux
ssh -L 1234:localhost:1234 [email protected]
jupyter lab --no-browser --port=1234
@baobuiquang
baobuiquang / fastapi.py
Last active April 15, 2025 07:17
FastAPI
# Boilerplate: https://github.com/baobuiquang/fastapi
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from fastapi import FastAPI
import uvicorn
import _config
# For images processing
from fastapi import File, UploadFile
@baobuiquang
baobuiquang / cmd_quickcodes.bat
Last active August 29, 2024 02:17
CMD Quickcodes
# Python
call py --version
# Virtual Environment
call py -m venv venv
call venv\Scripts\activate
call py -m pip install -U pip
call py run.py
# Install dependencies
@baobuiquang
baobuiquang / python_quickcodes.py
Created August 29, 2024 01:26
Python Quickcodes
# Create folder
import os
os.makedirs("my/path", exist_ok=True)
# Read and write CSV
import pandas as pd
df = pd.read_csv('input_data.csv', encoding='utf-8')
df.to_csv('output_data.csv', encoding='utf-8', index=False)