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
| import { Injectable, CanActivate, ExecutionContext } from "@nestjs/common"; | |
| import { SetMetadata } from "@nestjs/common"; | |
| import { Reflector } from "@nestjs/core"; | |
| export enum Role { | |
| User = "user", | |
| Admin = "admin", | |
| } | |
| export const Roles = (...roles: Role[]) => SetMetadata("roles", roles); |
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
| import { | |
| AuthorizationType, | |
| CognitoUserPoolsAuthorizer, | |
| Cors, | |
| CorsOptions, | |
| EndpointType, | |
| LambdaRestApi, | |
| } from "aws-cdk-lib/aws-apigateway"; | |
| import { IFunction } from "aws-cdk-lib/aws-lambda"; | |
| import { Certificate, CertificateValidation } from "aws-cdk-lib/aws-certificatemanager"; |
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
| import { OpenAI } from "langchain/llms/openai"; | |
| import { OpenAIEmbeddings } from "langchain/embeddings/openai"; | |
| import { BufferMemory } from "langchain/memory"; | |
| import { PineconeStore } from "langchain/vectorstores/pinecone"; | |
| import { ConversationalRetrievalQAChain } from "langchain/chains"; | |
| import { getPineconeClient } from "../utils/pinecone.utils"; | |
| import { PromptTemplate } from "langchain/prompts"; | |
| import { getConversationPromot, getQuestionPrompt } from "./prompt"; | |
| export class ConversationalRetrievalChat { |
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
| import { GlobInput, PuppeteerCrawler } from "crawlee"; | |
| import { OpenAIEmbeddings } from "langchain/embeddings/openai"; | |
| import { RecursiveCharacterTextSplitter } from "langchain/text_splitter"; | |
| import { PineconeStore } from "langchain/vectorstores/pinecone"; | |
| import { getPineconeClient } from "../utils/pinecone.utils"; | |
| import { GraphDbService } from "../graph/GraphDbService"; | |
| import { HNSWLib } from "langchain/vectorstores/hnswlib"; | |
| export class PineconeCrawler { | |
| constructor(private indexName: string, private urls: string[], private globs?: string[]) {} |
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
| import express from "express"; | |
| import { launch } from "puppeteer"; | |
| const proxyChain = require("proxy-chain"); | |
| import { URLSearchParams } from "node:url"; | |
| import fetch from "node-fetch"; | |
| import { appendFile } from "fs/promises"; | |
| import urls from "./urls.json"; | |
| import { ScanResults } from "./zap.type"; | |
| express().listen(process.env.PORT || 4000); |
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 isPerfectSquare = (n: number): boolean => Number.isInteger(Math.sqrt(n)); | |
| const isFibonacci = (n: number): boolean => isPerfectSquare(5 * n * n + 4) || isPerfectSquare(5 * n * n - 4); |
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
| type ToTupleType<B, F extends (keyof B)[]> = { | |
| [K in keyof F]: F[K] extends F[number] ? B[F[K]] : never; | |
| }; |
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
| interface AnomalyDetectorOptions<T> { | |
| dataset: T[]; | |
| numericKey: keyof T; | |
| sensitivity: number; | |
| } | |
| class AnomalyDetector<T extends Record<string, any>> { | |
| constructor(private options: AnomalyDetectorOptions<T>) {} | |
| private getValues(): number[] { |
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 CollatzConjecture implements Iterable<number> { | |
| private next = this.startFrom; | |
| constructor(private startFrom: number) {} | |
| *[Symbol.iterator](): Generator<number> { | |
| while (this.next !== 1) { | |
| this.next = this.next % 2 === 0 ? this.next / 2 : this.next * 3 + 1; | |
| yield this.next; | |
| } | |
| } |
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
| type OccurrenceMap<T extends readonly string[] | readonly number[]> = Record<T[number], number>; | |
| function getDuplicates(arr: readonly any[]): OccurrenceMap<typeof arr> { | |
| const reducer = (a: OccurrenceMap<typeof arr>, b: string) => ({ | |
| ...a, | |
| [`${b}`]: a[`${b}`] + 1 || 1, | |
| }); | |
| const res: OccurrenceMap<typeof arr> = arr.reduce(reducer); | |
| return Object.fromEntries(Object.entries(res).filter((e) => e[1] > 1)); | |
| } |
NewerOlder