Skip to content

Instantly share code, notes, and snippets.

View samuelastech's full-sized avatar
🎯
Focusing

Samuel A. Souza samuelastech

🎯
Focusing
View GitHub Profile
@samuelastech
samuelastech / server.go
Created September 25, 2024 20:55
Simple HTTP server with Go
package main
import (
"fmt"
"io"
"log"
"net/http"
)
func main() {
@samuelastech
samuelastech / tsconfig.json
Last active July 17, 2024 15:30
A TypeScript config
{
"compilerOptions": {
"outDir": "dist/app",
"target": "ES6",
"noEmitOnError": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"removeComments": true,
"strictNullChecks": true,
"emitDecoratorMetadata": true,
@samuelastech
samuelastech / script.js
Last active April 4, 2023 12:19
A script that cleans up OCI `products.json`
import { createReadStream, createWriteStream, writeFile } from 'node:fs';
import { Transform, Writable } from 'node:stream';
import JSONStream from 'JSONStream';
import axios from 'axios';
// const readStream = createReadStream('./products.json', { encoding: 'utf8' });
let jsonString = '';
const url = 'https://apexapps.oracle.com/pls/apex/cetools/api/v1/products/?currencyCode=BRL';
/**
@samuelastech
samuelastech / index.sh
Created February 26, 2023 02:31
Open up chrome tabs from CLI
#!/bin/bash
webpages=(
"https://dictionary.cambridge.org/dictionary/"
"https://www.oxfordlearnersdictionaries.com/us/"
"https://context.reverso.net/traducao/"
"https://synonyms.reverso.net/synonym/"
"https://tophonetics.com/"
"https://translate.google.com/"
)
@samuelastech
samuelastech / package.json
Created January 31, 2023 14:35
How to monitor Node.js application using Climen and Autocannon
// The "-r" flag allows you to preload a module when running Node, see https://www.stephenlewis.me/blog/node-dash-r
"scripts": {
"start": "CLIMEM=8999 node -r climem index.js",
"climem": "npx climem 8999",
"test": "npx autocannon -c 100 -d 30 -p 10 http://localhost:3000"
}
@samuelastech
samuelastech / ErroCustom.ts
Created January 2, 2023 19:04
Handling errors in REST APIs
export default class ErrorCustom {
constructor(public message: string, public code: number){
this.message = message
this.code = code
}
}
@samuelastech
samuelastech / promisseAll.js
Created December 28, 2022 23:21
Concurrence instead of synchronously
// Wrong away
const poolCountResponse = await api.get('http://localhost:3333/pools/count')
const guessCountResponse = await api.get('http://localhost:3333/guesses/count')
// Correct way
const [poolCountResponse, guessCountResponse] = await Promise.all([
api.get('http://localhost:3333/pools/count'),
api.get('http://localhost:3333/guesses/count')
])
@samuelastech
samuelastech / multi-thread.js
Created December 14, 2022 18:22 — forked from ngot/multi-thread.js
V8 Thread Demo
start(() => {
while(true)
{
print("a");
sleep(1000);
}
})
while(true)
{
@samuelastech
samuelastech / settings.json
Last active October 31, 2022 23:42 — forked from diego3g/NODE.md
VSCode Settings (Updated)
{
"emmet.syntaxProfiles" : {
"javascript" : "jsx"
},
"workbench.startupEditor" : "newUntitledFile",
"editor.fontSize" : 16,
"javascript.suggest.autoImports" : true,
"javascript.updateImportsOnFileMove.enabled" : "always",
"editor.rulers" : [
80,
@samuelastech
samuelastech / CTR-date-change.js
Created October 21, 2022 13:43
A very simple script to change the date of CTR document
/* The date you wanna change */
const date = '06/10/22'
const register = document.querySelector('#lb_DtRegistro')
const sent = document.querySelector('#lb_DtEnvio')
const destiny = document.querySelector('#lb_DtDestino')
register.innerText = date
sent.innerText = date
destiny.innerText = date