Skip to content

Instantly share code, notes, and snippets.

View dmitrykuznetsovdev's full-sized avatar
🌴
On vacation

Dmitry dmitrykuznetsovdev

🌴
On vacation
View GitHub Profile
const userCollection = [
{
name: 'Дмитрий',
age: 35
},
{
name: 'Сергей',
age: 30
}
]
@dmitrykuznetsovdev
dmitrykuznetsovdev / callstack.js
Created December 5, 2016 15:08
callstack block
/**
* поставит в очередь Callback Queue стразу
*/
setTimeout(() => {
console.log('setTimeout', 1);
}, 0)
setTimeout(() => {
console.log('setTimeout', 2);
}, 0)
@dmitrykuznetsovdev
dmitrykuznetsovdev / cycle.js
Last active December 1, 2016 10:45
Create loop
var aList = ['A','B','C','D','E'];
/**
*
* @param {Array} arr
* @return {Generator}
*/
function* cycle(arr) {
const arr = [...arr];
let i = 0;
@dmitrykuznetsovdev
dmitrykuznetsovdev / max-min-avg.js
Last active December 1, 2016 10:41
Calculate the Max/Min/Avg value from an array
let collection = [1, 2, 3, 4, 5, 6, null, undefined, 7, 8, 9, 10];
collection = collection.filter(a => !!a);
let max = (prev, current)=> {
return prev > current ? prev : current;
}
let min = (prev, current)=> {
return prev < current ? prev : current;
}
@dmitrykuznetsovdev
dmitrykuznetsovdev / template.js
Last active December 1, 2016 10:42
Find and replace in template
/**
*
* @param data
* @returns {string}
*/
let myTemplate = function(data){
let text = `
If you are {full_name} a value (and not a regular expression),
only the first {name} of the value will be replaced.
To replace all occurrences of a specified value, use the global (g) modifier (see "More Examples" below).
if (!Function.prototype.bind) {
Function.prototype.bind = function(oThis) {
if (typeof this !== 'function') {
// ближайший аналог внутренней функции
// IsCallable в ECMAScript 5
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
const polindrom = 'Я не !! , !!!стар, брат Сеня';
let polindromPrepare = '';
let comparePolindrom = '';
function compose(...funcs) {
return [].reduceRight.bind(funcs, (prev, func) => func(prev));
}
@dmitrykuznetsovdev
dmitrykuznetsovdev / _mixins.styl
Created February 25, 2013 07:44
mixins.stylus
// Display:
// appearance
// box-align
// box-flex
// box-sizing
// box-orient
// box-pack
// display-box
// overflow-sroll
// user-select