Skip to content

Instantly share code, notes, and snippets.

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "tag_table" {
let controller = segue.destinationViewController as! BudgetTagsTableViewController
//-- Pass in what we have as the selected tags
controller.selectedTagIDs = self.selectedTagIDs
//-- Closure to receive the selection list and create our tags_string
controller.onCloseSelectedTags = { [unowned self] tags in
self.selectedTagIDs = Set( tags.map { (tag) -> Int in tag.id } )
struct SelectedTagDetail {
var id: Int = 0
var name: String = ""
}
typealias SelectedTagsClosure = (tags: [SelectedTagDetail]) -> Void
class BudgetTagsTableViewController: UITableViewController, BNDTableViewProxyDataSource {
// ...
var selectedTagIDs = Set<Int>()
@curtisforrester
curtisforrester / fizzbuzz_sets.py
Created May 19, 2016 16:07
Python FizzBuzz with lookup sets
import cProfile
import pstats
import StringIO
pr = cProfile.Profile()
pr.enable()
threes = {num for num in range(3, 100, 3)}
fives = {num for num in range(5, 100, 5)}
not_in = {num for num in range(1, 100) if num not in threes and num not in fives}
@curtisforrester
curtisforrester / fizzbuzz_modulo.py
Created May 19, 2016 16:09
Python FizzBuzz with modulo comparisons
import cProfile
import pstats
import StringIO
pr = cProfile.Profile()
pr.enable()
iNot = set()
iFizz = set()
iBuzz = set()
@curtisforrester
curtisforrester / print_args.py
Last active June 16, 2016 12:04
Python decorator to print function arguments
from functools import wraps
def print_args():
def decorator(func):
@wraps(func)
def func_wrapper(*args, **kwargs):
print('args: [%r], kwargs: [%r]' % (args, kwargs))
return func(*args, **kwargs)
return func_wrapper
return decorator
@curtisforrester
curtisforrester / bp.py
Created March 24, 2020 12:21
A route to list routes
@bp.route('/routes', methods=['GET'])
def get_routes():
"""
A route to show registered routes.
:return:
"""
rules = []
for rule in current_app.url_map.iter_rules():
methods = ','.join(sorted(rule.methods))