Skip to content

Instantly share code, notes, and snippets.

View guiseek's full-sized avatar
🌱
Nós poderíamos ser muito melhores se não quiséssemos ser tão bons.

Guilherme Siquinelli guiseek

🌱
Nós poderíamos ser muito melhores se não quiséssemos ser tão bons.
View GitHub Profile
@guiseek
guiseek / di.ts
Created May 18, 2024 05:16
DI - use / add / set
const container = new Map()
const relations = new Map()
export const use = <T>(type: Key<T>): T => {
const concrete = container.get(type)
if (!concrete) throw `Provider ${type.name} não registrado`
return concrete
}
const provide = <T>({for: key, use}: For<T>) => {
export const App = () => {
const title = "TSX Vanilla";
return (
<>
<h1>{title}</h1>
</>
);
};
@guiseek
guiseek / index.html
Created May 4, 2024 05:04
Audio player vanila HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/ts.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + TS</title>
<style>
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
@guiseek
guiseek / create-three.sh
Last active April 21, 2024 14:59
create vite project with three.js
#!/bin/bash
pnpm create vite@latest $1 --template vanilla-ts
cd $1
nvm use 20
pnpm add three
@guiseek
guiseek / idle-config.ts
Last active April 4, 2024 22:23
Idle Detection
export interface IdleConfig {
maxIdle: number;
warnPeriod?: number;
scope?: Node;
}
@guiseek
guiseek / pipe.ts
Created March 17, 2024 02:15
Pipe functions
type Fn<T, R> = (value: T) => R;
type Pipe<T, R> = [Fn<T, R>, ...Fn<R, R>[]];
function pipe<T, R>(...[fn, ...fns]: Pipe<T, R>) {
return (value: T) => fns.reduce((p, c) => c(p), fn(value));
}
@guiseek
guiseek / demo.ts
Last active February 29, 2024 17:24
custom rxjs
// Exemplo de uso:
of(10)
.pipe(
map((value) => value * 4),
filter((value) => value > 2)
)
.subscribe((value) => console.log(value));
@guiseek
guiseek / dx.term
Last active January 18, 2024 18:38
zsh
#!/bin/sh
#
# This script should be run via curl:
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# or via wget:
# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# or via fetch:
# sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
#
# As an alternative, you can first download the install script and run it afterwards:
@guiseek
guiseek / brew.sh
Created January 18, 2024 18:09
homebrew
#!/bin/bash
# We don't need return codes for "$(command)", only stdout is needed.
# Allow `[[ -n "$(command)" ]]`, `func "$(command)"`, pipes, etc.
# shellcheck disable=SC2312
set -u
abort() {
printf "%s\n" "$@" >&2
@guiseek
guiseek / git-auto-complete.zsh
Last active January 18, 2024 17:56
Git aliases
#compdef git gitk
# zsh completion wrapper for git
#
# Copyright (c) 2012-2020 Felipe Contreras <felipe.contreras@gmail.com>
#
# The recommended way to install this script is to make a copy of it as a
# file named '_git' inside any directory in your fpath.
#
# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git',