Skip to content

Instantly share code, notes, and snippets.

View micalevisk's full-sized avatar
🇧🇷
HTTP 499 ~ Adding bugs to programs.‏‏‎

Micael Levi L. Cavalcante micalevisk

🇧🇷
HTTP 499 ~ Adding bugs to programs.‏‏‎
View GitHub Profile
@micalevisk
micalevisk / _nodejs web frameworks.md
Last active June 25, 2024 16:46
Comparing the popularity of few Node.js web frameworks.
@micalevisk
micalevisk / Dockerfile
Last active August 1, 2024 16:17
Production Dockerfile example for NestJS projects.
## ===========================================================> The common stage
FROM node:16.14 AS base
ENV NODE_ENV=production
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
## Remove unnecessary files from `node_modules` directory
@micalevisk
micalevisk / make-autocannon-command.mjs
Created March 20, 2022 19:29
Generates `autocannon` (https://github.com/mcollina/autocannon) command from user's answers
#!/usr/bin/env -S npx zx
$.shell = '/usr/bin/bash'
$.verbose = process.env.NODE_ENV === 'development'
// ========================================================================== //
function quitWitError(errorMsg) {
console.error( chalk.bold.red(errorMsg) )
process.exit(1)
}
function assertNotEmpty(val, errorMsg) {
/* version: 03-14-2022 */
.swagger-ui .info .title, .swagger-ui a.nostyle, .swagger-ui .parameter__name, .swagger-ui .parameter__type, .swagger-ui .parameter__deprecated, .swagger-ui .parameter__in, .swagger-ui table thead tr th, .swagger-ui .response-col_status, .swagger-ui table thead tr td, .swagger-ui .opblock .opblock-section-header h4, .swagger-ui label, .swagger-ui .tab li, .swagger-ui .opblock .opblock-section-header label, .swagger-ui .btn {
color: #CCCCCC;
}
body, .swagger-ui .info .title, .swagger-ui .scheme-container, .swagger-ui select {
background-color: #222;
color: #CCC;
}
.swagger-ui .opblock .opblock-section-header {
@micalevisk
micalevisk / show_last_modified_dates.sh
Last active July 23, 2023 23:12
Display the last modified date of every package on package.json dependencies list using npm-view (https://docs.npmjs.com/cli/v7/commands/npm-view)
#!/bin/bash
## (c) 2022 Micael Levi L. C.
## This script requires:
## - npm (https://nodejs.org)
## - jq (https://stedolan.github.io/jq)
file="${1:-./package.json}"
[ -r "$file" ] || { echo "The file $file is not readable" ; exit 1 ; }
@micalevisk
micalevisk / redis-raw-generator.js
Last active January 17, 2022 01:26
NodeJS slim function to generate a string that follows the Redis protocol (RESP) from a command name and its args. Inspired by https://redis.io/topics/mass-insert
// https://redis.io/topics/protocol
/**
* @param {string} str
* @returns {number}
* (c) https://stackoverflow.com/a/27377098/5290447
*/
function getBinarySize(str) {
return Buffer.byteLength(str, 'utf8');
}
@micalevisk
micalevisk / _README_.md
Last active October 16, 2024 23:41
A non-exhaustive list of patterns to help hidding all RC (run commands) and configuration files of Node.js projects on VSCode!
@micalevisk
micalevisk / __README.md
Last active December 25, 2023 18:18
My general purposes GitHub CLI (gh https://cli.github.com) aliases and extensions stuff
chmod +x *.sh

./set-aliases.sh
./install-exts.sh

mkdir -p ~/.config/prs/ && mv gh-prs--config.yml ~/.config/prs/config.yml
@micalevisk
micalevisk / algorithms_good_to_know.md
Last active December 31, 2021 03:00
General purporses algorithms implemented in JavaScript.

maximum subarray sum

Kadane's algorithm

code
/**
 * @param {number[]} arr - Array com valores arbitrários.
@micalevisk
micalevisk / bench.sh
Created September 14, 2021 16:56
Comparing Nodejs HTTP server with 'Keep-Alive' header vs without it
#!/bin/bash
URL="http://localhost:3001"
// https://github.com/mcollina/autocannon
autocannon "$URL" \
--connections 100 \
--timeout 20 \
--pipelining 1 \
--amount 2000