Skip to content

Instantly share code, notes, and snippets.

Avatar

Naman Goel nmn

View GitHub Profile
@nmn
nmn / setup.sh
Last active Apr 12, 2016
Mac Set-up
View setup.sh
#!/usr/bin/env bash
# install Xcode Command Line Tools
# https://github.com/timsutton/osx-vm-templates/blob/ce8df8a7468faa7c5312444ece1b977c1b2f77a4/scripts/xcode-cli-tools.sh
# touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
# PROD=$(softwareupdate -l |
# grep "\*.*Command Line" |
# head -n 1 | awk -F"*" '{print $2}' |
# sed -e 's/^ *//' |
# tr -d '\n')
@nmn
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 => {
// FOR PERF
const boundCheck = node =>
node.type === 'Identifier' && node.name === name ||
node.type === 'MemberExpression' && boundCheck(node.object) ||
node.type === 'CallExpression' && boundCheck(node.callee)
return boundCheck;
@nmn
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 {
render(){
return fn(this.props, this.context)
}
}
C.displayName = fn.displayName || fn.name
C.propTypes = fn.propTypes
C.contextTypes = fn.contextTypes
return C
@nmn
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(){
putAsync(Math.random())
setTimeout(fakeDataGenerator, Math.random() * 2000)
@nmn
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
if(!observe){
View gist:ee966ef14310d00b6d78
<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1" >
<form>
<record name="recording" beep="true" dtmfterm="true" maxtime="100s">
<prompt>
Please start your recording at the sound of the beep.
</prompt>
<prompt>
After you are finished, you may press any DTMF key to indicate that you are done recording.
</prompt>
You can’t perform that action at this time.