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 { PrismaClient } from '@prisma/client'; | |
declare global { | |
interface CustomNodeJsGlobal extends NodeJS.Global { | |
prisma: PrismaClient; | |
} | |
} | |
const prisma: PrismaClient = global.prisma ?? new PrismaClient(); |
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 { useState, useEffect } from 'react'; | |
const useTimer = () => { | |
const [seconds, setSeconds] = useState(0); | |
useEffect(() => { | |
const intervalId = setInterval(() => { | |
setSeconds((prevSeconds) => prevSeconds + 1); | |
}, 1000); |
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 { NextResponse } from "next/server"; | |
export function Success(response: Object) { | |
return NextResponse.json({ status: 200, ...response }, { status: 200 }); | |
} | |
export function Created(response: Object) { | |
return NextResponse.json({ status: 201, ...response }, { status: 201 }); | |
} |
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 random | |
import string | |
def generate_random_string(length): | |
# Define the characters to choose from | |
characters = string.ascii_letters + string.digits + string.punctuation | |
# Generate a random string of the specified length | |
random_string = ''.join(random.choice(characters) for _ in range(length)) |
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 { | |
Injectable, | |
NestInterceptor, | |
ExecutionContext, | |
CallHandler, | |
} from '@nestjs/common'; | |
import { Observable } from 'rxjs'; | |
import { map } from 'rxjs/operators'; | |
export interface ResponseTemplate<T> { |
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 Graph: | |
def __init__(self, vertices): | |
self.vertices = vertices | |
self.adj_list = {v: [] for v in vertices} | |
def add_edge(self, u, v): | |
self.adj_list[u].append(v) | |
self.adj_list[v].append(u) # for undirected graph | |
def has_cycle(graph): |
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
extern crate crypto; | |
use crypto::digest::Digest; | |
use crypto::md5::Md5; | |
fn brute_force(hash: &str, charset: &str, max_length: usize) { | |
for length in 1..=max_length { | |
let mut attempt = vec![0; length]; | |
loop { | |
let guess: String = attempt |