Skip to content

Instantly share code, notes, and snippets.

@JoeThunyathep
JoeThunyathep / Text2Speech.js
Last active April 11, 2020 18:14
Text2Speech.js
const textToSpeech = require('@google-cloud/text-to-speech');
const fs = require('fs');
const util = require('util');
const projectId = 'patrikhornak'
const keyFilename = 'patrikhornak-1f5ece28af9f.json'
const client = new textToSpeech.TextToSpeechClient({ projectId, keyFilename });
const YourSetting = fs.readFileSync('setting.json');
async function Text2Speech(YourSetting) {
const [response] = await client.synthesizeSpeech(JSON.parse(YourSetting));
const writeFile = util.promisify(fs.writeFile);
@JoeThunyathep
JoeThunyathep / setting.json
Created April 11, 2020 18:17
setting.json
{
"audioConfig": {
"audioEncoding": "LINEAR16",
"pitch": 0,
"speakingRate": 1.00
},
"input": {
"text": "Some text input here"
},
"voice": {
@JoeThunyathep
JoeThunyathep / download_file_from_URL.py
Last active April 16, 2020 12:16
The example python script to download file from URL. This example downloads the German COVID-19 cases from RKI.
import urllib.request
from datetime import datetime
print("Start Program ... ")
try:
print("Start Downloading file ... ")
timenow = datetime.now()
timenow_iso = timenow.strftime('%Y-%m-%dT%H:%M:%S') #Time ISO to second resolution
url = 'https://opendata.arcgis.com/datasets/dd4580c810204019a7b8eb3e0b329dd6_0.csv' #url
output= f'data_RKI_{timenow_iso}.csv' # output's file name/ location
urllib.request.urlretrieve(url, output)
@JoeThunyathep
JoeThunyathep / README.md
Created April 17, 2020 14:10 — forked from roachhd/README.md
EMOJI cheatsheet 😛😳😗😓🙉😸🙈🙊😽💀💢💥✨💏👫👄👃👀👛👛🗼🔮🔮🎄🎅👻

EMOJI CHEAT SHEET

Emoji emoticons listed on this page are supported on Campfire, GitHub, Basecamp, Redbooth, Trac, Flowdock, Sprint.ly, Kandan, Textbox.io, Kippt, Redmine, JabbR, Trello, Hall, plug.dj, Qiita, Zendesk, Ruby China, Grove, Idobata, NodeBB Forums, Slack, Streamup, OrganisedMinds, Hackpad, Cryptbin, Kato, Reportedly, Cheerful Ghost, IRCCloud, Dashcube, MyVideoGameList, Subrosa, Sococo, Quip, And Bang, Bonusly, Discourse, Ello, and Twemoji Awesome. However some of the emoji codes are not super easy to remember, so here is a little cheat sheet. ✈ Got flash enabled? Click the emoji code and it will be copied to your clipboard.

People

:bowtie: 😄

@JoeThunyathep
JoeThunyathep / getCovid19Data.py
Last active April 19, 2020 17:48
Scraping COVID-19 Data from Worldometer every 1 minute
import requests, datetime
from bs4 import BeautifulSoup #To install: pip3 install beautifulsoup4
url = "https://www.worldometers.info/coronavirus/"
req = requests.get(url)
bsObj = BeautifulSoup(req.text, "html.parser")
data = bsObj.find_all("div",class_ = "maincounter-number")
NumTotalCase = data[0].text.strip().replace(',', '')
NumDeaths = data[1].text.strip().replace(',', '')
NumRecovered = data[2].text.strip().replace(',', '')
TimeNow = datetime.datetime.now()
@JoeThunyathep
JoeThunyathep / server.js
Created April 20, 2020 16:17
Simple NodeJS server with Express framework
var express = require('express');
var compression = require('compression');
var app = express();
app.use(compression());
app.use(express.static('public'));
var server = app.listen('3000', '0.0.0.0', function () {
console.log('Application Running: http://localhost:%d', server.address().port);
});
@JoeThunyathep
JoeThunyathep / index.html
Created April 20, 2020 17:28
Index file for Cesium NYC application
<html lang="en">
<head>
<meta charset="utf-8">
<script src="https://cesium.com/downloads/cesiumjs/releases/1.68/Build/Cesium/Cesium.js"></script>
<link href="https://cesium.com/downloads/cesiumjs/releases/1.68/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
<div id="cesiumContainer" style="width: 100%; height:100%"></div>
<script>
var viewer = new Cesium.Viewer('cesiumContainer');
tileset.style = new Cesium.Cesium3DTileStyle({
color: {
conditions: [
['${Height} >= 300', 'color("#FF442E")'],
['${Height} >= 200', 'color("#FF8000")'],
['${Height} >= 100', 'color("#E7A700")'],
['${Height} >= 50', 'color("#CFC600")'],
['${Height} >= 25', 'color("#A4B600")'],
['${Height} >= 10', 'color("#6A9E00")'],
['true', 'rgb(127, 59, 8)']
{
"ddd":"ddddddd"
}
@JoeThunyathep
JoeThunyathep / sendCovidEmail.py
Created April 24, 2020 20:21
Python Notification COVID-19
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import requests, datetime
from bs4 import BeautifulSoup #To install: pip3 install beautifulsoup4
email_sender_account = "" #your email
email_sender_username = "" #your email username
email_sender_password = ""#your email password
email_smtp_server = "smtp.gmail.com" #change if not gmail.
email_smtp_port = 587 #change if needed.