Skip to content

Instantly share code, notes, and snippets.

View kittinan's full-sized avatar
🇹🇭
|||

Kittinan kittinan

🇹🇭
|||
View GitHub Profile
@kittinan
kittinan / spotipy.py
Created August 2, 2018 15:28
sample code for spotipy
# https://github.com/plamere/spotipy/issues/194#issuecomment-315458391
# http://spotipy.readthedocs.io/en/latest/#client-credentials-flow
import spotipy
from spotipy.oauth2 import SpotifyClientCredentials
client_credentials_manager = SpotifyClientCredentials(client_id='CLIENT_ID', client_secret='CLIENT_SECRET')
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="js/face-api.min.js"></script>
</head>
<body>
@kittinan
kittinan / matplotlib_candle_stick.py
Created July 3, 2018 09:39
Matplotlib plot candle stick
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from mpl_finance import candlestick_ohlc
df = pd.read_csv('data.csv', parse_dates=True)
start = "2016-01-01"
end = "2016-03-31"
@kittinan
kittinan / jupyter_shortcuts.md
Created May 28, 2018 03:06 — forked from kidpixo/jupyter_shortcuts.md
Keyboard shortcuts for ipython notebook 3.1.0 / jupyter

Toc

Keyboard shortcuts

The IPython Notebook has two different keyboard input modes. Edit mode allows you to type code/text into a cell and is indicated by a green cell border. Command mode binds the keyboard to notebook level actions and is indicated by a grey cell border.

MacOS modifier keys:

  • ⌘ : Command
@kittinan
kittinan / stock.py
Created May 16, 2018 07:12
Yahoo stock pandas
from pandas_datareader import data as pdr
import fix_yahoo_finance as yf
yf.pdr_override()
data = pdr.get_data_yahoo("ADVANC.BK", start="2001-01-01", end="2018-05-16")
@kittinan
kittinan / remote.py
Created May 11, 2018 09:51
Broadlink send IR command
import pickle
import broadlink
import sys
import os
if len(sys.argv) != 3:
sys.exit(0)
type = sys.argv[1]
command = sys.argv[2]
@kittinan
kittinan / download.py
Last active May 4, 2018 09:50
Download Youtube Audio with multi threading
import pandas as pd
import youtube_dl
import os
from youtube_dl.utils import DownloadError
from concurrent.futures import ThreadPoolExecutor, wait, as_completed
def download_youtube(youtube_id, idx):
@kittinan
kittinan / AESCipher.py
Created April 30, 2018 04:02 — forked from swinton/AESCipher.py
Encrypt & Decrypt using PyCrypto AES 256 From http://stackoverflow.com/a/12525165/119849
#!/usr/bin/env python
import base64
from Crypto import Random
from Crypto.Cipher import AES
BS = 16
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s : s[0:-ord(s[-1])]
@kittinan
kittinan / plot_history.py
Created April 10, 2018 14:44
keras plot history object
# Ref: https://www.kaggle.com/danbrice/keras-plot-history-full-report-and-grid-search
def plot_history(history):
loss_list = [s for s in history.history.keys() if 'loss' in s and 'val' not in s]
val_loss_list = [s for s in history.history.keys() if 'loss' in s and 'val' in s]
acc_list = [s for s in history.history.keys() if 'acc' in s and 'val' not in s]
val_acc_list = [s for s in history.history.keys() if 'acc' in s and 'val' in s]
if len(loss_list) == 0:
print('Loss is missing in history')
return
@kittinan
kittinan / score.txt
Last active April 6, 2018 00:52
Deepcut JS score
Model: lite_model_v1.h5 (Dense 100)
f1score: 0.979600348056747
precision: 0.9749029122509861
recall: 0.9843432709344426
Model: lite_model_v1_1.h5 (Dense 100)
f1score: 0.9807887916860532
precision: 0.9759241434331015
recall: 0.9857021801093907