Skip to content

Instantly share code, notes, and snippets.

View robert-field's full-sized avatar

Robert Field robert-field

View GitHub Profile
@robert-field
robert-field / product_gen.js
Created May 10, 2022 16:07
Generate a product of iterables in Javascript
// This is modelled on the example for the
// Python itertools.product example.
//
// It creates the entire product vector
// before yielding. This is acceptable
// for the use case it serves, with
// a smallish number of smallish iterables
// to create.
function *product_gen(vec) {
let result = [[]];
@robert-field
robert-field / control_never_cache.py
Last active May 7, 2022 12:03
Control operation of Django never_cache decorator
def control_caching(func):
"""This can control whether Django's never_cache is active.
It can be used as a decorator. For example
@control_never_cache
def some_view(request):
# The code for some_view here
"""