๐ฏ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "๋๋ ์ ํํฌ์์ฆ๊ถ์ ์ ์ฌํ๋ ค๋ ๊ฐ๋ฐ์์ผ. ํด๋ผ์ฐ๋๋ฅผ ๊ณต๋ถํด์ผ ํ ํ์๊ฐ ์์๊น?" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openai | |
openai.api_key = 'sk-APIํค๋ฅผ ์ ๋ ฅํฉ๋๋ค' | |
def lambda_handler(event, context): | |
message = openai.ChatCompletion.create( | |
model="gpt-4o-mini", # ์ฌ์ฉ ๋ชจ๋ธ | |
messages=[ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): | |
# ๋ฐฐ๊ฒฝ ํด๋ฆฝ ์์ฑ (ํ๋์ ๋ฐฐ๊ฒฝ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |