Skip to content

Instantly share code, notes, and snippets.

@Aetet
Aetet / gulp-di.js
Last active September 15, 2015 07:35
Gulp with immutable-di for data connection
/* eslint-disable */
var gulp = require('gulp');
var Facet = require('immutable-di/define').Facet;
var Container = require('immutable-di');
var NativeCursor = require('immutable-di/cursors/native');
var Setter = require('immutable-di/define').Setter;
var cursor = new NativeCursor({
@Aetet
Aetet / Widgetmap.js
Created August 6, 2015 14:10
Some switch logic
import React from 'react'
export default class WidgetMap extends React.Component {
render() {
const {mapBy, children, tagName, mapKeyName, ...props} = this.props
let defaultChild
const mk = mapKeyName || 'mapKey'
const widgets = (Array.isArray(children) ? children : [children]).filter(child => {
const mapKey = child.props[mk]
function processData(input) {
var arr = input.split('\n');
var len = arr[0];
var res = '';
for (var i = 1;i < arr.length; i++) {
if (i === arr.length - 1) {
res+=divider(arr[i]);
} else {
res+=divider(arr[i])+'\n';
}
@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

******

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.

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/
@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
@Aetet
Aetet / gist:11214010
Created April 23, 2014 12:50
Linux distrib version
cat /etc/*-release
@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: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)));
};
};