Skip to content

Instantly share code, notes, and snippets.

👀
Uh-oh, something went wrong! Recalibrating...

Satwik Kansal satwikkansal

👀
Uh-oh, something went wrong! Recalibrating...
Block or report user

Report or block satwikkansal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
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
```
@satwikkansal
satwikkansal / README.md
Last active Aug 11, 2017
Github README.rst and README.md styles
View README.md
@satwikkansal
satwikkansal / snippet.cs
Created May 2, 2018
Creating persistent menu and get started button in C# (useful for ASP.net)
View snippet.cs
// Snippet for persistent menu
var client = new RestClient("https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "2f9a47e2-2a8a-0a70-c4ce-cb72dbfd8e93");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"setting_type\" : \"call_to_actions\",\n \"thread_state\" : \"existing_thread\",\n \"call_to_actions\":[\n {\n \"type\":\"postback\",\n \"title\":\"Help\",\n \"payload\":\"DEVELOPER_DEFINED_PAYLOAD_FOR_HELP\"\n },\n {\n \"type\":\"postback\",\n \"title\":\"Start a New Order\",\n \"payload\":\"DEVELOPER_DEFINED_PAYLOAD_FOR_START_ORDER\"\n },\n {\n \"type\":\"web_url\",\n \"title\":\"View Website\",\n \"url\":\"http://petersapparel.parseapp.com/\"\n }\n ]\n }", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
@satwikkansal
satwikkansal / gan.py
Created Jun 19, 2018
Generative Adversarial Network implementation in Tensorflow for MNIST dataset: Generating handwritten digits using GANs
View gan.py
import tensorflow as tf
from PIL import Image
import numpy as np
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
model_dir = './model/'
model_name = 'gan_mnist'
@satwikkansal
satwikkansal / oss_2k18.md
Last active Jun 22, 2018
GSoC Discussion (intermediate)
View oss_2k18.md
@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"]
You can’t perform that action at this time.