Instantly share code, notes, and snippets.

# Seokjoon Ahn joonahn

• POSTECH
• Pohang
Created November 5, 2021 09:05
create 24 unique 3x3 cube rotation matrices.
View create_cube_rotation.py
This file contains 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
 # the algorithm is from https://stackoverflow.com/questions/16452383/how-to-get-all-24-rotations-of-a-3-dimensional-array import nunpy as np rollmat = np.array([[1, 0, 0], [0, 0, 1], [0, -1, 0]], dtype=np.float) turnmat = np.array([[0, -1, 0], [1, 0, 0], [0, 0, 1]], dtype=np.float) def get_24_rotation(): rotations = [] current_rot = np.eye(3)
Created September 2, 2021 00:43
training main.py boilerplate
View main.py
This file contains 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 argparse def str2bool(v): if isinstance(v, bool): return v if v.lower() in ('yes', 'true', 't', 'y', '1'): return True elif v.lower() in ('no', 'false', 'f', 'n', '0'): return False else:
Last active February 23, 2020 13:17
국가 이름과 국가 emoji 매핑
View contry_name_emoji_map.py
This file contains 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
 # usage : contries_flag_dict.get("<국가명>", "") contries_flag_dict = { "어센션 섬" : "🇦🇨", "안도라" : "🇦🇩", "아랍에미리트" : "🇦🇪", "아프가니스탄" : "🇦🇫", "앤티가 바부다" : "🇦🇬", "앵귈라" : "🇦🇮", "알바니아" : "🇦🇱", "아르메니아" : "🇦🇲",
Created March 26, 2019 09:08
View spin.sh
This file contains 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
 i=1 sp="/-\|" echo -n ' ' while true do printf "\b\${sp:i++%\${#sp}:1}" sleep 0.1 done
Last active August 27, 2022 04:54 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server can upload multiple files
This file contains 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
 #!/usr/bin/env python3 """Simple HTTP Server With Upload. This module builds on BaseHTTPServer by implementing the standard GET and HEAD requests in a fairly straightforward manner. see: https://gist.github.com/UniIsland/3346170 """
Last active September 28, 2018 06:14
Code that generate random noises
View generate_noise.py
This file contains 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 sys import numpy as np data = np.random.uniform(-1, 1, [int(input("input random array length:"))]) data = np.around(data, 3).tolist() print(data)
Created September 13, 2018 01:51
Get data from web
View get_data.py
This file contains 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 requests URL = 'http://www.tistory.com' response = requests.get(URL) print(response.status_code) print(response.text)
Last active June 20, 2018 00:35
python method profile 방법
View profile_python_method.md

# Profile python methods

python method를 profile 하는 간단한 방법에 대한 소개

## Code

우선 decorator method를 정의한다. 그 뒤 profile 대상 메소드 def 위에 `@profileit` decorator를 붙인다.

```import cProfile

def profileit(func):
def wrapper(*args, **kwargs):```
Last active October 8, 2019 05:58
mac에서 생성한 한글 파일명을 windows에서 읽을 때 깨진 파일을 복구해 주는 스크립트
View repair_broken_mac_filename.py
This file contains 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 sys from unicodedata import normalize import glob import os def nfd2nfc(data): return normalize('NFC', data) if len(sys.argv) > 1: dirname = sys.argv[1]
Created April 24, 2018 02:16
Mac에서 깨진 파일 string을 합쳐진 windows string으로 변환하는 함수
View nfd2nfc.py
This file contains 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 unicodedata import normalize def nfd2nfc(data): return normalize('NFC', data)