Skip to content

Instantly share code, notes, and snippets.

Avatar

Stanislav Panferov s-panferov

View GitHub Profile
View gist:8a7e26350ddb31254269
var webpack = require('webpack');
var path = require("path");
var fs = require("fs");
var nodeModules = {};
fs.readdirSync('node_modules')
.filter(function (x) {
return ['.bin'].indexOf(x) === -1;
})
.forEach(function (mod) {
View gist:c1ef473f811438d719bf
{
"version": "1.5.0-beta",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"jsx": "react",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
@s-panferov
s-panferov / chat.ts
Created Jun 19, 2015
Immutable models in TS
View chat.ts
import invariant from '../lib/invariant';
import * as models from './index';
import { Record, Map, Set, List } from 'immutable';
import { Option, Some, None } from 'opty';
export enum ChatType {
Dialog = <any>'dialog',
Room = <any>'room'
}
View json.json
{
block : 'form-field',
name : 'documentUrgency',
mods : { theme : 'alfa', bkg : 'color' },
content : [
{ tag : 'br' },
{ tag : 'br' },
{ tag : 'br' },
{
block : 'checkbox',
View dep-hell.js
modules.define('madison',
['log', 'config', 'utils', 'router', 'bank__auth', 'bank__customers', 'page'],
function(provide, log, config, utils, router, bankAuth, bankCustomers, page) {
var vow = require('vow'),
express = require('express'),
path = require('path'),
cookies = require('cookie-parser'),
session = require('express-session'),
body = require('body-parser');
View with.js
var x = 5;
var y = 10;
with({x: 20}) {
var x = 30;
var y = 30;
console.log(x);
console.log(y);
};
View genericHell.ts
state = rx.BehaviorSubject<
model_state.ModelState<
immutable.Map<
Ref,
rx.BehaviorSubject<model_state.ModelState<Model, void>>
>,
Meta
>
>;
View col.ts
export interface ModelState<Model> {
model: opty.Option<Model>;
isProcessing: boolean;
isPending: boolean;
}
export interface ListModel<Ref, Model, Meta> {
models: immutable.Map<Ref, rx.BehaviorSubject<ModelState>>;
meta: opty.Option<Meta>;
}
View API.ts
private dispatchLoadOrgs(action: org_actions.LoadOrgs.Start) {
loadOrgsLock.lock(action.actionId, api.requestManager);
org_api.OrgApi
.loadOrgs(action.actionId)
.then((reply) => {
loadOrgsLock.unlock();
this.dispatcher.dispatch(new org_actions.LoadOrgs.Complete(action, reply.orgs))
})
.catch((e) => {
View DOM.ts
var viewClass = bemr.block("card");
return DOM.div({className: viewClass},
DOM.div({className: viewClass.el("cover")},
avatar.AvatarF({
url: "/public/profile.png",
variant: avatar.Variant.Large,
className: viewClass.el("avatar")
}),
DOM.div({className: viewClass.el("name")}, user.name)