Skip to content

Instantly share code, notes, and snippets.

@dooyeoung
dooyeoung / base62.py
Last active August 3, 2022 12:40
base62
# 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
# [0-9,a-z,A-Z] 62자로 구성되며 예측 난이도를 높이기 위해 무작위로 섞습니다.
BASE62 = "dCsuHTIWEcOPLhrgwBpRx4flv8JMKGDVmQ01qtejY9iNFzn5okX63aZAbySU27"
def encode(num, alphabet=BASE62):
if num == 0:
return alphabet[0]
arr = []
base = len(alphabet)
while num:
@dooyeoung
dooyeoung / draw_ratiobar.py
Created June 26, 2019 01:17
Draw RatioBar
def drawRatioBar(score_keytalk_category):
fig = plt.figure(figsize=(20,1))
ax = fig.add_subplot(111)
patch_handles = []
data = [r['score'] for r in score_keytalk_category]
percentages = [r['score'] for r in score_keytalk_category]
label = [r['kl_category'] for r in score_keytalk_category]
left = 0
for d in data:
@dooyeoung
dooyeoung / rgb2hex.py
Created June 26, 2019 01:16
rgb to hex
def rgb2hex(rgb):
'''
리스트 형식의 rgb 값을 hexcode로 변환
:param rgb: list ex)[255, 255, 255]
:return : hex code
'''
return '#{:02x}{:02x}{:02x}'.format( rgb[0], rgb[1] , rgb[2])
@dooyeoung
dooyeoung / hex2rgb.py
Created June 26, 2019 01:16
hex to rgb
def hex2rgb(hexcode):
hexcode = hexcode.lstrip('#')
lv = len(hexcode)
return list(int(hexcode[i:i + lv // 3], 16) for i in range(0, lv, lv // 3))
@dooyeoung
dooyeoung / check_quadrant.py
Created June 25, 2019 04:53
check Quadrant - 사사분면 확인
def get_area(degree):
area = 1
if degree > 0 and degree <=90:
area = 1
elif degree > 90 and degree <=180:
area = 2
elif degree > 180 and degree <=270:
area = 3
elif degree > 270 and degree <=360:
area = 4
@dooyeoung
dooyeoung / get_degree.py
Created June 25, 2019 04:42
coordinate to degree - 좌표를 각도로 변환
# x= 2, y= 2
# 1사분면
np.arctan2(2, 2) * 180 / np.pi
# 45
# x=-2, y= 2
# 2사분면
np.arctan2(2, -2) * 180 / np.pi
# 135