Skip to content

Instantly share code, notes, and snippets.

View dmil's full-sized avatar

Dhrumil Mehta dmil

View GitHub Profile
@dmil
dmil / scraper_stub
Created March 28, 2015 19:56
Scraper Stub
"""
Stub for scraping-related jobs
CSS Selectors Reference: http://www.w3schools.com/cssref/css_selectors.asp
"""
import requests, lxml.html
# Grab HTML from page
response = requests.get('https://www.google.com/')
@dmil
dmil / scraper_stub
Created March 28, 2015 19:56
Scraper Stub
"""
Stub for scraping-related jobs
CSS Selectors Reference: http://www.w3schools.com/cssref/css_selectors.asp
"""
import requests, lxml.html
# Grab HTML from page
response = requests.get('https://www.google.com/')
@dmil
dmil / pdfscraper
Created March 28, 2015 20:28
Scrape PDFS
"""
Stub for scraping-related jobs
CSS Selectors Reference: http://www.w3schools.com/cssref/css_selectors.asp
"""
import requests, lxml.html
import re
# Select the element using a CSS Selector
from nameparser import HumanName
import codecs
import csv
# READ NAMES AND FORMAT PROPERLY
namefile = codecs.open('names.txt', encoding='utf-16')
names = {}
for name in namefile:
names[name.strip()] = str(HumanName(name.strip()))
namefile.close()
@dmil
dmil / api.py
Created September 12, 2015 04:28
"""
Stub for script to query API
"""
from urllib2 import Request, urlopen, URLError
import json
import logging
from time import sleep
URL_STUB = "http://website.com/api?q="
@dmil
dmil / mirror
Created February 9, 2016 05:46
<3 Hi, Goodmorning
#!/usr/bin/env ruby
#
# Ruby script to access wordpress.com REST API
# For usage, see main method at end of file.
require 'wordpress-com'
require 'json'
require 'logger'
@logger = Logger.new(STDOUT)
@dmil
dmil / google.R
Last active November 1, 2016 16:52
parse google polls
library(dplyr)
library(tidyr)
setwd('~/Downloads')
filename <- 'GS_Election_Poll_20161101'
df <- read.csv(paste(filename,".csv",sep=""))
grouped <- group_by(df, Question..2.Answer)
summary_df = summarise(grouped, total=sum(Weight))
summary_df_mutated <- mutate(summary_df, pct=total/sum(total))
[
{
"name" : "Molecule Man",
"age" : 29,
"secretIdentity" : "Dan Jukes",
"powers" : [
"Radiation resistance",
"Turning tiny",
"Radiation blast"
]
@dmil
dmil / junk
Created February 5, 2017 02:51
[
{
"name" : "Molecule Man",
"age" : 29,
"secretIdentity" : "Dan Jukes",
"powers" : [
"Radiation resistance",
"Turning tiny",
"Radiation blast"
]