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 / create-workspace-app.ts
Created July 16, 2022 21:05
Create an app inside a npm workspace. Params: directory name. Ex: ts-node create-workspace-app.ts apps mobile
import { execSync } from 'child_process'
const [directory, filename] = process.argv.slice(2, 4)
const log = (...args: any[]) => console.log(`log: `, ...args)
const copyFile = (src: string, to: string) => {
execSync(`cp ${src} ${to}`)
log(`file ${src} copied to ${to}`)
}
const createDir = (value: string) => {
@guiseek
guiseek / password-strength.html
Last active August 4, 2022 19:37
Password Strength Custom Element
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8" />
<title>Password Strength Custom Element</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
}
fieldset,
@guiseek
guiseek / accordion-item-heading.component.scss
Last active September 9, 2022 14:16
Accordion Details Component
[eghp-accordion-item-heading] {
align-items: center;
display: inline-flex;
cursor: pointer;
padding: 16px;
> * {
flex: 1;
}
@guiseek
guiseek / _media.mixins.scss
Created December 15, 2022 04:09
Sass media query mixins
@use 'sass:map';
$breakpoint: (
'xxs': 240,
'xs': 360,
'sm': 480,
'md': 768,
'lg': 1024,
'xl': 1440,
'xxl': 1920,
@guiseek
guiseek / error.page.ts
Last active January 15, 2023 12:10
Router
export class ErrorPage extends HTMLElement {
innerHTML = `<h1>Error</h1>`
}
customElements.define('error-page', ErrorPage)
export class FrontendStorageService<T extends StorageMap> {
private _storage: Storage
constructor(storage: Storage) {
this._storage = storage
}
get<K extends keyof T>(key: K) {
const data = this._storage.getItem(String(key))
if (data) {
@guiseek
guiseek / that-as.ts
Created January 8, 2023 15:34
That As
export const that = <I>(value: I) => ({
as<O>() {
return value as unknown as O
},
})
@guiseek
guiseek / color.ts
Created January 13, 2023 21:03
hexToRgb - rgbToHex
const hexCharacters = 'a-f\\d';
const match3or4Hex = `#?[${hexCharacters}]{3}[${hexCharacters}]?`;
const match6or8Hex = `#?[${hexCharacters}]{6}([${hexCharacters}]{2})?`;
const nonHexChars = new RegExp(`[^#${hexCharacters}]`, 'gi');
const validHexSize = new RegExp(`^${match3or4Hex}$|^${match6or8Hex}$`, 'i');
type ColorArrayType = [number, number, number, number];
type ColorStyleType = `rgb(${number} ${number} ${number}${string})`;
type ColorObjectType = {
red: number;
@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
@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">