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 'package:w_common/func.dart'; | |
/// Provides a way to signal that an operation has been canceled. | |
/// | |
/// Typically, the consumer creates a [CancellationTokenSource] and then passes | |
/// the [token] to another operation. The consumer can then call [cancel], | |
/// while the operation can only check if it has been canceled. | |
/// | |
/// FUTURE: If we want a stream to listen for when a cancellation has happened, | |
/// use CancelableCompleter from the async package instead. |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
import argparse | |
import sys | |
import re | |
import yaml # PyYAML |
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
------------------------------------------------------------------------- | |
USEFUL ONE-LINE SCRIPTS FOR SED (Unix stream editor) Dec. 29, 2005 | |
Compiled by Eric Pement - pemente[at]northpark[dot]edu version 5.5 | |
Latest version of this file (in English) is usually at: | |
http://sed.sourceforge.net/sed1line.txt | |
http://www.pement.org/sed/sed1line.txt | |
This file will also available in other languages: | |
Chinese - http://sed.sourceforge.net/sed1line_zh-CN.html |
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 logging | |
# MAGIC-NUMBER: max length is just some guess at a reasonable size, e.g. 80 cols by 500 lines | |
def dump(value, msg='DUMP', max_length=80 * 500, stdout=False, pick=(), skip=(), | |
loglevel=logging.DEBUG): | |
""" | |
Write as verbose of a description of the value as possible to logging.DEBUG. | |
See http://stackoverflow.com/q/27830888/116891 | |
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 glob | |
import inspect | |
import os | |
import re | |
import unittest | |
# http://superuser.com/a/748264/43406. NOTE ^ in front for negation | |
_unsafe_filename_regex = re.compile('([^\[\]\.0-9a-zA-Z-,;_])') | |
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 https://betamax.readthedocs.org/en/latest/cassettes.html | |
python -m json.tool cassette.json |
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
# Taken from http://ae-book.appspot.com/static/pgae-ndb-20121009.pdf | |
# Video at https://www.youtube.com/watch?v=xZsxWn58pS0#t=3383 | |
## Automatic Caching | |
# • Two automatic caching features | |
# • “In-context” cache | |
# • Memcache storage | |
# • Same basic idea, difference in scope | |
# • Context cache starts empty for each request | |
# • Minimizes datastore interactions throughout the request handler code |
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
# Taken from http://ae-book.appspot.com/static/pgae-ndb-20121009.pdf | |
# Video at https://www.youtube.com/watch?v=xZsxWn58pS0#t=3184 | |
## Cursors | |
# • Fetch results using an iterator, with cursors enabled: | |
it = query.iter(produce_cursors=True) | |
for result in it: # ... | |
# • Test whether there’s another result: | |
if it.has_next(): # ... | |
if it.probably_has_next(): # ... |
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
# Taken from http://ae-book.appspot.com/static/pgae-ndb-20121009.pdf | |
# Video at https://www.youtube.com/watch?v=xZsxWn58pS0#t=2970 | |
query = Player.query() | |
results = query.fetch(20, | |
projection=[Player.name, Player.level]) | |
for player in results: | |
# player.name ... | |
# (player.score not set) | |
# Projected property values are pulled directly from |
NewerOlder