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
| const getSearchParams = <T extends object>(): Partial<T> => { | |
| // server side rendering | |
| if (typeof window === "undefined") { | |
| return {}; | |
| } | |
| const params = new URLSearchParams(window.location.search); | |
| return new Proxy(params, { |
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
| [ | |
| { "name": "Atreides", "planets": "Calladan" }, | |
| { "name": "Corrino", "planets": ["Kaitan", "Salusa Secundus"] }, | |
| { "name": "Harkonnen", "planets": ["Giedi Prime", "Arrakis"] } | |
| ] |
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
| type Customer = string; | |
| type CustomerId = string; | |
| type GetCustomer = (customer: CustomerId) => Customer; | |
| type Connection = string; | |
| type getCustomerFromDataBase = (connection: Connection) => GetCustomer; | |
| const connection = "DATABASE"; | |
| const gcfdb: getCustomerFromDataBase = (connection) => (customerId) => ` |
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
| const Last = (x) => ({ | |
| x, | |
| concat: (o) => o, | |
| }); | |
| // const Fn = f => | |
| // ({ | |
| // runFn: f, | |
| // map: g => Fn(x => g(f(x))), | |
| // concat: o => |
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
| function* asynFunction () { | |
| const data = yield fetch('url-here') | |
| console.log(data) | |
| } | |
| function doAfterFetch (value){ | |
| returnAfterFetch.next(value) | |
| } | |
| const returnAfterFetch = asynFunction() |
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
| ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/id_rsa | |
| ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/github_rsa | |
| ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/mozilla_rsa |
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
| function logger(strings,...values) { | |
| var str = ""; | |
| for (let i = 0; i < strings.length; i++) { | |
| if (i > 0) { | |
| if (values[i-1] && typeof values[i-1] == "object") { | |
| if (values[i-1] instanceof Error) { | |
| if (values[i-1].stack) { | |
| str += values[i-1].stack; | |
| continue; | |
| } |
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
| document.body.addEventListener('focusin', (event) => { | |
| console.log(document.activeElement) | |
| }) |
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
| const loops = 100; | |
| const numbers = [ | |
| [3, "Fizz"], | |
| [5, "Buzz"], | |
| ]; | |
| for (i = 1; i <= loops; i++) { | |
| r = numbers.filter((n) => !(i % n[0])); | |
| console.log(r.length ? r.map((result) => result[1]).join(" ") : i); | |
| } |
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 React from "react"; | |
| const reducer = (previousState = {}, updatedState = {}) => { | |
| return { ...previousState, ...updatedState }; | |
| }; | |
| const useSetState = (initialState = {}) => { | |
| const [state, dispatch] = React.useReducer(reducer, initialState); | |
| const setState = (updatedState) => dispatch(updatedState); |
NewerOlder