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
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| ) | |
| func BatchStrings(values <-chan string, maxItems int, maxTimeout time.Duration) chan []string { | |
| batches := make(chan []string) |
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
| { | |
| "foo": "bar", | |
| "baz": 123 | |
| } |
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 | |
| import sys | |
| import operator | |
| def generic_sql(sql): | |
| sql = re.sub(r"'.*?'", "?", sql, 0, re.DOTALL) | |
| sql = re.sub(r'".*?"', "?", sql, 0, re.DOTALL) | |
| sql = re.sub(r"`(.*?)`", '\\1', sql, 0, re.DOTALL) | |
| sql = re.sub(r"\d[\d\.]*", "?", sql, 0, re.DOTALL) | |
| sql = re.sub(r"\(\?(,\s*\?\)*)*", "?", sql, 0, re.DOTALL) |
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
| # -*- coding: utf8 -*- | |
| from __future__ import print_function | |
| class LockManager: | |
| def __init__(self): | |
| self.locks = [] | |
| def add(self, transaction, record_id): | |
| if not self.exists(transaction, record_id): |
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 XCTest | |
| import HealthKit | |
| @testable import Stepology | |
| class StepUnitFormatterTests: XCTestCase { | |
| //> (0, "0 steps") | |
| //> (1, "1 step") | |
| //> (2, "2 steps") | |
| //> (999, "999 steps") | |
| //> (1000, "1,000 steps") |
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 | |
| import re | |
| import glob | |
| import os | |
| files = [] | |
| for arg in sys.argv[1:]: | |
| if os.path.isdir(arg): | |
| arg += "/*.swift" |
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 | |
| import re | |
| import glob | |
| import os | |
| files = [] | |
| for arg in sys.argv[1:]: | |
| if os.path.isdir(arg): | |
| arg += "/*.swift" |
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 | |
| def to_camel_case(text): | |
| return re.sub('[_-](.)', lambda x: x.group(1).upper(), text) |
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 pluralize(n, word): | |
| if n == 1: | |
| return '%d %s' % (n, word) | |
| return '%d %ss' % (n, word) | |
| def format_duration(seconds): | |
| if seconds == 0: | |
| return "now" | |
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 format_duration(seconds): | |
| return "now" |