Skip to content

Instantly share code, notes, and snippets.

View mkuchak's full-sized avatar

Marcos Kuchak mkuchak

View GitHub Profile
@mkuchak
mkuchak / To Install Extensions.md
Last active March 13, 2024 00:22
The best VSCode setup ever

To Install Extensions

Shortcut to call VSCode or VSCode Insiders on terminal

code <command> or

code-insiders <command>

List extensions

code --list-extensions on Windows or

@mkuchak
mkuchak / Email.ts
Last active February 12, 2024 19:29
TypeScript alias alternative to Static Factory Method: avoid static create and restore methods on DDD, just simplify
export class Email {
constructor(private _value: string) {
if (!this.isValid()) {
throw new Error("Invalid email");
}
}
private isValid(): boolean {
/**
* Must have a valid username and domain.
@mkuchak
mkuchak / update-golang.md
Last active January 7, 2023 16:55 — forked from nikhita/update-golang.md
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@mkuchak
mkuchak / cloudflare-workers-d1-template-insomnia.json
Last active December 16, 2022 22:39
Cloudflare Workers Template
{"_type":"export","__export_format":4,"__export_date":"2022-12-16T22:37:08.215Z","__export_source":"insomnia.desktop.app:v2022.6.0","resources":[{"_id":"req_dd6236dd708448aa99d65ecf1cc7d592","parentId":"fld_c6153aa7f6a74750a61083e5ebce7fdd","modified":1671230130609,"created":1669502522217,"url":"{{ _.restBaseUrl }}/users","name":"/users","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1669502522217,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_c6153aa7f6a74750a61083e5ebce7fdd","parentId":"wrk_031bdb6d7c8a40129ab36152ab8ec7c3","modified":1671221337647,"created":1669502518402,"name":"REST","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1671134801469,"_type":"request_group"},{"_id":"wrk_031bdb6d7c8a40129ab36152ab8ec7c3","parentId":null,"modified
@mkuchak
mkuchak / docker-wait-for-mysql-alt.sh
Last active April 29, 2022 12:15 — forked from valmayaki/docker-wait-for-mysql-alt.sh
Wait for Connection ready
#!/bin/sh
until docker-compose exec mysql mysql -h 127.0.0.1 -u $DB_USERNAME -p$DB_PASSWORD -D $DB_DATABASE --silent -e "show databases;"
do
echo "Waiting for database connection..."
sleep 5
done
@mkuchak
mkuchak / performance.js
Last active April 21, 2022 13:36
Measure performance of NanoID and Web Crypto API to generate unique identifiers
// run it on browser console
const { nanoid } = await import(
'https://cdnjs.cloudflare.com/ajax/libs/nanoid/3.3.2/nanoid.min.js'
)
const loops = 1_000_000
console.time('NanoID')
for (let i = 0; i < loops; i++) {
nanoid()
@mkuchak
mkuchak / Docker.md
Last active December 22, 2022 21:46
Manage Docker for development and production environment

Change DNS Docker

Create a /etc/docker/daemon.json file with this content:

{
  "dns": ["8.8.8.8", "8.8.4.4"]
}
@mkuchak
mkuchak / TypeScript.md
Last active September 30, 2022 17:58
Start simple TypeScript project with development environment and ESLint rules

Starting with TypeScript on new project

On terminal when init project:

npm init -y

npm i typescript ts-node-dev tsconfig-paths eslint eslint-plugin-simple-import-sort rimraf dotenv-cli -D

npx tsc --init --rootDir ./ --baseUrl ./ --outDir ./dist \
--strictNullChecks false --esModuleInterop --resolveJsonModule \
@mkuchak
mkuchak / Discord.md
Last active May 10, 2023 14:59
Unlock Discord resize window limit

1. Find settings

Windows: C:\Users\<your_user>\AppData\Roaming\discord\settings.json

Linux: /home/<your_user>/snap/discord/121/.config/discord/settings.json

If not was installed with snap use sudo find / -name settings.json to locate the file

2. Update settings.json

@mkuchak
mkuchak / GIT_COMMANDS.md
Last active September 23, 2021 19:59
Terminal Hyper and ZSH configuration with Git shortcuts bonus

Main commands

Command Action
git init Inicia nova linha do tempo
git branch Cria nova branch
git checkout master Navega entre as branches
git commit -am "description" Envia alterações realizadas
git merge Une branch ao branch ativo
git checkout -b Cria e navega até a nova branch