Skip to content

Instantly share code, notes, and snippets.

Avatar
✍️
Working on something exciting

Alexey Raspopov alexeyraspopov

✍️
Working on something exciting
View GitHub Profile
View timestamp.js
provider = typeof window === 'object' && window.performance || Date;
timestamp = typeof provider.now === 'function' ? provider.now.bind(provider) : function(){ return +new Date(); };
View gist:eaffd30d5e8f65e739b2
function min(initial){
return map(function(value){
if(isNaN(initial) || value < initial){
initial = value;
}
return initial;
})
}
View gist:b93bd6bd0e9573dc9b5f
function SomeViewModel(title){
this.title = data(title)
.map(toLowerCase);
this.description = event(node, 'change')
.map(getTargetValue)
.filter(Boolean);
this.full = computed(interpolate('$0: $1'), [this.title, this.description]);
}
View gist:f796a055ee6251df472b
var data = require('./index');
function wrapper(process){
var observable, wrapper;
observable = data();
wrapper = function(value){
return arguments.length ? process(observable, value) : observable();
};
@alexeyraspopov
alexeyraspopov / birds.js
Last active Aug 29, 2015
Traits in JavaScript with CommonJS Modules
View birds.js
var rolesComposition = require('./trait');
function Duck(swimMessage, flyMessage){
this.swimMessage = swimMessage;
this.flyMessage = flyMessage;
}
Duck.prototype = rolesComposition(require('./swimming'), require('./flying'));
function Penguin(swimMessage){
View gist:50f1f81a7e1c5cf08167
CLI -> GUI -> NUI
Переход от CLI к GUI, на примере работы с гитом:
* усложняется работа за счет взаимодействия с мышью
* если использовать шорткаты вместо мыши, необходимо кроме знания команд знать и комбинации привязанные к ним. И в таком случае GUI является посредником опыта пользователя.
View generator
function* counter(start){
while (true) yield start++;
}
View range
function range(min, max, inc=1){
return Array.apply(null, Array(max - min + 1))
.map((_, index) => index + min)
.filter((_, index) => !(index % inc));
}
View spread.js
// returns a function which receive an array of values and apply they to `fn` as params
function spread(fn){
return fn.apply.bind(fn, null);
}
View use-over.js
var slice = Array.prototype.slice.call.bind(Array.prototype.slice);
function use(fn, fns){
return function(){
var args = slice(arguments);
return fn.apply(null, args.map(function(arg, index){
return fns[index](arg);
}));
}