This file contains hidden or 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
| # Ref: http://masnun.com/2016/03/29/python-a-quick-introduction-to-the-concurrent-futures-module.html | |
| import time | |
| import random | |
| from concurrent.futures import ThreadPoolExecutor, wait, as_completed | |
| def add(name): | |
| res = random.randint(1, 5) | |
| res = 2 |
This file contains hidden or 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 cv2 | |
| import io | |
| import socket | |
| import struct | |
| import time | |
| import pickle | |
| import zlib | |
| client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| client_socket.connect(('192.168.1.124', 8485)) |
This file contains hidden or 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
| """ | |
| Adding a variable into Keras/TensorFlow CNN dense layer | |
| https://stackoverflow.com/questions/42556919/adding-a-variable-into-keras-tensorflow-cnn-dense-layer | |
| ___________ _________ _________ _________ ________ ______ | |
| | Conv | | Max | | Conv | | Max | | | | | | |
| Image --> | Layer 1 | --> | Pool 1 | --> | Layer 2 | --> | Pool 2 | -->| | | | | |
| |_________| |________| |_________| |________| | Dense | | Out | | |
| | Layer |-->|_____| |
This file contains hidden or 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
| #Edit /etc/network/interfaces | |
| auto wlan0 | |
| iface wlan0 inet dhcp | |
| wpa-ssid {ssid} | |
| wpa-psk {password} |
This file contains hidden or 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 subprocess | |
| from gtts import gTTS | |
| def play_mp3(path): | |
| subprocess.Popen(['mpg123', '-q', path]).wait() | |
| text = "สวัสดี" | |
| tts = gTTS(text=text, lang='th') | |
| tts.save("hello.mp3") | |
| play_mp3("hello.mp3") |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| # 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 |
This file contains hidden or 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
| #!/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])] |
This file contains hidden or 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 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): |
This file contains hidden or 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 pickle | |
| import broadlink | |
| import sys | |
| import os | |
| if len(sys.argv) != 3: | |
| sys.exit(0) | |
| type = sys.argv[1] | |
| command = sys.argv[2] |