Skip to content

Instantly share code, notes, and snippets.

View guiseek's full-sized avatar
🌱
Winners don't care what others think, the real battle is overcoming yourself.

Guilherme Siquinelli guiseek

🌱
Winners don't care what others think, the real battle is overcoming yourself.
View GitHub Profile
@guiseek
guiseek / input.ts
Created April 17, 2023 02:00
Criar formulários com decorators
import 'reflect-metadata'
type InputType =
| 'checkbox'
| 'color'
| 'datetime-local'
| 'email'
| 'file'
| 'image'
| 'month'
@guiseek
guiseek / breakout.ts
Last active April 15, 2023 04:33
Breakout
import './style.scss'
const canvas = document.createElement('canvas')
const contexto = canvas.getContext('2d')
const config = {
bola: {
raio: 10,
},
raquete: {
@guiseek
guiseek / index.html
Last active March 29, 2023 23:36
App Drawer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Fira+Sans:ital,wght@0,300;0,400;0,500;1,300;1,400&display=swap"
@guiseek
guiseek / axes-handler.ts
Last active March 8, 2023 06:15
Dependency Injection Provider
export abstract class AxesHandler<T = Readonly<number>> {
abstract handle(value: readonly T[]): {x: number; y: number}
abstract isActive(value: T): boolean
}
interface Window {
readonly navigation: Navigation;
}
interface NavigationEventMap {
"navigate": NavigateEvent;
"navigatesuccess": Event;
"navigateerror": ErrorEvent;
"currententrychange": NavigationCurrentEntryChangeEvent;
}
@guiseek
guiseek / game-control.ts
Last active March 4, 2023 22:22
Game Control - Gamepad API
type GameCallback = (gamepad: Gamepad) => void
interface GameAnimation {
animation: number
cancel(): void
}
export class GameControl {
#animations: GameAnimation[] = []
type PropControl<T, P extends keyof T = keyof T> = {
value: T[P]
set(value: T[P]): void
patch(value: Partial<T[P]>): void
onChange(fn: Callback<T[P]>): void
}
type StateByKey<T> = { [P in keyof T]: PropControl<T, P> }
type Callback<T> = (value: T) => void
import {UserService, UpdateUserDto, CreateUserDto, UserResponseDto, CreateDeviceDto, DeviceResponseDto, CreateMeetingDto, AgendaResponseDto} from '../../data'
import {ApiTags, ApiBody, ApiResponse, ApiOperation, ApiBearerAuth, ApiNotFoundResponse} from '@nestjs/swagger'
import {Get, Body, Post, Patch, Param, Delete, Controller, UnauthorizedException} from '@nestjs/common'
import {CaslAbilityFactory} from '../casl/casl-ability.factory'
import {AuthUserLogged, UserRole} from '@contact/type'
import {User} from '../../data/user/ports/user'
import {Logged, Roles} from '../../utils'
type Constructor<T = unknown> = new (...params: unknown[]) => T
@guiseek
guiseek / index.html
Created January 15, 2023 14:30
Chat WebRTC DataChannel com Broadcast Channel
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + TS</title>
</head>
<body>
<template id="messageItemTemplate">
@guiseek
guiseek / parser.d.ts
Created January 14, 2023 14:20
Typed Query Selector
type Whitespace = ' ' | '\n' | '\r' | '\f' | '\t'
type Trim<S extends string> = S extends `${infer T}${Whitespace}`
? Trim<T>
: S extends `${Whitespace}${infer T}`
? Trim<T>
: S
type Combinators = ' ' | '>' | '~' | '+'
type GetLastTag<I> = I extends `${string}${Combinators}${infer Right}`
? Right extends '' // right arm can't be empty