Skip to content

Instantly share code, notes, and snippets.

View py-ranoid's full-sized avatar

Vishal Gupta py-ranoid

View GitHub Profile
@py-ranoid
py-ranoid / montreal_eater.ipynb
Last active August 1, 2022 05:34
Plotting Popular Restaurants and Bars according to Eater
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import requests
import pandas as pd
def get_weather_df(lat='40.7128',lon='-74.006',start_date='1979-01-01', end_date='2022-01-15'):
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36',
'Origin': 'https://climate.northwestknowledge.net',
'Sec-Fetch-Site': 'cross-site',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
import requests, datetime, time
PINCODE, WAIT = '600096', 60
def notify(available_sessions):
print("SESSIONS AVAILABLE :%r"%available_sessions)
while True:
resp = requests.get('https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode=600096&date=%s'%datetime.datetime.now().strftime("%d-%m-%Y")).json()
all_sessions = [(center['name'], session['date'], session['available_capacity']) for center in resp['centers'] for session in center['sessions'] if session['min_age_limit']==18]
available_sessions = [i for i in all_sessions if i[2]]
@py-ranoid
py-ranoid / user_script.js
Created November 13, 2020 15:43
Upstox P/L Notifier
// ==UserScript==
// @name Upstox Notifier
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://pro.upstox.com/trading
// @grant none
// ==/UserScript==
@py-ranoid
py-ranoid / WeDontTalkAnymore.py
Last active January 18, 2022 09:35
Visualising number of texts initiated by participants of a WhatsApp thread over time
import re
import pandas as pd
import matplotlib.pyplot as plt
with open('/Users/vishalgupta/Downloads/WhatsApp Chat with MopHead.txt','r') as f:
backup_text = f.read()
matches = re.findall('\n([0-9]+[/][0-9]+[/][0-9]+, [0-9]+[:][0-9]+ [AP]M - [a-zA-Z ]+[:])',backup_text)
sender_df = pd.DataFrame([{'time':pd.to_datetime(row.split('-')[0].strip()),'sender':row.split('-')[1].strip().replace(':','')} for row in matches])
sender_df.groupby('sender').time.hist(bins=30)
plt.show()
@py-ranoid
py-ranoid / gci_instances.py
Last active January 14, 2019 07:03
Downloading Google CodeIn tasks without an API Key.
"""
Note : This approach is an alternative to using the API for fetching instance info by
saving the webpages in ~/Downloads/ instead and using BeautifulSoup for parsing the data.
Go to https://codein.withgoogle.com/dashboard/task-instances/?sp-order=name&sp-my_tasks=false&sp-page_size=100
Iterate over all pages (1, 2, 3...) and save them.
"""
from glob import glob
from bs4 import BeautifulSoup as soup
import pandas as pd
@py-ranoid
py-ranoid / gci_instance_dump.py
Created January 14, 2019 06:52
Downloading Google CodeIn tasks without an API Key.
all_rows = []
for fname in glob("/Users/vishalgupta/Downloads/Task instances _ Google Code-in *.htm"):
with open(fname) as f:
cont = f.read()
s = soup(cont)
rows = s.select('md-table-container tbody tr')
for row in rows:
vals = [i.text.strip() for i in row.select('td') if i.text.strip()]
@py-ranoid
py-ranoid / gci_instance_dump.py
Created January 14, 2019 06:52
Downloading Google CodeIn tasks without an API Key.
all_rows = []
for fname in glob("/Users/vishalgupta/Downloads/Task instances _ Google Code-in *.htm"):
with open(fname) as f:
cont = f.read()
s = soup(cont)
rows = s.select('md-table-container tbody tr')
for row in rows:
vals = [i.text.strip() for i in row.select('td') if i.text.strip()]
@py-ranoid
py-ranoid / SeqModelsSlides.md
Last active December 27, 2018 05:54
Markdown Content for my slides on RNNs and LSTMs. To present as a slideshow refer : http://vishalgupta.me/md-slides/
@py-ranoid
py-ranoid / SeleniumScraper.py
Last active December 27, 2018 05:19
Fetching a website's source (HTML) with Selenium over Python.
from selenium import webdriver,common
"""
How to Download Chrome Driver :
- Go to https://chromedriver.storage.googleapis.com/index.html?path=2.45/
- Download and unzip webdriver for your OS
- Move the webdriver to a where it can be accessed by python. (Same directory or $PATH)
"""
try :