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 / malloc.c
Last active August 9, 2022 23:47
Alocar dinamicamente um array com malloc em C
#include <stdio.h>
#include <stdlib.h>
int main(){
int size=5,*array;
array=(int*)malloc(size * sizeof(int));
for(int i=0;i<size;i++){
array[i] = i;
}
for(int i=0;i<size;i++){
printf("dobro de %d é %d\n",i,array[i]*2);
@faustoct1
faustoct1 / urlsearchparams.js
Last active August 8, 2022 04:00
Obter url query string em javascript
const test = async () => {
const url = new URL('https://example.com?foo=1&bar=2');
const params = new URLSearchParams(url.search);
console.log(params.get('foo'))
console.log(params.get('bar'))
const entries = params.entries()
for (const item of entries) {
@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