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 / uuid.ts
Created March 11, 2021 00:51
UUID / Tweet 4 / 10/03/2021
export class uuid {
static long() {
return uuid.fromBase('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx')
}
static short() {
return uuid.fromBase('xxxxxxxx')
}
private static fromBase(base: string) {
return base.replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0
import { MatDialog } from '@angular/material/dialog';
import { ConfirmDialogComponent } from '@webdev/ui';
import { Injector } from '@angular/core';
/**
* Decorator para dialog de confirmação
* @param message
*/
export function Confirmador(message: string) {
/**
@guiseek
guiseek / start-ts-project.sh
Last active January 29, 2023 03:19
Comandos pra começar um projeto simples usando TypeScript + HTML + ESBuild, usando Shell Script
#!/bin/bash
# Para usar, dê permissão de execução ao script
# usando o comando: chmod +x create-project.sh
# e então execute: ./create-project.sh projeto
mkdir $1
cd $1
npm init -y
@guiseek
guiseek / calendar.element.ts
Last active November 22, 2021 23:20
Seek Calendar
export interface DayDataSet extends DOMStringMap {
date: string;
month: string;
year: string
monthName: string
}
interface DayCell extends HTMLTableCellElement {
dataset: DayDataSet
}
@guiseek
guiseek / cube-3d-svg.html
Created December 5, 2021 21:46
Cubo 3D com SVG
<!doctype html>
<html lang="pt-br">
<head>
<meta charset="utf-8" />
<title>Cubo 3D</title>
<style>
.edge {
fill: white;
stroke: black;
@guiseek
guiseek / get-form-as-json.ts
Created May 8, 2022 07:00
Form to JSON Parser
export function getForrmAsJson<R>(form: HTMLFormElement) {
const data = new FormData(form)
const value = Object.fromEntries(data.entries()) as Record<string, any>
Object.keys(value).forEach((key) => {
value[key] = !isNaN(+value[key]) ? +value[key] : value[key]
})
return value as R
/**
* You may copy, distribute and modify the software
* as long as you track changes/dates in source files.
*
* Guilherme Siquinelli <[email protected]>
* Copyleft (ↄ) 2022 - LGPL-3.0
*/
export type IdSelector =
| `#${string}`
@guiseek
guiseek / src-infra-fetch-config.ts
Created June 15, 2022 23:05
Http atômico funcional
import { HttpMethod, HttpRequestMap } from '../types'
export function fetchConfig<M extends HttpMethod>(
method: M,
opts: HttpRequestMap[M]
): RequestInit {
let { body, data, headers = [] } = opts
if (body) body = JSON.stringify(body)
if (data) data = JSON.stringify(data)
@guiseek
guiseek / ia-talks.js
Last active June 18, 2022 19:39
Simulação de uma conversa entre um humano e uma I.A.
const synth = speechSynthesis;
let vsort = -1;
let voices = [];
function createIA(lang, pitch, rate) {
if (voices.length === 0) {
voices = synth.getVoices().filter((v) => v.lang === lang);
}
@guiseek
guiseek / query.ts
Created July 10, 2022 08:15
Document Query Selector Typed and Simplified. Ex.: `query<'nav'>('.navigation')`
export type IdSelector =
| `#${string}`
| `#${string} ${string}`
| `#${string} > ${string}`
| `${string}#${string}`;
export type ClassSelector =
| `.${string}`
| `.${string} .${string}`
| `.${string} > .${string}`