Skip to content

Instantly share code, notes, and snippets.

View istarkov's full-sized avatar
💭
I need snow, now!

Ivan Starkov istarkov

💭
I need snow, now!
View GitHub Profile
@acdlite
acdlite / gist:c7eb7ac45617d9332b60
Last active August 29, 2015 14:20
Imagining a more functional, classless Flummox API
import Flummox from 'flummox';
import { Map } from 'immutable';
// Instead of a constructor, just wrap flux creation inside a function
export default function createFlux() {
const flux = new Flummox();
// Actions are the same. Just pass an object instead of a class.
const thingActions = flux.createActions('things', {
incrementSomething(amount) {
@leon
leon / README.md
Created February 4, 2014 09:49
angularjs $q decorator for spread

Use it like this

$q.all([ promise1, promise2 ]).then($q.spread(function (promise1Result, promise2Result) {

});

import {Component} from 'react'
import shallowEqual from 'react/lib/shallowEqual'
export function observe(ComposedComponent) {
if (!ComposedComponent.observe) {
return ComposedComponent
}
Object.defineProperty(ComposedComponent.prototype, 'data', {
@zackify
zackify / .eslintrc
Last active December 21, 2015 17:57
Upgrade to Babel 6
{
"parser": "babel-eslint",
"env": {
"es6": true,
"mocha": true,
"node": true
},
"ecmaFeatures": {
"blockBindings": true,
"forOf": true,
@MoOx
MoOx / webpack.config.babel.js
Last active March 28, 2016 06:20
Simpler webpack config concept
import webpackSimpleConfig from "webpack-simple-config"
/*
ideas:
- simpler config
- fix loaders order (imo, more logical order): proof is that every new webpack user don't get this part
- no tons of way to provide config via string, query etc
- some shortcuts: simple extract, aliases
*/
@fukata
fukata / nginx.lb.conf
Created October 25, 2012 05:57
nginx proxy cache gzipped contents
http {
upstream web_backend {
server web01:80;
server web02:80;
}
proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=cache-space:100m max_size=1024m inactive=1h;
proxy_temp_path /var/cache/nginx/tmp;
server {
@deebloo
deebloo / rxjs-worker-map.example.js
Last active August 19, 2016 17:24
A RxJs operator that runs in a new thread. https://github.com/deebloo/rxjs-worker
// https://github.com/deebloo/rxjs-worker
var observable = Observable.of([0, 1, 2, 3, 4]);
observable
.map(function (data) {
return data.concat([5, 6, 7, 8, 9]);
})
.workerMap(function (data) {
return data.concat([10,11,12,13,14]);;
})
@skevy
skevy / gist:8a4ffc3cfdaf5fd68739
Last active February 4, 2017 04:59
Redux with reduced boilerplate

Note

I would recommend @acdlite's redux-actions over the methods suggested in this Gist.

The methods below can break hot-reloading and don't support Promise-based actions.

Even though 'redux-actions' still uses constants, I've come to terms with the fact that constants can be good, especially in bigger projects. You can reduce boilerplate in different places, as described in the redux docs here: http://gaearon.github.io/redux/docs/recipes/ReducingBoilerplate.html


Synchronous module inspection

This document describes the challenges presented by import() and how they could be addressed.

Problem

If you're starting up an app with multiple modules already loaded, using import() prevents you from gaining access to them synchronously.

@rosskevin
rosskevin / relay.js
Last active June 27, 2018 01:07
flow libdef for relay modern 1.2. This is in a _works for me_ state. Someone please export these properly from relay or create a proper flow-typed libdef.
// @flow
declare module 'react-relay' {
declare export type RecordState = 'EXISTENT' | 'NONEXISTENT' | 'UNKNOWN';
declare export type onCompleted = (response: ?Object, errors: ?Array<PayloadError>) => void
declare export type onError = (error: Error) => void
declare export type CommitOptions = {
onCompleted: onCompleted,