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 os | |
| CREDENTIALS = ['AWSAccessKeyId', 'AWSSecretKey'] | |
| def credentials(filename=None): | |
| """ | |
| Generally made for standard AWS export format. Turns conf file into python dict | |
| If no filename is given, will attempt to read environment variables instead, then global variables |
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
| @BotoSave('bucketname') | |
| def method(): | |
| return {<key>: <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 json | |
| from boto.s3.connection import S3Connection, OrdinaryCallingFormat | |
| from boto.s3.key import Key | |
| class BotoSave(object): | |
| def __init__(self, bucket, filename=None): | |
| """ |
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
| class MissingKeyException(Exception): | |
| """ | |
| If we can't figure out what the key is of an item being saved, we just say so. | |
| Should probably make a better error message that says what we can figure out and what they can do about it. | |
| """ | |
| def __init__(self, data_structure): | |
| self.ds = data_structure | |
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 requests | |
| import json | |
| import urllib | |
| URLS = { | |
| 'css': 'http://cssminifier.com/raw', | |
| 'js': 'http://javascript-minifier.com/raw' | |
| } | |
| def new_filepath(filepath): |
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
| def get_voter_links(outfile="voter_info.txt"): | |
| start_urls = ("http://usavoters.directory/complete.php?id=%s" % i for i in xrange(128555, 214545)) | |
| with open(outfile, 'a') as sink: | |
| for url in start_urls: | |
| document = etree.HTML(requests.get(url).content) | |
| link_selector = CSSSelector('tr>td>a') | |
| person_links = link_selector(document)[14:] | |
| sink.write('\n'.join(link.get('href') for link in person_links if link.get('href'))) | |
| print url |
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
| id title description google_product_category product_type price sale_price sale_price_effective_date link mobile_link image_link additional_image_link brand gtin mpn identifier_exists condition availability availability_date item_group_id color material pattern size size_type size_system gender age_group tax shipping shipping_weight shipping_label multipack is_bundle adult adwords_redirect adwords_grouping adwords_labels custom_label_0 custom_label_1 custom_label_2 custom_label_3 custom_label_4 excluded_destination expiration_date promotion_id display_ads_id display_ads_link display_ads_similar_id display_ads_title display_ads_value shipping_length shipping_width shipping_height | |
| sku152300450 Washable-Crepe Straight-Leg Pants, Petite, Size: PS (6/8), BLACK - Eileen Fisher Eileen Fisher Washable-Crepe Straight-Leg Pants, Petite Details From Eileen Fisher, bi-stretch crepe pants with elegant day-to-night texture and remarkable fit memory, great for travel. 29" approx. inseam. Regular rise; yoked waist contours t |
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
| {"http://images.neimanmarcus.com/product_assets/T/8/A/P/X/NMT8APX_mz.jpg": [0.0, 0.0, 0.7503045797348022, 0.0, 4.050353527069092, 0.0, 0.0, 3.970454454421997, 2.56343936920166, 0.0, 0.0, 0.0, 0.0, 0.8763924241065979, 2.9059646129608154, 1.7854936122894287, 0.0, 0.0, 0.0, 3.603835105895996, 0.0, 0.0, 0.0, 0.0, 2.9097509384155273, 0.6788361072540283, 0.0, 0.0, 0.0, 0.0, 0.9168252348899841, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.21072697639465332, 0.0, 2.585055112838745, 0.0, 0.18340826034545898, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.772193431854248, 0.0, 0.0, 0.0, 0.0, 1.1300804615020752, 0.0, 0.0, 0.0, 1.8126261234283447, 0.0, 0.0, 2.4351160526275635, 1.0090645551681519, 6.7620415687561035, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.6218217611312866, 0.0, 3.785642385482788, 0.0, 0.0, 0.0, 0.4094317555427551, 0.0, 1.046784520149231, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5131956338882446, 0.0, 2.341181516647339, 3.7282121181488037, 2.7647757530212402, 0.0, 0.0, 0.2037421613931656, 0.0, 0.0, 2.629900932 |
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 json | |
| from collections import OrderedDict | |
| import numpy as np | |
| from scipy.spatial.distance import cdist | |
| from indicoio.custom import vectorize | |
| from nouns import NOUNS | |
| FEATURES = json.load(open("features.json"), object_pairs_hook=OrderedDict) |
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
| def firstNonRepeated(s): | |
| return ([letter for i, letter in enumerate(s) if letter not in (s[:i] + s[i+1:])] + [""])[0] | |
| def first_non_repeated1(s): | |
| for i, letter in enumerate(s): | |
| if letter not in (s[:i] + s[i+1:]): | |
| return letter | |
| return "" | |
| def first_non_repeated1(s): |