// Retorna o valor com desconto de 10%
function valorDescontado(valorBruto) {
let desconto = 0.1;
console.log(`Calculando desconto de ${desconto}`);
return valorBruto * (1 - desconto);
}
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
| #!/bin/bash | |
| lint-staged() { | |
| # ng lint --files $(git diff --name-only --cached | tr '\n' ' ') | |
| staged_files=$(git diff --name-only --cached) | |
| staged_files_inline=$(echo $staged_files | tr '\n' ' ') | |
| command="ng lint --files $staged_files_inline" | |
| # if not null | |
| if [ ! -z "$staged_files" ]; then |
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
| HTMLFormElement.prototype.serialize = function() { | |
| const formData = new FormData(this); | |
| return Object.fromEntries(formData.entries()); | |
| } |
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
| class CPF { | |
| static CPF_MASK = '$1.$2.$3-$4'; | |
| static CPF_REGEX = /(\d{3})(\d{3})(\d{3})(\d{2})/; | |
| static generateFormated(): string { | |
| return this.format(this.generate()); | |
| } | |
| static format(cpf: string): string { | |
| return cpf.replace(this.CPF_REGEX, this.CPF_MASK); |
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 $(selector) { | |
| const el = document.querySelector(selector); | |
| return ({ | |
| html: () => el, | |
| hide: () => el.hidden = true, | |
| show: () => el.hidden = false, | |
| on: (event, callback) => el.addEventListener(event, callback), | |
| attr: (name, value) => value ? el.setAttribute(name, value) : el.getAttribute(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
| #!/usr/bin/env sh | |
| mkdir src | |
| cat << STYLE > src/style.scss | |
| h1 { | |
| color: blue; | |
| } | |
| STYLE |
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": "json-db", | |
| "version": "1.0.0", | |
| "description": "", | |
| "main": "index.js", | |
| "scripts": { | |
| "postinstall": "if [ ! -f db.json ]; then echo '{\n \"products\": []\n}' > db.json; fi", | |
| "start": "json-server --watch db.json --port 3001" | |
| }, | |
| "keywords": [], |
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 readline = require('readline'); | |
| readline.emitKeypressEvents(process.stdin); | |
| process.stdin.setRawMode(true); | |
| process.stdin.on('keypress', (str, key) => { | |
| if (key.ctrl && key.name === 'c') { | |
| process.exit(); | |
| } | |
| handleKey(key); |
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
| . |