Skip to content

Instantly share code, notes, and snippets.

View koorukuroo's full-sized avatar
๐ŸŽฏ
Focusing

Kyunghoon Kim koorukuroo

๐ŸŽฏ
Focusing
View GitHub Profile
import random
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
# Monty Hall simulation function
def monty_hall(switch=True):
prize_door = random.randint(0, 2) # Randomly assign the prize behind one of the three doors
chosen_door = random.randint(0, 2) # Player's initial choice of door
doors = [0, 1, 2]
import numpy as np
import time
def monty_hall_numpy(trials=100000000, switch=True):
"""
Fully vectorized Monty Hall simulation using NumPy for maximum performance.
Parameters:
trials (int): Number of games to simulate.
switch (bool): If True, the player switches doors; otherwise, they stay.
import random
# Define the Monty Hall function
def monty_hall(switch=True):
"""
Simulates one round of the Monty Hall game.
Parameters:
switch (bool): If True, the player switches their choice after the host opens a door.
from moviepy.editor import VideoClip, TextClip
from tqdm import tqdm
def make_frame(t):
# Calculate remaining time in minutes and seconds
remaining_time = max(0, int(5*60 - t))
minutes, seconds = divmod(remaining_time, 60)
time_str = f"{minutes:01d}:{seconds:02d}"
# Create TextClip for the countdown with 4K resolution
import openai
openai.api_key = 'sk-API ํ‚ค๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”'
def lambda_handler(event, context):
if 'm' in event['params']['querystring']:
input_message = event['params']['querystring']['m']
else:
input_message = "๋‚˜๋Š” ์‹ ํ•œํˆฌ์ž์ฆ๊ถŒ์— ์ž…์‚ฌํ•˜๋ ค๋Š” ๊ฐœ๋ฐœ์ž์•ผ. ํด๋ผ์šฐ๋“œ๋ฅผ ๊ณต๋ถ€ํ•ด์•ผ ํ•  ํ•„์š”๊ฐ€ ์žˆ์„๊นŒ?"
import openai
openai.api_key = 'sk-APIํ‚ค๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค'
def lambda_handler(event, context):
message = openai.ChatCompletion.create(
model="gpt-4o-mini", # ์‚ฌ์šฉ ๋ชจ๋ธ
messages=[
from fastapi import FastAPI
import redis
app = FastAPI()
redis_client = redis.Redis(host='localhost', port=6379, db=0)
@app.get("/items/{id}")
def read_item(id: str):
value = redis_client.get(id)
if value:
from moviepy.editor import TextClip, CompositeVideoClip, ColorClip
from moviepy.editor import VideoFileClip, concatenate_videoclips
from moviepy.video.fx.all import fadein, fadeout
from multiprocessing import Pool
import os
# ์‹œ๊ฐ„์„ HH:MM:SS ํ˜•์‹์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
def format_time(seconds):
hours = seconds // 3600
minutes = (seconds % 3600) // 60
@koorukuroo
koorukuroo / 1min.py
Created September 4, 2024 12:09
generate 1min countdown video
from moviepy.editor import TextClip, CompositeVideoClip, ColorClip
from moviepy.video.fx.all import fadein, fadeout
# 60์ดˆ ์นด์šดํŠธ๋‹ค์šด ๋น„๋””์˜ค ์ƒ์„ฑ (๋ฉ”๋ชจ๋ฆฌ ์ตœ์ ํ™”)
def create_stylish_countdown_video(duration=60):
# ๋น„๋””์˜ค ํŒŒ์ผ์˜ ํŒŒํŠธ๋“ค์„ ์ €์žฅํ•  ๋ฆฌ์ŠคํŠธ
filenames = []
for i in range(duration, 0, -1):
# ๋ฐฐ๊ฒฝ ํด๋ฆฝ ์ƒ์„ฑ (ํŒŒ๋ž€์ƒ‰ ๋ฐฐ๊ฒฝ)
@koorukuroo
koorukuroo / cuda_11.8_installation_on_Ubuntu_22.04
Created January 22, 2024 10:14 — forked from MihailCosmin/cuda_11.8_installation_on_Ubuntu_22.04
Instructions for CUDA v11.8 and cuDNN 8.7 installation on Ubuntu 22.04 for PyTorch 2.0.0
#!/bin/bash
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
### to verify your gpu is cuda enable check