Skip to content

Instantly share code, notes, and snippets.

View manashmandal's full-sized avatar
👨‍💻
Probably Coding || ! Probably Coding

Manash Kumar Mandal manashmandal

👨‍💻
Probably Coding || ! Probably Coding
View GitHub Profile
@manashmandal
manashmandal / jupyter_scrapy.py
Created October 21, 2016 13:43
Scrapy in jupyter notebook
#http://stackoverflow.com/questions/26177620/how-to-execute-scrapy-shell-url-with-notebook
import requests
from scrapy.http import TextResponse
r = requests.get('http://stackoverflow.com/')
response = TextResponse(r.url, body=r.text, encoding='utf-8')
import pandas as pd
import geoip2.database
mmdb_path = 'C:\\Users\\Manash\\Downloads\\Compressed\\GeoLite2-Country.mmdb\\GeoLite2-Country.mmdb'
ipaddress_path = 'C:\\Users\\Manash\\Downloads\\IP_Address.csv'
ipdf = pd.read_csv(ipaddress_path)
reader = geoip2.database.Reader(mmdb_path)
for ip in ipdf['IP Address']:
@manashmandal
manashmandal / dtrump.py
Created October 12, 2016 09:36
Predictive analysis
status_updates = ['JOIN ME FOR A FEW MINUTES IN PANAMA CITY BEACH, FLORIDA. This is a MOVEMENT like never seen before- and will never be seen again. This is our last chance- lets MAKE AMERICA SAFE AND GREAT AGAIN!', 'I would like to wish everyone who is observing the solemn and holy day of Yom Kippur an inspirational day of reflection. We hope that everyone’s prayers are answered and that we all have a year of peace, security, good health, prosperity and blessings. -DJT', 'JOIN ME FOR A FEW MINUTES IN PANAMA CITY BEACH, FLORIDA. This is a MOVEMENT like never seen before- and will never be seen again. This is our last chance- lets MAKE AMERICA SAFE AND GREAT AGAIN!', 'I would like to wish everyone who is observing the solemn and holy day of Yom Kippur an inspirational day of reflection. We hope that everyone’s prayers are answered and that we all have a year of peace, security, good health, prosperity and blessings. -DJT', 'Great morning in San Antonio, Texas - GREAT afternoon in Dallas, Texas. Departing now
@manashmandal
manashmandal / wordcloud.py
Created October 12, 2016 09:23
Donald trump word cloud
# Dependencies:
# NLTK
# WordCloud
# Scikit-learn
# Matplotlib
# Scipy
# Python version: 2.7
%matplotlib inline
@manashmandal
manashmandal / dt_sentiment_plot.r
Created October 12, 2016 08:03
Plotting sentiment
install.packages('ggplot2')
require(ggplot2)
df <- data.frame(Sentiment = c('Positive', 'Negative'), Count = c(174, 115))
ggplot(df, aes(Sentiment, Count)) + geom_bar(stat="identity")
@manashmandal
manashmandal / facebook_profile_scraper.py
Last active October 12, 2016 15:38
Facebook Profile Scraper!
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
from requests import get
from lxml import html
class FacebookSpider():
def __init__(self, userid, password):
self.userid = userid
self.password = password
import pandas as pd
import os
import numpy as np
import random
from sklearn.utils import shuffle
import matplotlib.pyplot as plt
positive_text_path = './txt_sentoken/pos/'
negative_text_path = './txt_sentoken/neg/'
@manashmandal
manashmandal / stanfordnertagger.py
Created October 6, 2016 13:41
StanfordNERTagger for linux
import nltk
print nltk.__version__
from nltk.tag import StanfordNERTagger
import os
st = StanfordNERTagger(os.environ.get('STANFORD_MODELS'))
print st._stanford_jar
@manashmandal
manashmandal / stanford.py
Created October 6, 2016 13:38
StanfordNERTagger on linux
from nltk.tag import StanfordNERTagger
import os
print os.environ.get('STANFORD_MODELS')
# Output:
#/home/jackspicer/StanfordParser/stanford-ner-2015-12-09/classifiers/english.all.3class.distsim.crf.ser.gz:/home/jackspicer/stanford-postagger-2015-12-09/models/english.conll.4class.distsim.crf.ser.gz:/home/jackspicer/StanfordParser/stanford-ner-2015-12-09/english.muc.7class.distsim.crf.ser.gz
# I want to select the first classifier model
void setup(){
Serial.begin(9600);
Serial1.begin(9600);
Serial.println("Init");
pinMode(13, OUTPUT);
}
char b;
void loop(){