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 / JSFoo.md
Created January 6, 2018 06:28
wonky.md

#Core Idea

  • easy to start with and tough to master
  • brainstorming

#d11hack

We started off brain storming almost a week prior to the event about various problems that might get people interested in them. The [Web Crawler](link to the problem statement) was one which was the right balance of complexity and fun and adhered to our philosophy of

A good game is easy to start with but tough to master.

@tusharmath
tusharmath / JSFoo.md
Last active January 6, 2018 06:26
note.scala-cheatsheet

#Core Idea

  • easy to start with and tough to master
  • brainstorming

#d11hack

We started off brain storming almost a week prior to the event about various problems that might get people interested in them. The [Web Crawler](link to the problem statement) was one which was the right balance of complexity and fun and adhered to our philosophy of

A good game is easy to start with but tough to master.

@tusharmath
tusharmath / prettier.sh
Created December 25, 2017 13:43
prettier.sh
#!/usr/bin/env bash
git ls-files | \
grep -E '.*(css|ts|graphql)$' | \
xargs prettier --print-width 80 --single-quote --no-semi --no-bracket-spacing --write
const Set = (lens, value, target) => lens.set(value, target)
const View = (lens, target) => lens.get(target)
const Over = (lens, func, target) =>
Set(lens, func(View(lens, target), target), target)
const Compose = (...lenses) => {
lenses = lenses.reverse()
const itar = (i, target, value) => {
if (i === lenses.length) return value
return lenses[i].set(itar(i + 1, lenses[i].get(target), value), target)
@tusharmath
tusharmath / colorsublime.js
Created August 15, 2017 03:53
Scrapes all the download urls of color sublime themes
const R = require('ramda')
const O = require('observable-air')
const axios = require('axios')
const { JSDOM } = require('jsdom')
const makeRequest = url =>
axios.get(url).then(response => response.data).then(html => new JSDOM(html))
const fetchDOM = url => O.multicast(O.fromPromise(() => makeRequest(url)))
const fromArray = R.compose(O.fromArray, Array.from)
const findE = R.curry((sel, dom) =>
#!/usr/bin/env bash
git fetch origin
commitID=`git log origin/master..HEAD --oneline --pretty=format:"%h" | tail -1`
git rebase --onto origin/master $commitID~1 -i --preserve-merges --autosquash
@tusharmath
tusharmath / index.js
Created June 11, 2017 05:26 — forked from xgrommx/index.js
How we can make methods of observable via other methods
const flatMapLatest = (fn, stream) =>
stream.publish(s => s.flatMap(v => fn(v).takeUntil(s)));
const flatMapLatest = (fn, stream, resultSelector) => stream.publish(s => {
return s.flatMap(v => fn(v).map(v2 => resultSelector(v, v2)).takeUntil(s));
});
const delay = (source, delay) => source.flatMap(e => Rx.Observable.timer(delay).mapTo(e))
const debounceTime = (time, stream) => flatMapLatest(v => of(v).delay(time), stream);
@tusharmath
tusharmath / patch.js
Last active September 20, 2020 11:54
Virtual DOM library in 500bytes
const typeOf = ob => ob.toString()
const forEach = (fn, l) => typeOf(l) === '[object Object]'
? forEach(k => fn(l[k], k), Object.keys(l))
: Array.from(l).forEach(fn)
export const patch = (elm, node) => {
if(elm === node) return elm
if(typeOf(elm) === '[object Text]') {
elm.textContent = node.textContent
@tusharmath
tusharmath / esnextbin.md
Last active April 23, 2017 08:42
esnextbin sketch
@tusharmath
tusharmath / esnextbin.md
Last active April 19, 2017 05:40
esnextbin sketch