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://twitter.com/sseraphini/status/1521845452529979395 | |
| // by https://github.com/fersilva16 | |
| import { useRef } from 'react'; | |
| export const useStepCount = () => { | |
| const stepCount = useRef<number>(); | |
| stepCount.current = 0; |
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
| // === Arrays | |
| var [a, b] = [1, 2]; | |
| console.log(a, b); | |
| //=> 1 2 | |
| // Use from functions, only select from pattern | |
| var foo = () => [1, 2, 3]; |
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 express = require('express') | |
| const app = express() | |
| const port = process.env.PORT || 3000; | |
| function sleep(ms) { | |
| return new Promise((resolve) => { | |
| setTimeout(resolve, ms); | |
| }); | |
| } |
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
| PUT NICE LINKS HERE |
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 | |
| * let cursor = Test.find().sort({ name: 1 }).cursor(); | |
| const get = makeGen(cursor, 100); | |
| let first100 = await get.next(); | |
| console.log(first100.value.length); | |
| https://gist.github.com/lineus/3f7d826a21796129db968d6590c93faa | |
| */ | |
| export async function* batchCursor(c, n) { | |
| const cursor = c; |
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
| cat .gitconfig 1 ↵ tgmarinho@Thiagos-MacBook-Pro | |
| [user] | |
| name = Thiago Marinho | |
| email = [email protected] | |
| [core] | |
| editor = code | |
| longpaths = true | |
| [diff] | |
| tool = meld | |
| [difftool "meld"] |
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 { ethers } from 'ethers' | |
| export const isEscrowAddressValid = (param: string) => { | |
| try { | |
| ethers.utils.getAddress(param) | |
| return true | |
| } catch (error) { | |
| return false | |
| } | |
| } |
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 { Buffer } from 'buffer' | |
| export const transformSVGInBase64 = (svgFile: string) => { | |
| const imageInBase64 = Buffer.from(svgFile).toString('base64') | |
| const imageReadyToTagImg = 'data:image/svg+xml;base64,' + imageInBase64 | |
| return imageReadyToTagImg | |
| } |
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 function stringToUtf16Bytes(escrowId: string) { | |
| const bytes = [] | |
| for (let position = 0; position < escrowId.length; position++) { | |
| const code = escrowId.charCodeAt(position) // x00-xFFFF | |
| bytes.push(code & 255, code >> 8) // low, high | |
| } | |
| return bytes | |
| } |