Skip to content

Instantly share code, notes, and snippets.

View dzakyputra's full-sized avatar

Dzaky Widya Putra dzakyputra

View GitHub Profile
@dzakyputra
dzakyputra / designer.html
Last active January 2, 2016 04:56
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../speech-mic/speech-mic.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../google-map/google-map.html">
@dzakyputra
dzakyputra / main.py
Last active September 26, 2021 03:49
main python file of automatebot
from google.cloud import bigquery
from telegram.ext import Updater
import matplotlib.pyplot as plt
import numpy as np
import datetime
def query_to_bigquery(query):
client = bigquery.Client()
query_job = client.query(query)
data_df = {'Customer':['tom', 'nick', 'krish', 'jack', 'jack', 'tom', 'jack', 'krish', 'nick', 'nick'],
'Origin':['Tebet', 'Gondangdia', 'Mampang', 'SCBD', 'SCBD', 'Kuningan', 'Pancoran', 'Tebet', 'Mampang', 'Tebet'],
'Destination':['Gondangdia', 'Mampang', 'SCBD', 'Kuningan', 'Pancoran', 'Pancoran', 'Mampang', 'SCBD', 'SCBD', 'Kuningan'],
'Distance': [4.5, 5.0, 3.0, 4.8, 2.2, 4.7, 3.4, 4.0, 2.2, 2.9],
'Price': [20000, 23000, 14000, 24500, 7000, 20000, 15000, 18500, 9000, 11000]}
df = pd.DataFrame(data_df)
df
import pandas as pd
import os
from PIL import Image
import glob
df = pd.read_excel('result.xlsx')
out = {
'user_id': [],
'type': [],
# Search the date of birth
def search_dob(text):
# Define the pattern to get dates (20-07-2018, 20 07 2018, 20-07 2018, 20 07-2018)
# reg_dob = '(\d{2}[\/ -]\d{2}[\/ -]\d{2,4})'
# reg_dob = '(((0[1-9]|([1-2][0-9])|3[01])[-./ \s]?((0[13578])|(10|12)))|((0[1-9]|([1-2][0-9])|3[0])[-./ \s]?((0[469])|11))|((0[1-9]|[1-2][0-9])[-./ \s]?(02)))[-./ \s]?[\d]{2,4}'
reg_dob = '((((0[\ ]*[1-9][\ ]*|([1-2][\ ]*[0-9][\ ]*)|3[\ ]*[01][\ ]*)[-.—/ \s]*((0[\ ]*[13578][\ ]*)|(1[\ ]*0[\ ]*|1[\ ]*2[\ ]*)))|((0[\ ]*[1-9][\ ]*|([1-2][\ ]*[0-9][\ ]*)|3[\ ]*[0][\ ]*)[-./ —\s]*((0[\ ]*[469][\ ]*)|1[\ ]*1[\ ]*))|((0[\ ]*[1-9][\ ]*|[1-2][\ ]*[0-9][\ ]*)[-./ —\s]*(0[\ ]*2[\ ]*)))[-./ —\s]*([\d][\ ]*){2,4})'
# Find all strings that match
dates = re.finditer(reg_dob, text)
# Search the date of birth
def search_dob(text):
# Define the pattern to get dates (20-07-2018, 20 07 2018, 20-07 2018, 20 07-2018)
reg_dob = '(\d{2}[\/ -]\d{2}[\/ -]\d{2,4})'
# Find all strings that match
dates = re.findall(reg_dob, text)
# We iterate through the results and convert it into datetime format
import os
import io
import sys
import subprocess
import tesserocr
from pyspark.sql import SparkSession
# Initiate spark session
spark = SparkSession.builder \
from google.cloud import texttospeech
from bs4 import BeautifulSoup
import pandas as pd
import requests
import re
def get_hangeul():
# Scrape the website and get list of titles
url = 'https://www.bbc.com/korean/popular/read'
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
titles = soup.findAll('span',
{'class': 'most-popular-list-item__headline'})
# Iterate through titles -> remove punctuation -> append to the list
def create_audio(text, language='ko-KR'):
# Instantiates a client
client = texttospeech.TextToSpeechClient()
# Set the text input to be synthesized
synthesis_input = texttospeech.types.SynthesisInput(text=text)
# Build the voice request, select the language code ("en-US") and the ssml
# voice gender ("neutral")