Skip to content

Instantly share code, notes, and snippets.

View jgs03177's full-sized avatar
🤔
thinking

LEE Donghyeon jgs03177

🤔
thinking
  • South Korea
  • 02:04 (UTC +09:00)
View GitHub Profile
@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"
@jgs03177
jgs03177 / fix_unicode_escape.py
Created January 23, 2024 10:57
fix dict unicode escape (maybe because of json)
def _decode_unicode_escape_in_dict_(target_dict):
new_dict = {}
for key1, value1 in target_dict.items():
key1 = key1.encode().decode("unicode-escape")
if isinstance(value1, dict):
value1 = _decode_unicode_escape_in_dict_(value1)
elif isinstance(value1, str):
value1 = value1.encode().decode("unicode-escape")
new_dict[key1] = value1
return new_dict
@jgs03177
jgs03177 / distribution_ab.py
Created January 23, 2024 10:42
beta, gamma, dirichlet distribution test
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def beta_test():
b = np.random.beta(1,2,2000)
b0 = np.random.beta(1,1,1000)
x = np.random.uniform(0,1,2000)
x = x.reshape((-1,2))
b1 = (1 - (1 - x) ** (1/2 + 0j)).real
@jgs03177
jgs03177 / amalgamation.py
Created January 23, 2024 10:39
Code amalgamation example (python)
# python file amalgamation example (amalgamate cpython into one file)
import os
target_folder_name = r"repo\cpython"
output_file_name = "cpython.txt"
with open(output_file_name, "xb") as o_f:
for root, dirs, files in os.walk(target_folder_name):
for name in files:
_, ext = os.path.splitext(name)
@jgs03177
jgs03177 / imagedataset.py
Created January 23, 2024 10:36
pytorch dataloader example
import os
import errno
import cv2
import torch
import numpy as np
import random
from torch.utils.data import Dataset, ConcatDataset, DataLoader
from typing import Callable
@jgs03177
jgs03177 / infinity.py
Created January 23, 2024 10:16
Understanding python list
a = []
a.append(a)
while len(a) >= 1:
print(a)
a = a[0]
import copy
b = copy.deepcopy(a)
print(b)