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 / renameKeys.js
Created October 5, 2022 16:33
A function that catches a JavaScript object and rename the keys you want
const obj = {
name: 'Player',
team: 'Barcelona',
role: 'Raphinha'
}
/**
* Rename the a key of an object
* @param {Object} object with the keys to be renamed
* @param {Object} keys an array [oldkey, newkey], you can send as many pairs as you wish
@samuelastech
samuelastech / opencv_from_base64.py
Created October 7, 2022 19:09 — forked from HoweChen/opencv_from_base64.py
[opencv_from_base64]read image from opencv with base64 encoding #OpenCV
import cv2
import numpy as np
import base64
image = "" # raw data with base64 encoding
decoded_data = base64.b64decode(image)
np_data = np.fromstring(decoded_data,np.uint8)
img = cv2.imdecode(np_data,cv2.IMREAD_UNCHANGED)
cv2.imshow("test", img)
cv2.waitKey(0)
@samuelastech
samuelastech / pipenv_cheat_sheet.md
Created October 20, 2022 14:54 — forked from bradtraversy/pipenv_cheat_sheet.md
Pipenv cheat sheet for common commands

Pipenv Cheat Sheet

Install pipenv

pip3 install pipenv

Activate

pipenv shell
@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
@samuelastech
samuelastech / settings.json
Last active October 31, 2022 23:42 — forked from diego3g/settings.json
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 / 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 / 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 / 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 / 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 / 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/"
)