View ip.py
"""
Convert between various representations of an IPv4 address.
`ip` refers to a dotted string, like: `'127.0.0.1'`.
`octets` are indexables, like `(127, 0, 0, 1)`.
`int` is the integer representation, like `2130706433`.
Written for Python 2.7.
"""
View block-grid.less
// # Block Grid
//
// Technique adapted from Foundation 5 for Bootstrap 3.0.3 to at least 3.3.1.
// https://github.com/zurb/foundation/blob/f755d8704123f86c281ede0b171881e2672f150d/scss/foundation/components/_block-grid.scss
//
// # Example Usage
//
// To produce a grid of 2 items per row on an extra-small screen, and 3 items
// per row on a small screen:
//
View throttle.py
class throttle(object):
"""
Decorator that prevents a function from being called more than once every
time period.
To create a function that cannot be called more than once a minute:
@throttle(minutes=1)
def my_fun():
pass
View gist:89b40995409318e3c52c
/* Return a delta object whose days, hours, minutes, seconds property add up to
* the amount of time between timeA and timeB. Assumes A happens before B. */
var duration = function (timeA, timeB) {
var msPer = // milliseconds per various times
{ second: 1000
, minute: 1000 * 60
, hour: 1000 * 60 * 60
, day: 1000 * 60 * 60 * 24
};
var delta = {};
View cartesian-product.js
/* N-ary cartesian product.
* Input: any number of lists
* Output: the cartesian product of the above lists as list of lists
* Example: cartesianProduct([1, 2], ['cat']) -> [ [1, 'cat'], [2, 'cat'] ]
*/
var cartesianProduct = function () {
function addNextList (tuples, list) {
var result = [];
tuples.forEach(function (tuple) {
list.forEach(function (item) {