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
def list_splice(target, start, delete_count=None, *items): | |
"""Remove existing elements and/or add new elements to a list. | |
target the target list (will be changed) | |
start index of starting position | |
delete_count number of items to remove (default: len(target) - start) | |
*items items to insert at start index | |
Returns a new list of removed items (or an empty list) | |
""" |
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
# val = the value to pad | |
# length = the length of the padded string | |
# padChar = the character to use for padding. Defaults to '0' | |
pad = (val, length, padChar = '0') -> | |
val += '' | |
numPads = length - val.length | |
if (numPads > 0) then new Array(numPads + 1).join(padChar) + val else val |
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
/*jslint plusplus: true, vars: true, indent: 2 */ | |
/* | |
convertPointFromPageToNode(element, event.pageX, event.pageY) -> {x, y} | |
returns coordinate in element's local coordinate system (works properly with css transforms without perspective projection) | |
convertPointFromNodeToPage(element, offsetX, offsetY) -> {x, y} | |
returns coordinate in window's coordinate system (works properly with css transforms without perspective projection) | |
*/ |