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
.slide-up, .slide-down { | |
overflow:hidden; | |
} | |
.slide-up > div, .slide-down > div { | |
transform: translateY(-100%); | |
transition: .4s ease-in-out; | |
} | |
.slide-down > div { | |
transform: translateY(0); | |
} |
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
function validaCNPJ (cnpj) { | |
var b = [ 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2 ] | |
var c = String(cnpj).replace(/[^\d]/g, '') | |
if(c.length !== 14) | |
return false | |
if(/0{14}/.test(c)) | |
return false |
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
// From: https://devarthur.com/blog/funcao-para-validar-data-em-javascript | |
// Codepen: https://codepen.io/devarthur/pen/vYgBWmv | |
function validaData (valor) { | |
// Verifica se a entrada é uma string | |
if (typeof valor !== 'string') { | |
return false | |
} | |
// Verifica formado da data |
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
/** | |
* Adiciona números de linha aos blocos de código na página. | |
*/ | |
function adicionarNumerosLinhasCodigo () { | |
// Seleciona todos os elementos <pre><code> na página | |
document.querySelectorAll('pre code') | |
.forEach(container => { | |
// Obter as linhas de código | |
const linhas = container.innerHTML.split('\n') |
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
/** | |
* Adds line numbers to code blocks on the page. | |
*/ | |
function addLineNumbersToCode () { | |
// Select all <pre><code> elements on the page | |
document.querySelectorAll('pre code') | |
.forEach(container => { | |
// Get code lines | |
const lines = container.innerHTML.split('\n') |
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
/** | |
* Adds line numbers to code blocks on the page. | |
*/ | |
function addLinesToCode () { | |
// Select all <pre><code> elements on the page | |
document.querySelectorAll('pre code') | |
.forEach(container => { | |
// Get code lines | |
const lines = (container.textContent.match(/\n/g)||[]).length + 1 |
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 express = require('express') | |
const Article = require('./article.model.js') | |
const validate = require('./validate.middleware.js') | |
const router = express.Router() | |
router.get('/articles', | |
validate('query', { | |
title: String, | |
text: 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
const { readFileSync } = require('fs') | |
const { resolve } = require('path') | |
// Resolving the absolute path of the 'views' directory | |
const viewDir = resolve(`${ __dirname }/views/`) | |
/** | |
* Renders a view with the provided data. | |
* @param {string} viewName - The name of the view to render. | |
* @param {object} data - The data to pass to the view. |
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 sharp = require('sharp') | |
const maxWidth = 1200 | |
const maxHeight = 2000 | |
await sharp('uploads/image.png') | |
.resize(maxWidth, maxHeight * 1.5, { | |
fit: 'inside', | |
withoutEnlargement: true, // this | |
}) |
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
let docs | |
// METHOD 1 - new Date() +1 day | |
const startDate = new Date('2021-03-31 00:00') | |
const endDate = new Date(startDate.getTime() + 86400000) | |
docs = await collection.find({ | |
date1: { | |
$gte: startDate, | |
$lt: endDate | |
} |
NewerOlder