Skip to content

Instantly share code, notes, and snippets.

View kaikiat's full-sized avatar
🏗️
Building

Kai Kiat Poh kaikiat

🏗️
Building
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<link rel="shortcut icon" href="https://img.icons8.com/material-rounded/24/000000/download-2.png">
<script src='script.js'></script>
.searchBox {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,50%);
background: #2f3640;
height: 40px;
border-radius: 40px;
padding: 10px;
function download_img(){
var URLinput = document.querySelector('.searchInput');
console.log(URLinput.value);
sendURL(URLinput.value);
}
function sendURL(URL) {
window.location.href = `http://localhost:3000/download?URL=${URL}`;
}
const express = require('express');
const save = require('instagram-save');
const app = express();
app.get('/download', (req,res) => {
var URL = req.query.URL;
var myDir='/Users/kaikiat/Programming/youtube_dld'; //your_path
var splitted_URL=URL.split("/"); ///returns an array
var array_length=splitted_URL.length;
insta_photo_id=splitted_URL[array_length-2]
@kaikiat
kaikiat / plot_graph.py
Created October 6, 2019 14:47
Function to plot a stock's closing price against time
import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web
def show_closing_price(ticker,start,end):
style.use('ggplot')
df=web.DataReader(ticker,'yahoo',start,end)
@kaikiat
kaikiat / ma.py
Created October 6, 2019 15:51
Function to plot 200-day MA and 100-day MA
import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web
def plot_ma(ticker,start,end):
style.use('ggplot')
df=web.DataReader(ticker,'yahoo',start,end)
@kaikiat
kaikiat / main.py
Created January 12, 2020 08:15
Telegram Bot inline keyboard to prompt user for the service that they require
def sendInlineMessageForService(chat_id):
text_message='Hi! I am your Hair Sylist Bot!\nI can help you book an appointment.\n\nYou can control me using these commands\n\n/start-to start chatting with the bot\n/cancel-to stop chatting with the bot.\n\nFor more information please contact automationfeed@gmail.com'
keyboard={'keyboard':[
[{'text':'Cut'},{'text':'Dye'}],
[{'text':'Perm'},{'text':'Reborn'}]
]}
key=json.JSONEncoder().encode(keyboard)
url='https://api.telegram.org/bot'+str(api_key)+'/sendmessage?chat_id='+str(chat_id)+'&text='+str(text_message)+'&reply_markup='+key
response = requests.get(url)
return response
@kaikiat
kaikiat / schdulder.py
Created January 12, 2020 07:53
Script to schedule events in Google-Calendar
from __future__ import print_function
import datetime
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
# If modifying these scopes, delete the file token.pickle.
# SCOPES = ['https://www.googleapis.com/auth/calendar.readonly']
@kaikiat
kaikiat / main.py
Created January 12, 2020 08:22
Telegram Bot inline keyboard to prompt user for the time for their apppointment
def sendInlineMessageForBookingTime(chat_id):
text_message='Please choose a time slot...'
current_time=datetime.datetime.now()
current_hour=str(current_time)[11:13]
# ----------- Chunk of if statement to determine which inline keyboard to reply user ----------------
if int(current_hour) < 8:
keyboard={'keyboard':[
[{'text':'08:00'}],[{'text':'10:00'}],
[{'text':'12:00'}],[{'text':'14:00'}],
[{'text':'16:00'}],[{'text':'18:00'}],
@kaikiat
kaikiat / main.py
Created January 12, 2020 09:05
Telegram Bot inline keyboard to prompt user for their email as well as to verify their email using regex
def check_email(email):
regex = '^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$'
if(re.search(regex,email)):
print("Valid Email")
return True
else:
print("Invalid Email")
return False