Skip to content

Instantly share code, notes, and snippets.

@Aetet
Aetet / gist:8690814
Created January 29, 2014 15:49
События
1. Не рекомендуется навешивать события внутри обработчиков других событий, если эти события выполняются больше одного раза.
Пример:
@.listenTo(adultCounter,
'render': () =>
this.listenTo(adultNamesView,
'someEvent': () ->
console.log('I handle this')
adultNamesView.render()
@_renderAdultViews(adultNamesView.$el, adultCollection)
@Aetet
Aetet / gist:8799086
Created February 4, 2014 06:36
JSX sublime snippet
<snippet>
<content><![CDATA[
/**
* @jsx React.DOM
*/
var React = require('react');
var Events = require('../../util/Events');
console.log('Events', Events);
var $1 = React.createClass({
@Aetet
Aetet / gist:8857503
Created February 7, 2014 04:50
Javascript caret
function setCaretPosition(ctrl, pos){
if(ctrl.setSelectionRange)
{
ctrl.focus();
ctrl.setSelectionRange(pos,pos);
}
else if (ctrl.createTextRange) {
var range = ctrl.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
@Aetet
Aetet / gist:9259336
Created February 27, 2014 20:55
JS Snippet
var curry = function (fn) {
var args = [].slice.call(arguments, 1);
return function () {
return fn.apply(this, args.concat([].slice.call(arguments)));
};
};
@Aetet
Aetet / gist:9344864
Created March 4, 2014 11:33
Controller example
q = require('q')
Suggestions = require('./models/suggest_server_model.coffee')
SuggestView = require('./views/suggest_view.coffee')
SuggestSelectView = require('./views/suggest_select_view.coffee')
class Suggest extends app.BasicObject
constructor: (options) ->
self = this
suggestView = new SuggestView()
# suggestView.on('render', () ->
# )
@Aetet
Aetet / gist:11214010
Created April 23, 2014 12:50
Linux distrib version
cat /etc/*-release
@Aetet
Aetet / gist:e649d49fc995ece0ee68
Last active August 29, 2015 14:01
Node snippets
strace -o logopen -ff -eopen node app.js Показывает какие файлы открывались через system calls.
Показывает содержимое файла из гита.
git show some-file
Tactile scrolling
http://ariya.ofilabs.com/tag/kinetic
Low level v8 optimization
https://github.com/thlorenz/v8-perf
https://github.com/petkaantonov/bluebird/wiki/Promise-anti-patterns#the-deferred-anti-pattern
Smooth animation on page
http://css-tricks.com/add-page-transitions-css-smoothstate-js/

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@Aetet
Aetet / posa.mkdn
Created August 4, 2014 13:33 — forked from audreyt/posa.mkdn

From SocialCalc to EtherCalc

Previously, in The Architecture of Open Source Applications, I described SocialCalc, an in-browser spreadsheet system that replaced the server-centric WikiCalc architecture. SocialCalc performs all of its computations in the browser; it uses the server only for loading and saving spreadsheets.

For the Socialtext team, performance was the primary goal behind SocialCalc's design in 2006. The key observation was this: Client-side computation in JavaScript, while an order of magnitude slower than server-side computation in Perl, was still much faster than the network latency incurred during AJAX roundtrips:


WikiCalc and SocialCalc's performance model

******