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 | |
""" | |
Scan all folders in path and output a list of folder names and sizes sorted by descending size. | |
""" | |
import os | |
from os.path import join, getsize | |
from collections import defaultdict | |
import argparse |
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
"""Example pulled from pandas docs for highlights | |
the highest number in each columns to illustrate the | |
experimental DataFrame.style api. | |
""" | |
import pandas as pd | |
df = pd.DataFrame.from_dict({'Medications': {'By Alphabetical': 7.7914173413117429e-05, | |
'By Diagnosis': 0.12608248612763967, | |
'By Occurrences': 0.024339338681789544}, |
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 threading import Thread | |
from Queue import Queue | |
import requests | |
def worker(): | |
while True: | |
url = input_q.get() # grab a task (a url to scrape) from the input_q | |
res = requests.get(url) | |
output_q.put((url, res.content)) # save just the content or the entire response object to process later | |
input_q.task_done() # Tells the input_q that the task we grabbed above (the url) has been processed |
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
''' | |
This file demostrates how to prevent a generator from being fully comsumed by | |
multiprocessing. It avoids using multiprocessing.map() in favor of a single | |
queue with a max size from which processes pull elements to work on. As elements | |
are being processed, a loop fills the queue will elements from the generator | |
until it reaches its max size, at which point it blocks until elements are | |
retrieved from the queue by the processes. | |
''' | |
from multiprocessing import Process, JoinableQueue | |
import os |
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
echo "test script" > test.txt |
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 send_mail(msg, to_add, from_add=from_add, | |
smts_server=('smtp.gmail.com', 587), | |
login=(email, password), | |
subj=None, | |
header=True): | |
"""Function to consolidate sending a single email. to_add can be a list.""" | |
if header: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.