Skip to content

Instantly share code, notes, and snippets.

View jgs03177's full-sized avatar
🤔
overthinking

LEE Donghyeon jgs03177

🤔
overthinking
  • South Korea
  • 17:13 (UTC +09:00)
View GitHub Profile
# https://www.wolframalpha.com/input?i=minimize+%28y%5E3%2B17y%5E2+-%2818%2B2c%29y%29+where+y+%3E%3D+1%2C+2c+%3E%3D+y%5E2%2B17y-18
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (10,8)
# c -> y -> x -> f -> g
def y(c):
v = ((6*c+343)**0.5-17) / 3
@jgs03177
jgs03177 / analysis1.py
Last active July 6, 2025 00:23
Fruit Box
# analysis
# board, trial
# 2000, 25
algos = ["rand ", "elem ", "sumsq", "area "]
stats = []
for i in range(len(algos)):
filename = f"{algos[i]}_raw.csv"
@jgs03177
jgs03177 / imgconcat.py
Created February 12, 2025 15:01
image concatenator
import glob
import numpy as np
from PIL import Image
from einops import rearrange
def img_concatenator(images, row_batch=0):
# concatenate n images to 1 image
# rearrange to ceil(n/row_batch) x row_batch
np_imgs = [np.array(image) for image in images]
@jgs03177
jgs03177 / randomstring.py
Last active December 26, 2024 10:45
randomstring
import random
cons='bcdfghjklmnpqrstvwxyz_'
vowel='aeiou'
def f(l):
if l<=0:
return ""
c=random.choice(cons)
v=random.choice(vowel)
if c=='_':
@jgs03177
jgs03177 / uniform_sample_dball.py
Created October 28, 2024 06:45
uniform sample from d-ball
def uniformsample_dball(npoint, nd=2):
# https://extremelearning.com.au/how-to-generate-uniformly-random-points-on-n-spheres-and-n-balls/
# # method 20
eps = 1e-12
u = np.random.normal(0,1, (npoint,nd))
norm = np.sum(u ** 2, axis=1) ** 0.5
r = np.random.random(npoint)**(1.0/nd)
x = (r / (norm+eps)).reshape((-1,1)) * u
return x
@jgs03177
jgs03177 / discord_webhook.py
Created April 14, 2024 23:14
discord send message/file via webhook
# https://gist.github.com/Bilka2/5dd2ca2b6e9f3573e0c2defe5d3031b2
# https://www.reddit.com/r/Discord_Bots/comments/iirmzy/how_to_send_files_using_discord_webhooks_python/
import requests
webhook_url = "Insert Webhook URL" # discord webhook url
# test?
# result = requests.get(webhook_url)
@jgs03177
jgs03177 / send_email.py
Created April 8, 2024 13:43
python email example
# Import smtplib for the actual sending function
import smtplib
import getpass
# Import the email modules we'll need
from email.message import EmailMessage
# Create a text/plain message
msg = EmailMessage()
msg.set_content('Testing email notification with python!')
@jgs03177
jgs03177 / log_reqs.py
Created April 5, 2024 15:13
http request analysis with selenium, without fiddler
# request analysis with selenium, without fiddler
# references:
# https://stackoverflow.com/a/63732179
# https://stackoverflow.com/a/27644635
# https://stackoverflow.com/a/69931030
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import json
@jgs03177
jgs03177 / shortname.py
Created January 26, 2024 18:03
울라리
def generate_shortname(s):
"""generate all the possible short name of s
where the output should be a subsequence of s containing the first letter of s.
s : original name (string)
"""
assert len(s)>=2, "The length of the string should be at least 2."
t0, *t = s
len_t = len(t)
oo = []
@jgs03177
jgs03177 / VSCodeCL.bat
Created January 23, 2024 11:16
vscode enable vscpp compiler
call "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/Tools/VsDevCmd.bat"
"%LocalAppData%/Programs/Microsoft VS Code/Code.exe"