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
{ | |
"metadata": { | |
"name": "Trip Tables" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
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
{ | |
"metadata": { | |
"name": "RouterChecks" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
body{ | |
font-family: sans-serif; | |
} | |
#container { | |
width: 1000px; | |
margin: 50px auto; |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>MIT Wifi - Timeseries</title> | |
<link rel="stylesheet" href="styles.css"> | |
<style> |
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 requests | |
import shutil | |
import os | |
def download_images(url_filename, out_directory, max_urls=None): | |
"""Download images from a file containing URLS. | |
The URL file must contain a single URL per line. | |
Args: |
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
struct Debug { | |
struct Timer { | |
let start = DispatchTime.now().uptimeNanoseconds | |
func end() -> Double { | |
let end = DispatchTime.now().uptimeNanoseconds | |
let diff = Double(end — start) / 1_000_000_000 | |
return diff | |
} | |
} | |
} |
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 time_func(function, func_args=None, func_kwargs=None): | |
"""Time a single call of a function. | |
Args: | |
function (function): a function object to time | |
func_args (list, optional): the args for the function | |
func_kwargs (dict, optional): the kwargs for the function | |
Returns: | |
double: duration of the function call in sections | |
""" | |
args = func_args or [] |
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 pandas | |
import re | |
import json | |
# Use pandas and regex to clean up the post titles. | |
df = pandas.DataFrame(posts, columns=['subreddit', 'title']) | |
# Remove any [tag] markers in a post title | |
df.title = df.title.apply(lambda x: re.sub(r'\[.*\]', '', x)) | |
# Remove all other punctuation except spaces | |
df.title = df.title.apply(lambda x: re.sub(r'\W(?<![ ])', '', x)) |
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 requests | |
import json | |
def get_listing(subreddit, sort='top', after=None, limit=25): | |
# Set the user agent on the request so we don't get rate limited | |
headers = {'User-agent': 'Subreddit Title Bot'} | |
url_fmt = 'https://www.reddit.com/r/{subreddit}/{sort}.json' | |
url = url_fmt.format(subreddit=subreddit, sort=sort) | |
params = {'after': after, 'limit': limit, 't': 'year'} | |
response = requests.get(url, params=params, headers=headers) |
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
# Test the model on some titles I wrote with specific subreddits in mind. | |
sample_titles = [ | |
'Saw this good boy at the park today.', | |
'Latest NIPS submission from OpenAI', | |
'TIL you can use Core ML to suggest subreddits to users', | |
'I made a tutorial using CreateML AMA', | |
'Westworld and Game of Thrones coming to netflix', | |
'We park in driveways, but drive on parkways', | |
'From the top of Mt. Fuji, Japan', | |
"What's the first thing you do every morning?", |
OlderNewer