Skip to content

Instantly share code, notes, and snippets.

View faustoct1's full-sized avatar
🌍
Indie hacker

Fausto Torres faustoct1

🌍
Indie hacker
View GitHub Profile
@faustoct1
faustoct1 / helperstatic.js
Created August 6, 2022 19:50
Classe helper com funções estáticas em js
class Helper {
static getHelloWorldSync = () => {
return "Hello World Sync"
}
static getHelloWorldAsync = async () => {
return "Hello World Async"
}
}
@faustoct1
faustoct1 / fila-listaligada.js
Created July 30, 2022 21:13
Implementando fila com lista ligada em javascript
class ListLigada{
obj = {
anterior: null,
proximo: null,
valor: null
}
calda = null
cabeca = null
@faustoct1
faustoct1 / app.js
Created July 29, 2022 15:55
Passar parâmetro para um require
module.exports = (params) => {
const app = {
print: async () => {
console.log(params)
}
}
return app
}
@faustoct1
faustoct1 / listaligada.js
Created July 27, 2022 19:31
Lista ligada em javascript
class ListLigada{
obj = {
anterior: null,
proximo: null,
valor: null
}
calda = null
cabeca = null
@faustoct1
faustoct1 / copy.c
Created July 25, 2022 13:40
Diferença entre cópia e referência de variáveis em C
/*
Compilar: gcc -o copy copy.c
Executar: ./copy
*/
#import <stdio.h>
void naoAlteraValor(int x){
x=0;
}
@faustoct1
faustoct1 / array.c
Last active July 25, 2022 12:49
Passando array com ponteiro por referência para função em C
/*
Compilar: gcc -o array array.c
Executar: ./array
*/
#include <stdio.h>
void preencheArray(int* array){
for(int i=0;i<5;i++){
array[i] = i+1;
}
@faustoct1
faustoct1 / hello.c
Created July 24, 2022 06:27
Hello World em 5 linguagens diferentes
/*
Compilar: gcc -o hello hello.c
Executar: ./hello
*/
#include <stdio.h>
int main() {
printf("Hello World\n");
return 0;
}
@faustoct1
faustoct1 / index.js
Created July 20, 2022 03:33
test-require-import-modules
const {funcao1,funcao2,funcao3} = require('./modules')
exports.test = test = async () => {
await funcao1()
await funcao2()
await funcao3()
}
(async ()=>{ test() })() //chama test
@faustoct1
faustoct1 / index.js
Created July 17, 2022 15:23
Exportar e importar múltiplas funções no mesmo arquivo js
const {hello,espaco,world,helloworld} = require('./modulos')
const test = () => {
console.log(`${hello()}${espaco()}${world()}`)
console.log(`${helloworld()}`)
}
(async ()=>{test()})()
@faustoct1
faustoct1 / oobasico.js
Created July 16, 2022 21:31
Básico de programação orientada a objeto em javascript
class Abstrata {
print = () => {
throw "método abstrato precisa de implementação"
}
}
class Concreta1 extends Abstrata {
print = () => {
console.log('Classe concreta1 que estende classe abstrata')
}