Skip to content

Instantly share code, notes, and snippets.

@devdoomari3
devdoomari3 / ramdaVsLodash.ts
Last active October 24, 2018 05:48
ramda.ts
// 1. args-order matters:
import { map } from 'ramda'
type Person {
name: string
}
function getName(person: Person) { return person.name }
@devdoomari3
devdoomari3 / hoc-template.tsx
Last active December 19, 2019 08:10 — forked from rosskevin/hoc-template.tsx
Typescript higher order component (hoc) template
/* variation on https://medium.com/@DanHomola/react-higher-order-components-in-typescript-made-simple-6f9b55691af1 */
import * as React from 'react'
import { wrapDisplayName } from 'recompose'
// Props you want the resulting component to take (besides the props of the wrapped component)
interface ExternalProps {}
// Props the HOC adds to the wrapped component
export interface InjectedProps {}
@devdoomari3
devdoomari3 / forceOnlyOnce.ts
Created August 10, 2018 09:40
Typescript force 'atmost once' on type-level
// use cases: class decorators, etc
function forceOnlyOnce (test: string & {__T?: undefined}) {
const test2: string = test
return test2 as string & { __T: null }
}
const a = forceOnlyOnce('123')
@devdoomari3
devdoomari3 / .zshrc
Created July 27, 2018 08:14
add youtube-dl playlist-index on zsh
# usage: youtube-dl-playlist <youtube-playlist-url>
function youtube-dl-playlist() {
youtube-dl -o "%(playlist_index)s-%(title)s.%(ext)s" $1
}