This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage: youtube-dl-playlist <youtube-playlist-url> | |
function youtube-dl-playlist() { | |
youtube-dl -o "%(playlist_index)s-%(title)s.%(ext)s" $1 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. args-order matters: | |
import { map } from 'ramda' | |
type Person { | |
name: string | |
} | |
function getName(person: Person) { return person.name } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for https://github.com/Instagram/MonkeyType/issues/105 | |
class TypedDictPlaceHolder(dict): | |
def __init__(self, **kwargs): | |
super().__init__(**kwargs) | |
for (key, value) in kwargs.items(): | |
self.__dict__[key] = value | |
def __setitem__(self, key, item): | |
self.__dict__[key] = item |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as t from 'io-ts' | |
export class FromTsStringEnumType<T extends object> extends t.Type<T[keyof T]> { | |
constructor (public enumObject: T, name?: string) { | |
super( | |
name || `fromTsStringEnum: ${enumObject}`, | |
(u): u is T[keyof T] => Object | |
.values(enumObject) | |
.some(v => v === u), | |
(u, c) => (this.is(u) ? t.success(u) : t.failure(u, c)), | |
t.identity, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type PackedGenerics<A,B,C> = { | |
a: A, | |
b: B, | |
c: C | |
} | |
type testType = PackedGenerics<number, boolean, string> | |
type unpack2nd<T extends PackedGenerics<any, any, any>> = T extends PackedGenerics<infer A2, infer B2, infer C2> ? { | |
a2: A2, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://stackoverflow.com/questions/10555136/delete-multiple-remote-branches-in-git | |
// TODO - define bash/zsh func |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { pipe } from 'ramda' | |
export function addB<T>(i: T) { | |
return { | |
...i, | |
b: 2, | |
} | |
} | |
export function addC<T>(i: T) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://stackoverflow.com/questions/57016728/is-there-a-way-to-define-type-for-array-with-unique-items-in-typescript | |
( https://www.typescriptlang.org/play/#code/MYewdgzgLgBFCuAHANgUwPIDMAyBLKqATgIbIQBcMA2gIwA0MATA4wLowC819TLrA3AFgAUKEiwEKDJgBy4PARJlKVMPAC2AIyIM1WnTD3bC7LrRZ8ho8NBjFCJAJ5YFRUhRgAKGjAA+TAEoqU24LJgERMVt7Jyw5MFclDyMiYM5Q3nCrEShHRFQYAEkwADdSXAATAB4AFQA+dIBRBxBCGAAyGABvGAB9XqJCVoBZVAgIYgBzVEoamABfDsNUEqJs4Vz8mABBCABVMFwAR3hUbYdiRyqRGB2YVAAPAjAKiBgAJVRiCvBkR3OnFViGBHHU6DcYAAhe5PVAvN6fb6-f4XK7A0EiBpcLoQqiFGC4MAwADWqEcIEwO1YlHgYGJYBAAHciY9nq9uhDblQAFIEomk8mUyHUmC81lw9n4gD8y1WbUokJ57HF8J2ePYMtp9KZRMoYBWRAh81UGmMrE5MBlxTKyEqVSo23VDAARLg3oRUPliAQKs7WHULZRHYVzcJ5utNgUZDEmcRNGhOBD-NBCITJknDKbDcJbv5NCAQGhgRmQJoAFaoYBQDNqZDIDO0iqoTCE1AVDMQRxaQvrKKwYj7Q4nM6o9LXHMwGQwtlvaMtRlxtDgifbacSt5pfyIn5gP4Ay5VGQNTq7A7HU77q7bBjbAPCOqeCHEIMiAKcBrEXs2WAgYmXdIDmew6Xp45iZAAzKwAT8DAAD0sEwL+lyRN+hggFA6B-o4AGDueI5OKBPDMOE0FwQhgytAAhCI8G3HR9EMYxTEMQAfrcLE0QhKRtG6aH9uMuCTGAi4FFAIBFKU5TVFQxGuu6npfD6foNP4jbNq27bCJxMAAMLbAAao02w1AAy |
OlderNewer