Skip to content

Instantly share code, notes, and snippets.

View davidalves1's full-sized avatar

David Alves de Souza davidalves1

View GitHub Profile
@davidalves1
davidalves1 / list.sh
Last active August 21, 2023 21:38
Loop for all directories
path="/home/user"
for item in `ls`;
do
dir="$path/$item"
if [ -d $dir ] # check if it's a directory
then
cd $dir
pwd
cd ..
@davidalves1
davidalves1 / app.ts
Last active August 2, 2023 14:32
Observer Pattern
interface Observer {
update: (s: Subject) => void
}
class Subject {
private observers: Observer[] = [];
addObserver(ob: Observer) {
if (!this.observers.some(obs => obs === ob)) {
console.log('ADDING:', ob);
@davidalves1
davidalves1 / exemplo-c4model-in-plamtuml.puml
Last active May 4, 2023 23:26
Exemplo de diagrama C4 model utilizando PlantUML
@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
!define FONTAWESOME https://raw.githubusercontent.com/tupadr3/plantuml-icon-font-sprites/master/font-awesome-5
!include FONTAWESOME/firefox_browser.puml
!include FONTAWESOME/aws.puml
Person(user, "Usuário", "Responável por realizar o cadastro dos visitantes do museu")
System_Boundary(c1, "Contexto do sistema de cadastro de visitantes do museu") {
System(web, "Sistema WEB para cadastro de visitantes", "Sistema web responsável por realizar o cadastro dos visitantes ao museu", $sprite="firefox_browser")
@davidalves1
davidalves1 / using-uuid-as-pk.md
Created November 5, 2021 00:09 — forked from rponte/using-uuid-as-pk.md
Não use UUID como PK nas tabelas do seu banco de dados

Pretende usar UUID como PK em vez de Int/BigInt no seu banco de dados? Pense novamente...

TL;TD

Não use UUID como PK nas tabelas do seu banco de dados.

Um pouco mais de detalhes

interface Accumulator {
[key: string]: any
}
interface CurrentItem {
[index: number]: string
}
const convertToSnakeCase = (key: string) => key.replace(/[A-Z]/g, '_$&')
.toLowerCase()
@davidalves1
davidalves1 / settings.json
Last active March 23, 2024 11:47
My VSCode configuration
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.fontFamily": "'Fira Code', 'monospace', monospace, 'Droid Sans Fallback'",
"editor.fontLigatures": true,
"editor.formatOnSave": true,
"editor.suggestSelection": "first",
"editor.rulers": [100],
"explorer.compactFolders": false,
"files.exclude": {
"**/.classpath": true,
function createStore({ state, mutations }) {
return {
state: Vue.observable(state),
commit(key, ...args) {
mutations[key](state, ...args)
}
}
}
const store = createStore({
state: { count: 0 },
@davidalves1
davidalves1 / php.json
Last active December 13, 2019 19:06
PHP/Laravel snippets to VSCode
{
"Create public function": {
"prefix": "pubf",
"body": [
"public function $1($2)",
"{",
"\t$3",
"}"
],
"description": "Public function block"
@davidalves1
davidalves1 / reset.css
Last active May 30, 2023 22:22
A simple css reset to use on most HTML projects
*, html, body {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.5%; /* O font-size base passa a ser múltiplo de 10px, ou seja, 1rem === 10px*/
}
@davidalves1
davidalves1 / docker-compose.yml
Created November 15, 2019 15:58
Initial docker-compose configuration to run MariaDB
version: '3'
services:
awesome-db:
image: mariadb:10.3
command: "--character-set-server=utf8 --collation-server=utf8_general_ci --innodb-use-native-aio=0"
restart: "no"
ports:
- "3306"
volumes: