Skip to content

Instantly share code, notes, and snippets.

View SankaitLaroiya's full-sized avatar

Sankait Laroiya SankaitLaroiya

View GitHub Profile
@SankaitLaroiya
SankaitLaroiya / changeTZ.sh
Created June 27, 2018 19:30
Changing timezone of a linux machine
# All the available time zones are in directory /usr/share/zoneinfo
# Choose whichever one you want and replace the path below
ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
@SankaitLaroiya
SankaitLaroiya / gethostname.js
Created March 9, 2018 21:52
(JS) Get the host name from a URL
// Code snippet taken from:
// https://stackoverflow.com/questions/8498592/extract-hostname-name-from-string
function getHostNameFromURL(url) {
if (!url) {
return null;
}
let hostname;
@SankaitLaroiya
SankaitLaroiya / scale.js
Last active March 9, 2018 21:54
(JS) Scale Numbers Between a Given Range
// Code snippet taken from:
// https://stackoverflow.com/a/31687097
function scaleBetween(unscaledNum, minAllowed, maxAllowed, min, max) {
return (maxAllowed - minAllowed) * (unscaledNum - min) / (max - min) + minAllowed;
}
@SankaitLaroiya
SankaitLaroiya / main.py
Last active February 17, 2018 05:03
(Python) Speech recognition using IBM Speech to Text
#!/usr/bin/env python3
# NOTE 1: Add the username and password to your IBM Watson account below
# (More info: https://www.ibm.com/watson/services/text-to-speech/)
# NOTE 2: this example requires PyAudio because it uses the Microphone class
# pip3 install pyaudio
# if getting an error do
# brew remove portaudio
# brew install portaudio