This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
from glob import glob | |
from os import makedirs | |
from os.path import join | |
from urllib.parse import urljoin | |
import requests | |
FOX_HOME_URL = 'http://press.foxnews.com/press-archive/' | |
YEARS = ['2011', '2012', '2013', '2014', '2015', '2016', '2017'] | |
MONTHS = ['january', 'february', 'march', 'april', 'may', 'june', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
from glob import glob | |
from os import makedirs | |
from os.path import join | |
from urllib.parse import urljoin | |
import requests | |
CBS_HOME_URL = 'https://www.cbscorporation.com/' | |
YEARS = {'2009': '7', '2010': '4', '2011': '11', '2012': '9', | |
'2013': '9', '2014': '9', '2015': '4', '2016': '6', '2017': '5'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
@author: Faron | |
""" | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pylab as plt | |
from datetime import datetime | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img | |
datagen = ImageDataGenerator( | |
rotation_range=40, | |
width_shift_range=0.2, | |
height_shift_range=0.2, | |
shear_range=0.2, | |
zoom_range=0.2, | |
horizontal_flip=True, | |
fill_mode='nearest') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def one_hot_encode_object_array(arr): | |
'''One hot encode a numpy array of objects (e.g. strings)''' | |
uniques, ids = np.unique(arr, return_inverse=True) | |
return np_utils.to_categorical(ids, len(uniques)) | |
train_y_ohe = one_hot_encode_object_array(train_y) | |
test_y_ohe = one_hot_encode_object_array(test_y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def memoize(fn): | |
cache = {} | |
def wrapper(*args): | |
try: | |
return cache[args] | |
except: | |
result = fn(*args) | |
cache[args] = result | |
return result | |
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from http://jamescooke.info/arrange-act-assert-pattern-for-python-developers.html | |
# from x import * | |
def test_reverse(): | |
""" | |
list.reverse inverts the order of items in a list, in place | |
""" | |
greek = ['alpha', 'beta', 'gamma', 'delta'] | |
result = greek.reverse() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from https://unix.stackexchange.com/questions/90853/how-can-i-run-ssh-add-automatically-without-password-prompt | |
if [ ! -S ~/.ssh/ssh_auth_sock ]; then | |
eval `ssh-agent` | |
ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock | |
fi | |
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock | |
ssh-add -l > /dev/null || ssh-add |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
# from time import sleep | |
from creds import * | |
from random import randint | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_token, access_token_secret) | |
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True) | |
matches = ["Hello world!","Hello, world","Hello, World!","hello world"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
from time import sleep | |
from creds import * | |
from random import randint | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_token, access_token_secret) | |
api = tweepy.API(auth) | |
matches = ['Hello world', |