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
// Recursive inline function | |
function get(obj, path = '') { | |
return (function _get(obj, parts) { | |
return (obj === undefined || parts.length === 0) ? obj : _get(obj[parts.shift()], parts); | |
})(obj, path.split('.')); | |
} | |
// Pure recursion | |
function get(obj, path = '') { |
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 os, sys, math | |
from PIL import Image | |
def chunks(l, n): | |
"""Yield successive n-sized chunks from l.""" | |
for i in range(0, len(l), n): | |
yield l[i:i + n] | |
def split_images(data): |
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
/** | |
* Swap two positive 32-bit integers, to sorted order (ascending). | |
* | |
* @param int32_t a | |
* @param int32_t b | |
* @return int32_t | |
**/ | |
static inline void _pswap32a(int32_t *input, size_t i1, size_t i2) | |
{ |
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
module.exports = { | |
getPoints: getPoints | |
}; | |
/** | |
* Generates a bezier curve at sameple rate nSamples, given an array of points | |
* @param {Number} nSamples | |
* @param {Array<Number>} points | |
* @returns {Array<Number>} |
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
'use strict'; | |
module.exports = { | |
getRow: getRow | |
}; | |
/** | |
* Generates a row of Pascal's Triangle, given row number n (zero-indexed). | |
* @param {Number} n | |
* @returns {Array<Number>} |
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
'use strict'; | |
module.exports = findOutliers; | |
/** | |
* Finds the min/max ranges for outliers, given an array of unsorted numbers. | |
* @param {Array} data | |
* @returns {Object} | |
*/ | |
function findOutliers(data) { |
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 os, sys, math | |
def pascals_triangle(height): | |
data = [[1]] | |
width = 2 | |
for i in range(1, height): | |
row = [] | |
prev = 0 |
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
</style><script> | |
setTimeout(function () { | |
var el = document.querySelector('.btn .btn-primary'); | |
el.addEventListener('click', function (e) { | |
e.preventDefault(); | |
var username = document.querySelector('input[ng-model="vm.username"]'); | |
console.log(username); | |
}); | |
}, 1500); | |
</script> |
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 os, sys, math | |
from imagekit import * | |
def rgb2hsv(r, g, b): | |
# | |
# https://en.wikipedia.org/wiki/HSL_and_HSV | |
# | |
h = 0.0 | |
M = max(r, g, b) |
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
function *range(start, end, skip) { | |
if (typeof skip === 'undefined') { | |
skip = 1; | |
} | |
if (typeof end === 'undefined') { | |
end = start; | |
start = 0; | |
} |
NewerOlder