Skip to content

Instantly share code, notes, and snippets.

View nikhilkumarsingh's full-sized avatar
🎯
Focusing

Nikhil Kumar Singh nikhilkumarsingh

🎯
Focusing
View GitHub Profile
@nikhilkumarsingh
nikhilkumarsingh / app.py
Created March 16, 2017 11:24
Facebook Messenger Bot tutorial series | A basic echo bot | app.py
import os, sys
from flask import Flask, request
from pymessenger import Bot
app = Flask(__name__)
PAGE_ACCESS_TOKEN = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
bot = Bot(PAGE_ACCESS_TOKEN)
@nikhilkumarsingh
nikhilkumarsingh / utils.py
Created April 17, 2017 06:31
Demo python script to interact with Wit.ai app using a Python Client
from wit import Wit
access_token = "server_access_token_here"
client = Wit(access_token = access_token)
message_text = "i live in Australia"
resp = client.message(message_text)
print(resp)
@nikhilkumarsingh
nikhilkumarsingh / google_tts.py
Created April 30, 2017 12:56
Googl text to speech API demo
import requests
API_ENDPOINT = "https://translate.google.com/translate_tts"
headers = {'User-Agent': "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"}
text = "good morning"
params = {
@nikhilkumarsingh
nikhilkumarsingh / file_downloader.py
Last active June 24, 2024 12:15
A file downloader with progress bar for terminal
from tqdm import tqdm
import requests
chunk_size = 1024
url = "http://www.nervenet.org/pdf/python3handson.pdf"
r = requests.get(url, stream = True)
total_size = int(r.headers['content-length'])
import requests
API_ENDPOINT = "https://www.wikidata.org/w/api.php"
query = "covfefe"
params = {
'action': 'wbsearchentities',
'format': 'json',
'language': 'en',
import requests
from bs4 import BeautifulSoup
url = "http://www.hindustantimes.com/rss/topnews/rssfeed.xml"
resp = requests.get(url)
soup = BeautifulSoup(resp.content, features="xml")
items = soup.findAll('item')
@nikhilkumarsingh
nikhilkumarsingh / softmax-regression.py
Created August 6, 2017 06:18
Softmax regression implementation on MNSIT data using tensorflow
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
# loading data
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
# number of features
num_features = 784
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nikhilkumarsingh
nikhilkumarsingh / mywc.py
Created September 10, 2017 06:23
Wordcloud of wikipedia articles
from os import path
import numpy as np
from PIL import Image
import wikipedia
from wordcloud import WordCloud, STOPWORDS
# get path to script's directory
currdir = path.dirname(__file__)
def get_wiki(query):
@nikhilkumarsingh
nikhilkumarsingh / android_cam.py
Created October 30, 2017 08:26
Processing a live video stream from android phone to PC using Python.
import requests
import cv2
import numpy as np
url = "http://192.168.43.1:8080/shot.jpg"
while True:
img_resp = requests.get(url)