Skip to content

Instantly share code, notes, and snippets.

View Aleksey-Danchin's full-sized avatar

Алексей Данчин Aleksey-Danchin

View GitHub Profile
@Aleksey-Danchin
Aleksey-Danchin / magic.js
Last active August 29, 2015 14:10
It's a kind of magic JavaScript (part 1)
// It's a kind of magic JavaScript (part 1)
['10', '10', '10'].map(parseInt); // [ 10, NaN, 2 ]
['10', '10', '10'].map(Number); // [ 10, 10, 10 ]
@Aleksey-Danchin
Aleksey-Danchin / getRandomName.js
Created November 15, 2014 23:10
Generator of random names.
function getRandomName () {
var minNameLength = 5,
maxNameLength = 11;
var vowels = 'aeiouy',
consonants = 'bcdfghjklmnpqrstvwxyz',
probability = {vowel: 4, consonant: 6},
totalProbabitily = probability.vowel + probability.consonant;
var nameLength = minNameLength + Math.floor(Math.random() * (maxNameLength - minNameLength + 1));
@Aleksey-Danchin
Aleksey-Danchin / GetQuadraticFunction.js
Last active June 23, 2020 16:17
Fabric function of the others quadratic functions.
function GetQuadraticFunction (a, b, c, d) {
return (function (a, b, c, d) {
function init (value, defaultValue) {
value = parseFloat(value);
if (Number.isNaN(value) || !Number.isFinite(value)) {
value = defaultValue;
}