Skip to content

Instantly share code, notes, and snippets.

Satwik Kansal satwikkansal

View GitHub Profile
@satwikkansal
satwikkansal / request_ranking.py
Last active Mar 22, 2016
Ranking of exploration request for oppia
View request_ranking.py
from datetime import datetime, timedelta
from math import log
epoch = datetime(1970, 1, 1)
def epoch_seconds(date):
td = date - epoch
return td.days * 86400 + td.seconds + (float(td.microseconds) / 1000000)
@satwikkansal
satwikkansal / scrape.py
Last active Jun 18, 2016
Fetching the content
View scrape.py
import requests
response = requests.get('https://in.pycon.org/cfp/2016/proposals/')
if response.status_code == 200:
print "Fetched the page sucessfully"
print response.content
@satwikkansal
satwikkansal / scrape.py
Created Jun 27, 2016
Scraping top Stackoverflow posts using Scrapy
View scrape.py
import scrapy
class Stackoverflowspider(scrapy.spider):
name = 'stackoverflow'
start_urls = ['http://stackoverflow.com/questions?sort=votes']
def parse(self, response):
for href in response.css('.question-summary h3 a::attr(href)'):
full_url = response.urljoin(href.extract())
yield scrapy.Request(full_url, callback=self.parse_question)
def parse_question(self, response):
yield {
View dicey_clock.py
import time
import random
import datetime
import telepot
"""
After **inserting token** in the source code, run it:
```
$ python2.7 diceyclock.py
```
View Simple Cricket API script
#importing the python requests library
import requests
def get_scores():
url = "https://cricscore-api.appspot.com/csa"
#Creatin a GET request
response = requests.get(url)
@satwikkansal
satwikkansal / quotefancy.py
Created May 3, 2017
Quotefancy wallpapers scraper
View quotefancy.py
import shutil
import os
import requests
from bs4 import BeautifulSoup
# USAGE: Add all the galleries that you want to be scraped in the list below
roots = ["https://quotefancy.com/motivational-quotes",
"https://quotefancy.com/inspirational-entrepreneurship-quotes",
"https://quotefancy.com/startup-quotes"]
@satwikkansal
satwikkansal / cheatsheet.cpp
Last active Apr 13, 2019
C++ STL cheatsheet for competitive progrmming
View cheatsheet.cpp
/*
This a header file that includes every standard library.
You can use it to save time.
NOTE: This header file may not be recognized by compilers
other than gcc.
*/
#include <bits/stdc++.h>
/*
//Use this if the above header file doesn't work.
@satwikkansal
satwikkansal / README.md
Last active Aug 11, 2017
Github README.rst and README.md styles
View README.md
@satwikkansal
satwikkansal / REPORT.md
Last active Mar 29, 2019
Work Report for Google Summer Of Code 2017
View REPORT.md
Orgainization [coala]
Project name Enhance coala-quickstart
Primary repository [coala-quickstart]
Project Mentors Adhityaa, Zatreanu Adrian-Gabriel
Project Page [Summer of Code Project Page]
Status Completed

Project Abstract

@satwikkansal
satwikkansal / oss_2k18.md
Last active Jun 22, 2018
GSoC Discussion (intermediate)
View oss_2k18.md
You can’t perform that action at this time.