-
Programming with Futures
-
Render props in React
-
Basics of neural networks and Brain.js
-
How to work with RxJS
-
Bash chains and using xargs
This file contains 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
type ReturnType<T extends (...args: any[]) => any> = | |
T extends (...args: any[]) => infer R ? R : any; |
This file contains 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
const foo = (value: string) => { | |
return { | |
input: value, | |
time: Date.now(), | |
characters: value.split() | |
} | |
} | |
type FooOutput = { | |
input: string; |
This file contains 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 const idx = <T extends {}, U>( | |
props: T, | |
selector: (props: T) => U | undefined | |
) => { | |
try { | |
return selector(props); | |
} catch (e) { | |
return undefined; | |
} | |
}; |
This file contains 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 const idx = ( | |
props: any, | |
selector: (props: any) => any | |
) => { | |
try { | |
return selector(props); | |
} catch (e) { | |
return undefined; | |
} | |
}; |
This file contains 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
type User = { | |
user?: { | |
name: string, | |
friends?: Array<User>, | |
} | |
}; | |
// to safely get friends or friends, we have to write: | |
const friendsOfFriends = | |
props.user && |
This file contains 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
const wrapInObj = <T>(myValue: T) => { | |
return { | |
value: myValue, | |
} | |
} |
This file contains 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
const wrapInObj = (myValue: any) => { | |
return { | |
value: myValue, | |
} | |
} | |
const wrappedValue = wrapInObj(12345); | |
wrappedValue.value.split(); // TypeError: wrappedValue.value.split is not a function 🤒 |
This file contains 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
const pipe = require("lodash/fp/pipe"); | |
const qs = require("qs"); | |
const getRedirectToParam = (parsedQuery) => parsedQuery.redirect_to; | |
const storeRedirectToQuery = (redirectTo) => { | |
localStorage.setItem("REDIRECT_TO", redirectTo); | |
return redirectTo; | |
}; |
This file contains 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
const pipe = require("lodash/fp/pipe"); | |
const qs = require("qs"); | |
const getRedirectToParam = (parsedQuery) => parsedQuery.redirect_to; | |
const storeRedirectToQuery = (redirectTo) => { | |
localStorage.setItem("REDIRECT_TO", redirectTo) | |
return redirectTo; | |
}; |