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 | |
} |
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
// Set the manual property of Prism object to true | |
window.Prism = { manual: true } | |
// Add an event listener for when the window is loaded | |
window.addEventListener('load', () => { | |
// Import the Prism.js library from the specified URL | |
import('https://cdnjs.cloudflare.com/ajax/libs/prism/9000.0.1/prism.min.js') | |
.then(() => { | |
console.log('Prism loaded.') |
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
########################### | |
# xbindkeys configuration # | |
########################### | |
# | |
# Version: 0.1.3 | |
# | |
# If you edit this, do not forget to uncomment any lines that you change. | |
# The pound(#) symbol may be used anywhere for comments. | |
# | |
# A list of keys is in /usr/include/X11/keysym.h and in |
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
Show hidden characters
{ | |
"<router-link>": { | |
"scope": "html", | |
"prefix": ["rt", "rou", "rout"], | |
"body": [ | |
"<router-link to=\"$1\">$2</router-link>" | |
], | |
}, |
NewerOlder