Skip to content

Instantly share code, notes, and snippets.

View tusharmath's full-sized avatar
😑
Imploding

Tushar Mathur tusharmath

😑
Imploding
View GitHub Profile
@tusharmath
tusharmath / coprophagus.js
Last active June 14, 2016 22:30
Create coprophagus streams
const Rx = require('Rx')
const O = Rx.Observable
const R = require('ramda')
function SlimShady (signal$) {
return signal$
.delay(500).map((x) => x + 1)
}
const coprophagus = R.curry((funct, signal$) => {
@tusharmath
tusharmath / esnextbin.md
Last active July 23, 2016 17:10
esnextbin sketch
@tusharmath
tusharmath / esnextbin.md
Last active July 23, 2016 17:21
esnextbin sketch
@tusharmath
tusharmath / esnextbin.md
Created July 23, 2016 18:34
esnextbin sketch
import {Component} from 'react'
import {Subject, Observable as O} from 'rx'
import R from 'ramda'
const isFunction = R.compose(R.equals('Function'), R.type)
const isObservable = i => i instanceof O
const toObservable = i => {
const canSkip = R.anyPass([isFunction, isObservable])
return canSkip(i) ? i : O.just(i)
}
@tusharmath
tusharmath / SmartyPants.js
Created July 25, 2016 14:31
Base class to make your component work with Rx
import {Subject} from 'rx'
import {Component} from 'react'
import R from 'ramda'
const appendPrefix = (x) => ['@PROPS.' + x[0], x[1]]
const propPair = R.compose(R.map(appendPrefix), R.toPairs)
export class SmartyPants extends Component {
constructor () {
@tusharmath
tusharmath / WebpackUtils.js
Created August 3, 2016 17:37
Helps in creating webpack configs in a lot more declarative way
import R from 'ramda'
export default (config) => {
const ofPath = R.path(R.__, config)
const _appendToPath = R.useWith(R.over, [R.lensPath, R.append])
const _plugin = _appendToPath(['plugins'])
const _loader = _appendToPath(['module', 'loaders'])
const _if = R.uncurryN(3, condition => R.ifElse(R.always(condition), R.__, R.identity))
const _copyFrom = R.useWith(R.set, [R.lensPath, ofPath, R.identity])
const _set = R.useWith(R.set, [R.lensPath, R.identity, R.identity])
@tusharmath
tusharmath / esnextbin.md
Last active August 11, 2016 18:59
esnextbin sketch
@tusharmath
tusharmath / esnextbin.md
Last active August 12, 2016 18:01
esnextbin sketch
@tusharmath
tusharmath / esnextbin.md
Last active August 14, 2016 12:35
esnextbin sketch