Skip to content

Instantly share code, notes, and snippets.

Avatar

Naman Goel nmn

View GitHub Profile
@nmn
nmn / CallFormEditable.user.js
Last active Mar 8, 2018
TamperMonkey Scripts for IC
View CallFormEditable.user.js
// ==UserScript==
// @name Call Form Editable Still
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Make all View Buttons Edit Buttons
// @author You
// @match https://ic.bdsmarketing.com/IC.DataCollection/HoursCollection.aspx*
// @grant none
// ==/UserScript==
@nmn
nmn / CallFormEditable.js
Created Mar 1, 2018
TamperMonkey Scripts for IC
View CallFormEditable.js
// ==UserScript==
// @name Call Form Editable Still
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Make all View Buttons Edit Buttons
// @author You
// @match https://ic.bdsmarketing.com/IC.DataCollection/HoursCollection.aspx*
// @grant none
// ==/UserScript==
@nmn
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
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>,
...rest: 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
// https://en.wikipedia.org/wiki/Skew_heap#Implementation
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
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`
*/
/*
Link:
https://flow.org/try/#0C4TwDgpgBAJA8gIwFYQMbADwDUB8UC8UA3gNQDaA1hCAFxQDOwATgJYB2A5gLp1YC+AKFCQoAfRhYAhgBsArhHrYANFDh14yNJlx5CWIeGgSZ8xWtWb0uscbkKMAKhVwcAt8OiIkBYgKhQSVDo2WQBbBAgmJT8AhDpGVk5o-xJJOgQAewzpCEk2aMEBABM0aUkmaAA3cqhaWCk7M2RXAG4ACjqE9g4oAB8oTOzctj6oEPDIgEo3AHoZ9rqAQSYmSRAMcYimHEmoOagAURWMpgYACwyAdxHUE4r0aRAoM8iIATmF4LCt0a7OXf2RyYJ3OVxudy0j2er3e8w6XwmTABM0Ox1O9Au1ygtxWkKeLwqsM+AyyOTyyNRwPRmPBuIe+JhH3hDGY3QpQJBGLB2Ih9OhhKAA
*/
@nmn
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
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
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
# PREREQUISITES:
# 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 BROWSER_SYNC_HOSTNAME=<USERNAMEHERE>.dev.agkn.net
export GOPATH=$HOME/go-packages/
You can’t perform that action at this time.