Skip to content

Instantly share code, notes, and snippets.

View ValchanOficial's full-sized avatar
:octocat:
Happy Octocat

Valéria Padilha de Vargas ValchanOficial

:octocat:
Happy Octocat
View GitHub Profile
package.json
{
"name": "config",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "npx jest --runInBand test/",
"test:dev": "npx jest --runInBand --watchAll test/",
https://precisoestudarsempre.blogspot.com/2013/08/regex-para-aceitar-acentos.html
[A-Za-zà-úÀ-Ú]
@ValchanOficial
ValchanOficial / gist:fd6de7f5cc3471092fe3d3d5876826f6
Created November 23, 2023 17:34
[Zod][Images] Upload image
https://stackoverflow.com/a/76526810/11842937
https://codesandbox.io/p/sandbox/boring-platform-gpmnd9?file=%2Fsrc%2FApp.tsx%3A38%2C15&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clpbg1hi700072a67brbvi1bu%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%25
@ValchanOficial
ValchanOficial / gist:fe38a90c506fbaf6cc1857f65cbe1db8
Created November 21, 2023 21:09
[Zod][superRefine] How to check confirm password with zod
https://stackoverflow.com/questions/73695535/how-to-check-confirm-password-with-zod
https://github.com/colinhacks/zod#superRefine
export const registerUserSchema = z.object({
firstName: z.string(),
lastName: z.string(),
userName: z.string(),
email: z.string().email(),
phone: z.string().transform(data => Number(data)),
password: z.string().min(4),
@ValchanOficial
ValchanOficial / gist:eaeb4b22cb387347d3c65339599805ae
Created November 20, 2023 17:03
About large files on GitHub
https://docs.github.com/pt/repositories/working-with-files/managing-large-files/about-large-files-on-github
Open Git Bash.
Change the current working directory to your local repository.
To remove the file, enter git rm --cached:
@ValchanOficial
ValchanOficial / gist:8e15b365832b9452240c86799e1d18f1
Created August 4, 2023 01:37
[Storybook][How to fix] /node_modules/cli-table3/src/utils.js not supported.
Error:
const stringWidth = require('string-width');
^
.../node_modules/cli-table3/src/utils.js not supported.
How to solve:
delete yarn.lock and install packages again
@ValchanOficial
ValchanOficial / gist:8df01b193c4bff31512e86773fe045e6
Created June 19, 2023 12:45
[Javascript] Get image name from url
const url = 'https://valchan.com.br/static/59fef712836ff3c9af18106e6daea978/3554d/valchan.webp'
const imageName = url.split('/').pop().split('.').shift()
const imageName2 = url.split('/').pop().replace(/\.[^/.]+$/, "")
console.log(imageName) // valchan
console.log(imageName2) // valchan
@ValchanOficial
ValchanOficial / gist:c3e908ea4a0235151c8486363e9af85e
Last active November 24, 2023 19:57
[Javascript] file to Base64
// with undici
const getBase64FromUrl = async (url) => {
const response = await fetch(url)
const arrayBuffer = await response.arrayBuffer()
const base64 = Buffer.from(arrayBuffer)toString('base64')
return base64
}
// without undici
@ValchanOficial
ValchanOficial / gist:b9c95bbc850279ef63dfee448de1acbe
Created June 15, 2023 18:21
[Python] Find element by key value in list of objects
values = [
{
'title': 'A',
'desc': 'Desc A'
},
{
'title': 'B',
'desc': 'Desc B'
},
{
@ValchanOficial
ValchanOficial / gist:ec7f54b6ded90a37eceb1462606c9aff
Created June 9, 2023 12:24
[Linux] Command to append line to a text file without opening an editor
https://askubuntu.com/questions/21555/command-to-append-line-to-a-text-file-without-opening-an-editor
Append a line of text to a file by using the >> operator:
echo "hello world" >> my_file.txt