Skip to content

Instantly share code, notes, and snippets.

@lucasassisrosa
lucasassisrosa / node_modules_prune.sh
Created January 28, 2022 23:23
Remove All node_modules from a monorepo
find . -name "node_modules" -type d -prune | xargs du -chs
@lucasassisrosa
lucasassisrosa / commits_since_deploy_tag_monorepo.sh
Created January 28, 2022 23:30
View new commits since last deploy commit in monorepo packages
#!/bin/bash
# Print pretty list of commits since last deploy.
#
#
# Usage example:
#
# ./bin/commits_since_deploy.sh analytics-app c9bad41
#
# This will give you something like:
@lucasassisrosa
lucasassisrosa / docker-entrypoint.sh
Last active March 15, 2022 13:59
Docker Entrypoint sourcing .env file
#!/bin/sh
# source secrets and/or constants. This will export envs and populate process.env for Node in runtime
set -o allexport
SECRETS_FILE="/ci_folder/service.env"
set +o allexport
if [ -f "$SECRETS_FILE" ]; then
set -a
source "$SECRETS_FILE"
export CMS_HOST=${CMS_HOST}
@lucasassisrosa
lucasassisrosa / img_alt_long_text.html
Last active February 22, 2022 15:17
<img> "alt" attribute when it's a long text
<img
src="https://images.pexels.com/photos/8499628/pexels-photo-8499628.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500"
alt="Short description for image. Detailed description below."
aria-describedby="description-extended"
/>
<div id="description-extended">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
</div>
@lucasassisrosa
lucasassisrosa / vscode-extensions-list.sh
Last active March 16, 2022 18:51
VSCode Extensions
#!/bin/sh
# VSCode Extensions List with install command script
# OpenAPI (Swagger) Editor
code --install-extension 42Crunch.vscode-openapi
# ESLint
code --install-extension dbaeumer.vscode-eslint
# Git History
code --install-extension donjayamanne.githistory
@lucasassisrosa
lucasassisrosa / updateContentfulEntryFields.js
Created August 16, 2022 22:48
CMS Content Batch Update using Contentful Management API - Update target entries "Reference" Field to "Short Text" Field
const contentful = require('contentful-management');
const REFERENCE_FIELD = 'topic_ref';
const SHORT_TEXT_FIELD = 'topic';
const client = contentful.createClient({
accessToken: process.env.CONTENTFUL_MANAGEMENT_TOKEN,
});
client
@lucasassisrosa
lucasassisrosa / server.js
Last active September 28, 2022 21:54
Node.js plain simple Server
const http = require('http');
const fs = require('fs');
const requestListener = function (req, res) {
req.on('error', (err) => {
console.error(err);
res.statusCode = 400;
res.end('400: Bad Request');
return;
});
@lucasassisrosa
lucasassisrosa / gpg-setup.sh
Last active October 17, 2022 13:59
GPG Setup + Pinentry - MacOS
# set git global config to always sign commits
$ git config --global gpg.program gpg
$ git config --global commit.gpgsign true
# pinentry to read gpg passphrase from git user.signingKey
$ brew install pinentry-mac
# set pinentry-mac as the default program
$ echo "pinentry-program $(which pinentry-mac)" > ~/.gnupg/gpg-agent.conf
@lucasassisrosa
lucasassisrosa / international_pricing_pages_check.js
Last active June 21, 2023 14:21
Telnyx Elastic SIP International Pricing pages fetch all
// check all pricing pages built locally at the same time to stress test rate limiting
// run this script with node >= 18.x
Promise.allSettled(
[
"http://127.0.0.1:3000/pricing/elastic-sip/al",
"http://127.0.0.1:3000/pricing/elastic-sip/am",
"http://127.0.0.1:3000/pricing/elastic-sip/ao",
"http://127.0.0.1:3000/pricing/elastic-sip/ar",
"http://127.0.0.1:3000/pricing/elastic-sip/at",
"http://127.0.0.1:3000/pricing/elastic-sip/au",
@lucasassisrosa
lucasassisrosa / rename_files_ext_perl.sh
Last active January 19, 2024 12:07
Rename folder all files extensions
# transform all files to .md, including nested. Use -n to preview changes
rename -p -e 's/(\/.*)\.php/$1\.md/' **/*.php
rename -p -e 's/(\/.*)\.py/$1\.md/' **/*.py
rename -p -e 's/(\/.*)\.rb/$1\.md/' **/*.rb
rename -p -e 's/(\/.*)\.java/$1\.md/' **/*.java
rename -p -e 's/(\/.*)\.cs/$1\.md/' **/*.cs
# It outputs something like "'php/outbound_voice_profiles/outbound_voice_profiles/get.php' would be renamed to 'php/outbound_voice_profiles/outbound_voice_profiles/get.md'"