Skip to content

Instantly share code, notes, and snippets.

Avatar

Seokjoon Ahn joonahn

  • POSTECH
  • Pohang
View GitHub Profile
@joonahn
joonahn / contry_name_emoji_map.py
Last active Feb 23, 2020
국가 이름과 국가 emoji 매핑
View contry_name_emoji_map.py
# usage : contries_flag_dict.get("<국가명>", "")
contries_flag_dict = {
"어센션 섬" : "🇦🇨",
"안도라" : "🇦🇩",
"아랍에미리트" : "🇦🇪",
"아프가니스탄" : "🇦🇫",
"앤티가 바부다" : "🇦🇬",
"앵귈라" : "🇦🇮",
"알바니아" : "🇦🇱",
"아르메니아" : "🇦🇲",
View spin.sh
i=1
sp="/-\|"
echo -n ' '
while true
do
printf "\b${sp:i++%${#sp}:1}"
sleep 0.1
done
@joonahn
joonahn / SimpleHTTPServerWithUpload.py
Last active Apr 26, 2021 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server can upload multiple files
View SimpleHTTPServerWithUpload.py
#!/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
"""
@joonahn
joonahn / generate_noise.py
Last active Sep 28, 2018
Code that generate random noises
View generate_noise.py
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)
@joonahn
joonahn / get_data.py
Created Sep 13, 2018
Get data from web
View get_data.py
import requests
URL = 'http://www.tistory.com'
response = requests.get(URL)
print(response.status_code)
print(response.text)
@joonahn
joonahn / profile_python_method.md
Last active Jun 20, 2018
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):
@joonahn
joonahn / repair_broken_mac_filename.py
Last active Oct 8, 2019
mac에서 생성한 한글 파일명을 windows에서 읽을 때 깨진 파일을 복구해 주는 스크립트
View repair_broken_mac_filename.py
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]
@joonahn
joonahn / nfd2nfc.py
Created Apr 24, 2018
Mac에서 깨진 파일 string을 합쳐진 windows string으로 변환하는 함수
View nfd2nfc.py
from unicodedata import normalize
def nfd2nfc(data):
return normalize('NFC', data)
View get_code_line_number.py
import inspect
def get_caller_source_lines(cls, num_of_prev_functions=1):
# num_of_prev_functions
frame = inspect.stack()[1 + num_of_prev_functions]
_, linenum, _, _, _ = inspect.getframeinfo(frame)
return linenum
View logtest.py
import logging.config
import pkg_resources
resource_package = __name__
resource_path = '../logging.conf'
conf_file = pkg_resources.resource_filename(resource_package, resource_path)
print(conf_file)
logging.config.fileConfig(resource_path)
mylog = logging.getLogger("dev")