Skip to content

Instantly share code, notes, and snippets.

Naman Goel nmn

Block or report user

Report or block nmn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:ee966ef14310d00b6d78
<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1" >
<record name="recording" beep="true" dtmfterm="true" maxtime="100s">
Please start your recording at the sound of the beep.
After you are finished, you may press any DTMF key to indicate that you are done recording.
nmn / Enhancer.js
Created Apr 7, 2015
Observe API with JS-CSP Mults
View Enhancer.js
import React, { Component } from 'react'
import {operations, chan, go, take, CLOSED} from 'js-csp'
const {mult} = operations
export default function polyfillObserve(ComposedComponent, observe) {
observe = observe || ComposedComponent.observe
nmn / csp-distribute.js
Last active Aug 29, 2015
CSP - distribute expensive tasks to workers - A contrived example to show the strength and flexibility of CSP when compared to FRP.
View csp-distribute.js
import {go, chan, put, take, buffers, putAsync, CLOSED} from 'js-csp'
const BUFFER_LIMIT = 100
const NUM_OF_WORKERS = 4
var inputChannel = csp.chan(buffers.dropping(BUFFER_LIMIT))
function fakeDataGenerator(){
setTimeout(fakeDataGenerator, Math.random() * 2000)
nmn / pureFunctions.js
Last active Aug 29, 2015
Quick and dirty hack to make pure functions work in React:
View pureFunctions.js
function component(fn){
class C extends React.Component {
return fn(this.props, this.context)
C.displayName = fn.displayName ||
C.propTypes = fn.propTypes
C.contextTypes = fn.contextTypes
return C
nmn / VerExBabelPlugin.js
Last active Jan 21, 2016
A work in progress to make a Babel plugin that compiles VerbalExpression (nice library to create RegEx) into proper RegEx's at compile time
View VerExBabelPlugin.js
import VerEx from 'verbal-expressions';
const eventualCallIs = name => {
const boundCheck = node =>
node.type === 'Identifier' && === name ||
node.type === 'MemberExpression' && boundCheck(node.object) ||
node.type === 'CallExpression' && boundCheck(node.callee)
return boundCheck;
nmn /
Last active Apr 12, 2016
Mac Set-up
#!/usr/bin/env bash
# install Xcode Command Line Tools
# touch /tmp/;
# PROD=$(softwareupdate -l |
# grep "\*.*Command Line" |
# head -n 1 | awk -F"*" '{print $2}' |
# sed -e 's/^ *//' |
# tr -d '\n')
View .zshrc
# install docker
# git clone antigen into your home folder. Should be able to find $HOME/antigen.zsh
# install rvm
# git clone zsh-autosuggestions into ~/.zsh/
# so `source ~/.zsh/zsh-autosuggestions/autosuggestions.zsh` works.
# Switch terminal to zsh instead of bash
export GOPATH=$HOME/go-packages/
nmn / $NonNull.ts
Created Jul 9, 2016
MagicFlowType 3: Type to convert nullable to non-nullable types
View $NonNull.ts
/* @flow */
type _NonNull<T, N: ?T> = T
type $NonNull<N> = _NonNull<*, N>
type Num = $NonNull<?number>
;(45: Num)
// $ExpectError
;(undefined: Num)
nmn / $Value.ts
Last active Jul 9, 2016
[BROKEN] Magic Flow Type Part 2: Trying to create a magic type $Value that gets the value type of an object and key.
View $Value.ts
/* eslint-disable */
// @flow
type $ObjectPair<K, V> = {[key: K]: V} | Object
type _$Value<Key: string, V, O: $ObjectPair<Key, V>> = V
type $Value<O: Object, K: $Keys<O>> = _$Value<K, *, O>
type Obj = {
c: number,
b: boolean,
View HaskellySkewHeap.swift
import Foundation
indirect enum SkewHeap<T> where T: Equatable, T: Comparable {
case Empty
case Node(T, SkewHeap<T>, SkewHeap<T>)
func singleton<T>(_ a: T) -> SkewHeap<T> where T: Equatable, T: Comparable {
return .Node(a, .Empty, .Empty)
You can’t perform that action at this time.