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
// Number 1 | |
var funcs = []; | |
for (var i=0;i<10;i++) { | |
funcs.push(function() { | |
console.log(i); | |
}); | |
} | |
funcs.forEach(function(func) { |
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
const addChange = function (obj) { | |
obj.change = function (callback) { | |
if (callback) { | |
if ( !this._change ) this._change = []; | |
this._change.push(callback); | |
} else { | |
if ( !this._change ) return; | |
for (let i=0; i < this._change.length; i++) { | |
// apply callback to this object | |
this._change[i].apply(this); |
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
const Model = { | |
inherited: function() {}, | |
created: function() {}, | |
prototype: { | |
init: function() {}, | |
}, | |
create: function() { | |
let object = Object.create(this); |
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
//events - a super-basic Javascript (publish subscribe) pattern | |
var events = { | |
events: {}, | |
on: function (eventName, fn) { | |
this.events[eventName] = this.events[eventName] || []; | |
this.events[eventName].push(fn); | |
}, | |
off: function(eventName, fn) { | |
if (this.events[eventName]) { |
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
backup |
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 factorial(n) { | |
factorial.cache = factorial.cache || [1] | |
return factorial.cache[n] || (factorial.cache[n] = n * factorial(n - 1)) | |
} |
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 { connect } from 'react-redux'; | |
import compose from 'recompose/compose'; | |
import withState from 'recompose/withState'; | |
import withHandlers from 'recompose/withHandlers'; | |
import lifecycle from 'recompose/lifecycle'; | |
import { renderMonth, schoolyearsFilter, renderLessons } from './helpers'; | |
export default compose( |
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
'.source.js': | |
'then': | |
'prefix': '.then' | |
'body': """.then(response => console.log(response)) | |
.catch(reject => console.log(reject)) | |
""" | |
'comments': | |
'prefix': '/-' | |
'body': """// ========================================================================= | |
// ${1} |
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
const array = [1,2,3,4,5] | |
const reduce = function(arr, callback) { | |
let array = arr.slice(); | |
let result = null; | |
for(let i=0; i<array.length; i++) { | |
result = callback(result, arr[i], i, arr); | |
} | |
return result | |
} |
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
var Readable = require('stream').Readable, | |
stream = new Readable(), | |
data = ('Сайт рыбатекст поможет дизайнеру, верстальщику, вебмастеру сгенерировать несколько абзацев более менее осмысленного текста рыбы на русском языке, а начинающему оратору отточить навык публичных выступлений в домашних условиях. При создании генератора мы использовали небезызвестный универсальный код речей. Текст генерируется абзацами случайным образом от двух до десяти предложений в абзаце, что позволяет сделать текст более привлекательным и живым для визуально-слухового восприятия.').split(' ') | |
stream._read = function () { | |
if(data.length) { | |
setTimeout(function () { | |
stream.push(data.shift() + ''); | |
}, 200); | |
} else { |
NewerOlder