Skip to content

Instantly share code, notes, and snippets.

View jeakwon's full-sized avatar

Jea Kwon jeakwon

View GitHub Profile
@jeakwon
jeakwon / to_json.py
Created February 1, 2019 13:37
python save dict as json file
import json
def to_json(dictionary, filename):
with open(filename,'w') as fp:
json.dump(dictionary, fp,sort_keys=True, indent=4,ensure_ascii=False)
@jeakwon
jeakwon / hangul.py
Created February 5, 2019 06:56
주피터 노트북 한글 표시
from matplotlib import font_manager, rc
font_name = font_manager.FontProperties(fname="c:/Windows/Fonts/malgun.ttf").get_name()
rc('font', family=font_name)
@jeakwon
jeakwon / desktop.py
Last active February 12, 2019 02:12
Desktop path snippet
import os
def get_file_from_desktop(filename):
filepath = os.path.expanduser('~/Desktop')
fullpath = get_file(filepath,filename)
return fullpath
@jeakwon
jeakwon / setup.cfg
Created February 12, 2019 09:18
setup.cfg for pip install package
[metadata]
description-file = README.md
@jeakwon
jeakwon / setup.py
Last active February 12, 2019 10:12
pip install build
from setuptools import setup, find_packages
setup(
name = 'ccpy',
version = '0.1',
description = 'ccpy',
author = 'jeakwon',
author_email = 'onlytojay@gmail.com',
url = 'https://github.com/jeakwon/ccpy',
download_url = 'https://github.com/jeakwon/ccpy/archive/0.0.tar.gz',
@jeakwon
jeakwon / array.py
Created February 14, 2019 02:46
array print example
import numpy as np
arr = np.array([
[1,2],
[3,4],
])
print(arr)
@jeakwon
jeakwon / setup.py
Created February 18, 2019 02:03
setup.py with markdown
from setuptools import setup, find_packages
with open('README.md', encoding='utf-8') as f:
long_description = f.read()
setup(
name = 'ypcc',
version = '0.6.6',
long_description = long_description,
long_description_content_type='text/markdown',
description = 'ccpy',
@jeakwon
jeakwon / logger.py
Created March 2, 2019 09:11
Neat Logger
# -*- coding: utf-8 -*-
import logging.handlers
class Setting:
"""로거 세팅 클래스
::
Setting.LEVEL = logging.INFO # INFO 이상만 로그를 작성
"""
@jeakwon
jeakwon / runtime.py
Created May 8, 2019 03:49
runtime_decorator
def runtime(func):
@wraps(func)
def decorated(*args, **kwargs):
# Decorate front of func
before = time.time()
output = func(*args, **kwargs)
# Decorate back of func
after = time.time()
@jeakwon
jeakwon / sr_with_timestamp.py
Created June 24, 2019 01:37
google_cloud_speech_recognition.py
import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="<credential_file>.json"
def transcribe_gcs_with_word_time_offsets(gcs_uri):
"""Transcribe the given audio file asynchronously and output the word time
offsets."""
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types
client = speech.SpeechClient()