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
nmn / CallFormEditable.user.js
Last active Mar 8, 2018
TamperMonkey Scripts for IC
View CallFormEditable.user.js
// ==UserScript==
// @name Call Form Editable Still
// @namespace
// @version 0.1
// @description Make all View Buttons Edit Buttons
// @author You
// @match*
// @grant none
// ==/UserScript==
nmn / CallFormEditable.js
Created Mar 1, 2018
TamperMonkey Scripts for IC
View CallFormEditable.js
// ==UserScript==
// @name Call Form Editable Still
// @namespace
// @version 0.1
// @description Make all View Buttons Edit Buttons
// @author You
// @match*
// @grant none
// ==/UserScript==
nmn / HOF1.ts
Created Apr 25, 2017
a higher-order-function that almost maintains the function signature, but not quite.
View HOF1.ts
type ITask<I: $ReadOnlyArray<mixed>, O> = {
(...r: I): ?O,
lastError?: Error
function task <I: $ReadOnlyArray<mixed>, O>(inner: (...r: I) => O): ITask<I, O> {
const wrapped: any = function wrapped() {
try {
return (inner: any).apply(this, arguments)
} catch (err) {
nmn / $HOC.ts
Created Mar 4, 2017
A generalized type-def for Higher-Order Components in React.
View $HOC.ts
type HOC<InjectedProps, ExtraProps, Args: $ReadOnlyArray<*>> = <D, P, C: React$Component<D, P, any>>(
component: Class<C>, Args
) => Class<React$Component<D, $Diff<P, InjectedProps> & ExtraProps, any>>;
declare var injectName: HOC<{name: string}, {bla: Array<number>}, [string, number]>;
type Props = {
name: string,
age: number,
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)
nmn / $Values.ts
Last active Sep 11, 2017
something like $Keys but for values.
View $Values.ts
// @flow
This magic type will give you the union of the types of all the values in an object type.
This is still far from a fully dynamic $PropertyType, but it's a lot better than just using `any`
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,
nmn / FunctionValue.ts
Last active Nov 3, 2017
Magic Flow Type 1: $FunctionXValue —— A magic flow type that takes a function type that takes one arg, the type of that arg, and returns the return value type of the function.
View FunctionValue.ts
/* @flow */
type $Function1<A, B> = (arg: A) => B;
type _Function1Value<A, B, F: $Function1<A, B>> = B; // eslint-disable-line
type $Function1Value<F: $Function1<*, *>, A> = _Function1Value<A, *, F>;
var toString = (value) => String(value)
var toNumber = (value) => parseFloat(value) || 0
type NumberXString = ((value: number) => string) & ((value: string) => number)
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/
You can’t perform that action at this time.