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
db.runCommand({ | |
collMod: 'posts', | |
validator: { | |
$jsonSchema: { | |
bsonType: 'object', | |
required: ['title', 'text', 'creator', 'comments'], | |
properties: { | |
title: { | |
bsonType: 'string', | |
description: 'must be a string and is required' |
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
db.createCollection('posts', { | |
validator: { | |
$jsonSchema: { | |
bsonType: 'object', | |
required: ['title', 'text', 'creator', 'comments'], | |
properties: { | |
title: { | |
bsonType: 'string', | |
description: 'must be a string and is required' | |
}, |
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
import fs from 'fs'; | |
const matches = fs | |
.readFileSync('football.csv', { | |
encoding: 'utf-8', | |
}) | |
.split('\n') | |
.map((row: string): string[] => { | |
return row.split(','); | |
}); |
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
import NextAuth from 'next-auth'; | |
import type { NextAuthOptions } from 'next-auth'; | |
import CredentialsProvider from 'next-auth/providers/credentials'; | |
import User from '@/models/userModel'; | |
import { connectDb } from '@/utils/connect'; | |
import bcrypt from 'bcryptjs'; | |
const authOptions: NextAuthOptions = { | |
providers: [ | |
CredentialsProvider({ |
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 handleSubmit = async (e: any) => { | |
e.preventDefault(); | |
const username = e.target[0].value; | |
const email = e.target[1].value; | |
const password = e.target[2].value; | |
if (!isValidUsername(username)) { | |
setError('Nombre de usuário inválido'); | |
return; | |
} |
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
class Sorter { | |
constructor(public collection: number[] | string) {} | |
sort(): void { | |
const { length } = this.collection; | |
for (let i = 0; i < length; i++) { | |
for (let j = 0; j < length - i - 1; j++) { | |
if (this.collection instanceof Array) { | |
if (this.collection[j] > this.collection[j + 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
useEffect(() => { | |
if ( | |
typeof window !== 'undefined' && | |
typeof window.ethereum !== 'undefined' | |
) { | |
const provider = new ethers.providers.Web3Provider( | |
window.ethereum as any | |
); | |
// @ts-ignore | |
setSigner(provider.getSigner()); |
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
export interface mappable { | |
location: { | |
lat: number; | |
lng: number; | |
}; | |
markerContent(): string; | |
color: string; | |
} | |
export class CustomMap { |
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 Tesseract = require('tesseract.js'); | |
const sharp = require('sharp'); | |
// Ruta de la imagen de entrada (asegúrate de que la imagen exista) | |
// 0021995m3 | |
const imagePath = 'src/3.jpeg'; | |
// Función para extraer texto de la imagen | |
async function extractTextFromImage() { | |
try { |
NewerOlder