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 dev_appserver | |
| dev_appserver.fix_sys_path() | |
| def get_auth(): | |
| import getpass | |
| return raw_input('Username:'), getpass.getpass('Password:') | |
| def connect(app_id): | |
| from google.appengine.ext.remote_api import remote_api_stub |
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 lxml.html import parse | |
| from lxml import etree | |
| import cStringIO | |
| def remove_tags(html, strip_tags = ["script"]): | |
| b = cStringIO.StringIO(html) | |
| root = parse(b).getroot() | |
| for tag in strip_tags: | |
| for element in root.iter(tag): | |
| element.drop_tree() |
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 re | |
| re_pure_text = re.compile(ur'[\u4e00-\u9fff\w]+', re.UNICODE) |
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
| #!/usr/bin/env python | |
| # | |
| # Copyright 2010 Facebook | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may | |
| # not use this file except in compliance with the License. You may obtain | |
| # a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # |
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
| SELECT * FROM ProductAd where __key__ = Key('ProductAd', 'yahoo:product:2265602') |
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
| <iframe frameBorder="0" scrolling="no" width="300" height="250" marginwidth="0" marginheight="0" style="display: visible" src="http://ad.tagtoo.co/ad_g_300x250?pb=66&id=4#q=http%3A%2F%2Fwww.mayuki.com.tw%2F&p=%%SITE%%&cachebuster=%%CACHEBUSTER%%&click=%%CLICK_URL_ESC%%"></iframe> |
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 sys | |
| def extract_jpg(ifilepath): | |
| ofile = 'test.jpg' | |
| with open(ifilepath, 'rb') as ifile: | |
| icontent = ifile.read() | |
| index = icontent.index("</panorama>") + len("</panorama>") | |
| # print index | |
| icontent = icontent[index:] |
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 random | |
| x = ['x', 2] | |
| y = ['y', 3] | |
| z = ['z', 4] | |
| SAMPLES = 100000 | |
| choices = [x,y,z] | |
| total_weight = float(sum([k[1] for k in choices])) | |
| vs = [] |
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 random | |
| SAMPLES = 10000 | |
| NUM = 5 | |
| options = [(k, random.randint(0, 100)) for k in range(NUM)] | |
| choices = list(options) | |
| total_weight = float(sum([k[1] for k in choices])) | |
| vs = [] | |
| for i in range(SAMPLES): |
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 FileSplitPipe(base_handler.PipelineBase): | |
| def run(self, input_path, output, shards): | |
| # from google.appengine.api import files | |
| # from cStringIO import StringIO | |
| import time | |
| import logging | |
| def readline(_file): | |
| # TODO: Need to fix it |
OlderNewer