Skip to content

Instantly share code, notes, and snippets.

View eledroos's full-sized avatar

nasser eledroos

View GitHub Profile
@eledroos
eledroos / PDFtoText.py
Last active May 11, 2017 17:55
I had a folder hundreds of emails in the form of PDFs, and I needed to be able to parse them. So, the goal in this gist is to convert all of the PDFs into text files which I could then parse using Regex into a CSV file.
from cStringIO import StringIO
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
import os
import sys, getopt
def convert(fname, pages=None):
if not pages:
@eledroos
eledroos / civicInfoScript.py
Created July 10, 2017 20:39
A script to take a list of addresses from NationBuilder and find their State Senator and Representative using the Google Civic API.
import pandas as pd
import json, requests, logging, pprint
# Setup logging
lfh = logging.FileHandler('civicInfoScript.log')
lfh.setFormatter(logging.Formatter('%(levelname)s %(asctime)s %(message)s'))
log = logging.getLogger('civicInfoScript')
log.setLevel(logging.INFO)
log.addHandler(lfh)

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@eledroos
eledroos / police.js
Created October 3, 2017 16:04
Test Visualization
// set the dimensions and margins of the graph
var margin = {top: 20, right: 20, bottom: 30, left: 50},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
// parse the date / time
var parseTime = d3.timeParse("%d-%b-%y");
// set the ranges
var x = d3.scaleTime().range([0, width]);
@eledroos
eledroos / TrumpTweetAnalysis.py
Created May 11, 2017 17:58
Using TextBlob, return, clean and analyze @RealDonaldTrump's tweets from a particular date range. Needs config.py.
import re
import tweepy
import config
import sys
import datetime
import csv
from tweepy import OAuthHandler
from textblob import TextBlob
class TwitterClient(object):
Title: Total Surveillance Is Not What America Signed Up For
Author: The Editorial Board, The New York Times.
It is a federal crime to open a piece of junk mail that’s addressed to someone else. Listening to someone else’s phone call without a court order can also be a federal crime.
The Supreme Court has ruled that the location data served up by mobile phones is also covered by constitutional protections. The government can’t request it without a warrant.
But the private sector doesn’t need a warrant to get hold of your data. There’s little to prevent companies from tracking the precise movements of hundreds of millions of Americans and selling copies of that dataset to anyone who can pay the price.
The incongruity between the robust legal regime around legacy methods of privacy invasion and the paucity of regulation around more comprehensive and intrusive modern technologies has come into sharp relief in an investigation into the location data industry by Times Opinion. The investigation, which builds on