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 / blur-vscode-panels.js
Last active October 23, 2020 18:10
blur visible Visual Studio Code panels (tested on VSC v1.50.1)
// go to Help > Toggle Developer Tools
const toogleInlineStyle = (el, styleProp, styleValue) =>
!!el.style[styleProp] ? (el.style[styleProp]='') : (el.style[styleProp]=styleValue)
const blur = () =>
document.querySelectorAll('[class="monaco-scrollable-element editor-scrollable vs-dark"]')
.forEach(el => toogleInlineStyle(el, 'filter', 'blur(3px)'))
@micalevisk
micalevisk / README.md
Last active March 2, 2021 20:01
https://www.octotree.io (free version) dark style for GitHub dark mode. (Firefox)
@micalevisk
micalevisk / timeout.interceptor.spec.ts
Last active August 7, 2022 01:27
An attempt to unit test a timeout NestJS (v8) interceptor.
import { createMock } from '@golevelup/ts-jest';
import { CallHandler, ExecutionContext, RequestTimeoutException } from '@nestjs/common';
import { throwError } from 'rxjs';
import { marbles } from 'rxjs-marbles/jest';
import { TimeoutInterceptor } from '@/api/interceptors/timeout.interceptor';
describe('TimeoutInterceptor', () => {
const TIMEOUT = TimeoutInterceptor.TIMEOUT_RESPONSE_TIME_MS;
//
@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
@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 / __README.md
Last active January 25, 2025 23:14
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 / _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 / 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 / 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 ; }