Skip to content

Instantly share code, notes, and snippets.

View hotohoto's full-sized avatar
🐢
daily small stepping

Hoyeong-GenGenAI hotohoto

🐢
daily small stepping
  • GenGenAI
  • Seoul, Korea
View GitHub Profile
@hotohoto
hotohoto / draw_text.py
Created June 19, 2024 07:44
Draw text on an image using PIllow (auto font download)
from PIL import Image, ImageDraw, ImageFont
from pathlib import Path
from urllib.request import urlopen
def check_and_get_font_path(font_name="roboto_regular") -> Path:
if font_name == "roboto_regular":
path = Path("font/Roboto-Regular.ttf")
if not path.exists():
path.parent.mkdir(parents=True, exist_ok=True)
url = "https://github.com/googlefonts/roboto/raw/main/src/hinted/Roboto-Regular.ttf"
@hotohoto
hotohoto / rotate_yaw_pitch_roll.py
Last active July 1, 2024 15:38
Rotate an object by setting yaw pitch roll
import bpy
import mathutils
import math
# blender rotate in the right hand direction
figher = bpy.context.scene.objects['airplane']
figher.location = (0, 0, 0)
figher.rotation_euler = (0, 0, 0)
@hotohoto
hotohoto / pyproject.toml
Last active May 17, 2024 02:04
A minimum python project setting to support for src layout without considering distribution.
# Add this file into the root folder of your project
# Specify dependencies in requirements.txt and install dependencies with `pip install -e .`
# Then, you don't need to specify the `src` directory within PYTHONPATH when you run a python module in your project.
# This is an exeperimental/opinionated setting. So any comments are welcome.
# references:
# - https://stackoverflow.com/a/73600610/1874690
# - https://packaging.python.org/en/latest/guides/writing-pyproject-toml/
[project]
name = "my-project-name"
@hotohoto
hotohoto / make_grid.sh
Last active December 8, 2023 06:55
Generate grid images from single images in the abc folder
sudo apt update
sudo apt install imagemagick
montage abc/* -tile 8x8 -geometry +1+1 grid_abc.png
@hotohoto
hotohoto / private_fork.md
Created March 20, 2023 11:40 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

# grids = [create_grid(generated_batch[j]) for j in range(len(generated_batch))]
# save_as_gif_animation(grids, output_animation_path)
import math
import numpy as np
from PIL import Image
def create_grid(image_arrays: np.ndarray):
batch_size = image_arrays.shape[0]
@hotohoto
hotohoto / composite_pattern_modifying_another_class.py
Created April 23, 2021 03:33
To modify a class, use composite pattern instead of inheriting a base class
class BaseClass:
def __init__(self, _id, a, k=None):
self.id = _id
self.a = a
self.k = k
def updated(self, **kwargs):
kwargs = {"k": self.k, **kwargs}
return BaseClass(self.id, self.a, **kwargs)
@hotohoto
hotohoto / downsample.py
Last active December 15, 2020 06:45
Downsample a time-series dataset
import pandas as pd
import numpy as np
input_csv = "./weather_history_weekly.csv"
output_csv_2w = "./weather_history_2w.csv"
output_csv_monthly = "./weather_history_monthly.csv"
df = pd.read_csv(input_csv)
N = len(df)
all_columns = df.columns
@hotohoto
hotohoto / window.py
Created December 15, 2020 06:43
Window a time series dataset with pandas
import pandas as pd
import numpy as np
input_csv = "./weather_history_tiny.csv"
output_csv = "./weather_history_tiny_windowed.csv"
df = pd.read_csv(input_csv)
n_lags = 1
N = len(df)
all_columns = df.columns
@hotohoto
hotohoto / example.py
Created October 7, 2020 04:45
Python stack dumper
import signal
import threading
import traceback
import time
import sys
def func2():
y = 2
time.sleep(1)