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 numpy as np | |
import wave | |
import matplotlib.pyplot as plt | |
import sounddevice as sd | |
class SoundFile: | |
def __init__(self, file_name=None): | |
# https://docs.python.org/3.6/library/wave.html | |
pass | |
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
# -*- coding: utf-8 -*- | |
cho = "ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ" # len = 19 | |
jung = "ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ" # len = 21 | |
jong = "ㄱ/ㄲ/ㄱㅅ/ㄴ/ㄴㅈ/ㄴㅎ/ㄷ/ㄹ/ㄹㄱ/ㄹㅁ/ㄹㅂ/ㄹㅅ/ㄹㅌ/ㄹㅍ/ㄹㅎ/ㅁ/ㅂ/ㅂㅅ/ㅅ/ㅆ/ㅇ/ㅈ/ㅊ/ㅋ/ㅌ/ㅍ/ㅎ".split('/') # len = 27 | |
test = cho + jung + ''.join(jong) | |
hangul_length = len(cho) + len(jung) + len(jong) # 67 |
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
""" | |
It is partial black in python to be utilized in windows PyCharm. | |
- To see partial black here (https://blog.godatadriven.com/black-formatting-selection) | |
- This code is conversion of this shell script (https://gist.github.com/BasPH/5e665273d5e4cb8a8eefb6f9d43b0b6d) | |
If you want to use in windows, you should first complie this python to exe. | |
- To do that, see (https://pypi.org/project/auto-py-to-exe/) | |
""" | |
import os | |
import sys |
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 numpy as np | |
def exponentially_weighted_matrix(discount, mat_len): | |
DisMat = np.triu(np.ones((mat_len, mat_len)) * discount, k=1) | |
DisMat[DisMat==0] = 1 | |
DisMat = np.cumprod(DisMat, axis=1) | |
DisMat = np.triu(DisMat) | |
return DisMat | |
def exponentially_weighted_cumsum(discount, np_data): |
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
class Map(dict): | |
def __init__(self, *args, **kwargs): | |
super(Map, self).__init__(*args, **kwargs) | |
for arg in args: | |
if isinstance(arg, dict): | |
for k, v in arg.items(): | |
self[k] = v | |
if kwargs: |
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 IPython.core.display import display, HTML, Javascript | |
def Archive_the_bk_canvas(): | |
archiving_the_bkcanvas= "\ | |
console.log(this); \ | |
var loop = setInterval(execute.bind(this, null), 1000); \ | |
function execute(output_area){ \ | |
console.log(this); \ | |
if(this.element.find(\".bk-canvas\").length == 0){\ | |
console.log(\"loop\"); \ |
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 nbformat | |
import nbconvert | |
import sys | |
if len(sys.argv) < 2: | |
print("Usage:", sys.argv[0], 'filename.ipynb', '[--slides]') | |
exit(-1) | |
with open(sys.argv[1]) as nb_file: | |
nb_contents = nb_file.read() |
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, termios, atexit | |
from select import select | |
# save the terminal settings | |
fd = sys.stdin.fileno() | |
new_term = termios.tcgetattr(fd) | |
old_term = termios.tcgetattr(fd) | |
# new terminal setting unbuffered | |
new_term[3] = (new_term[3] & ~termios.ICANON & ~termios.ECHO) |
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 termios, fcntl, sys, os | |
def get_char_keyboard_nonblock(): | |
fd = sys.stdin.fileno() | |
oldterm = termios.tcgetattr(fd) | |
newattr = termios.tcgetattr(fd) | |
newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO | |
termios.tcsetattr(fd, termios.TCSANOW, newattr) |
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
class _GetchUnix: | |
def __init__(self): | |
import tty, sys | |
def __call__(self): | |
import sys, tty, termios | |
fd = sys.stdin.fileno() | |
old_settings = termios.tcgetattr(fd) | |
try: |