This file contains hidden or 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 as pd | |
import matplotlib.pyplot as plt | |
dataset = '/home/cullenrhodes/Downloads/as-and-a-level-mathematics-data-set.xls' | |
# Build DataFrame containing Heathrow 1987 data. | |
# Header starts at row 6 (substract 1 for 0-based indexing). | |
df_heathrow_1987 = pd.read_excel( | |
dataset, sheetname='Heathrow May-Oct 1987', header=5, index_col='Date' | |
) | |
# Build DataFrame containing Heathrow 2015 data. |
This file contains hidden or 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 django | |
django.setup() | |
import factory.base | |
import inspect | |
import importlib | |
factory_pre_imports = [] | |
for app_name in LOCAL_APPS: | |
module_name = '{}.{}'.format(app_name, 'factories') | |
try: | |
module = importlib.import_module(module_name) |
This file contains hidden or 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 itertools import izip_longest | |
def grouper(n, iterable, fillvalue=None): | |
"grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx" | |
args = [iter(iterable)] * n | |
return izip_longest(fillvalue=fillvalue, *args) | |
def exp_treesize(data): | |
data = data.split('\n') |
This file contains hidden or 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 rest_framework import renderers | |
class PlainTextRenderer(renderers.BaseRenderer): | |
media_type = 'text/plain' | |
format = 'text' | |
def render(self, data, media_type=None, renderer_context=None): | |
return str(renderers.JSONRenderer().render(data, media_type, renderer_context)).encode(self.charset) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
# settings.py | |
class DisableMigrations(object): | |
def __contains__(self, item): | |
return True | |
def __getitem__(self, item): | |
return "notmigrations" |
This file contains hidden or 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
""" | |
Reddit DailyProgrammer Challenge #190 - Webscraping Sentiments. | |
http://bit.ly/11sBRa0 | |
""" | |
import requests | |
from bs4 import BeautifulSoup | |
comments_url = 'http://www.youtube.com/all_comments?v={video_id}' | |
happy = ['love','loved','like','liked','awesome','amazing','good','great','excellent'] |
This file contains hidden or 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
# Demonstration of a time of check to time of use (toutou) race condition | |
import os | |
import time | |
from threading import Thread | |
class ReadFileThread(Thread): | |
def __init__(self, file_name): |
This file contains hidden or 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 | |
# shape (3, 3, 3, 3) | |
l = np.array(range(81)).reshape((3, 3, 3, 3)) | |
for w in range(3): | |
for x in range(3): | |
for y in range(3): | |
for z in range(3): | |
print(l[w][y][x][z], end=" ") |