Skip to content

Instantly share code, notes, and snippets.

View neto-developer's full-sized avatar
🚀
Taking off

Neto, Aristides da Silva neto-developer

🚀
Taking off
View GitHub Profile
@neto-developer
neto-developer / libvips.md
Created June 18, 2024 19:21
Installing libvips from source and making it work

Installing libvips from source on Ubuntu 18.04 Bionic

wget https://github.com/libvips/libvips/releases/download/v8.8.2/vips-8.8.2.tar.gz
tar -xvf vips-8.8.2.tar.gz 
cd vips-8.8.2
./configure

Make sure image loading libraries are installed.

Docker - Certbot - Manual Wildcard Domain Certificate.md

Create a dir for mount in containers, and save letsencrypt folders

mkdir letsencrypt

Run a container and follow the instructions

docker run -it --rm -v "$PWD"/letsencrypt:/etc/letsencrypt certbot/certbot certonly --manual -d '*.domain.com'
@neto-developer
neto-developer / Disable PM2 Vizion feature to save IO and Memory Usage and avoid "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory".md
Last active June 3, 2024 19:32
Disable PM2 Vizion feature to save IO and Memory Usage and avoid "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory"

Disable PM2 Vizion feature to save IO and Memory Usage and avoid "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory"

A feature do pm2 chamada "vizion" tenta indexar o repositório do projeto de cada comando rodando. Em grandes repositórios e principalmente com um grande numero de processos rodando isso pode causar um grande consumo de memória e IO, o que impacta drasticamente a performance da maquina e dependendo da maquin, pode causar: "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory"

A seguir salvamos o estado do pm2 no arquivo ~/.pm2/dump.pm2, matamos o PM2 God Daemon e todos os processos que ele gerencia, alteramos o dumo.pm2 desativando a flag do "vizion" e ressucitamos o pm2 ao estado original.

@neto-developer
neto-developer / showHeadingTags.js
Created February 2, 2022 18:31
Show all heading tags on page
$('h1,h2,h3,h4,h5,h6').each(function(){
console.log($(this).prop("tagName") + ' - ' + $(this).text().trim());
$(this).html($(this).prop("tagName") + ' - ' + $(this).html());
});
@neto-developer
neto-developer / showDimensionsOfAllImagesOnPage.js
Created February 2, 2022 18:29
Show dimensions of all images on page
$('img').each(function(){
let t = $(this);
let url = `https://dummyimage.com/${Math.round(t.outerWidth())}x${Math.round(t.outerHeight())}/f0f0f0/999`;
console.log(`${Math.round(t.outerWidth())}x${Math.round(t.outerHeight() => ${t.attr('src')}`);
t.attr('src', url);
});
@neto-developer
neto-developer / autofill.js
Last active February 2, 2022 18:32
Preenchimento automatico de formulários
/**
* Tool to autofill some forms
*/
function randomiza(n) {
return Math.round(Math.random() * n);
}
function getRange(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
@neto-developer
neto-developer / gist:074ccc015e2f300a2cdce4b3d2336597
Created April 14, 2020 14:20
Filter a Apache Log in a Range of DateTime
Considering $4 is the position of DataTime on access_log file
cat /var/log/httpd/access_log | awk '$4 >= "[14/Apr/2020:09:50:00" && $4 < "[14/Apr/2020:10:15:00"'
Analyser:
https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-suggesters-phrase.html
Template:
POST /_template/template_produtos
{
"index_patterns": [
"produto*"
],
"settings": {