Skip to content

Instantly share code, notes, and snippets.

View rdsedmundo's full-sized avatar

Edmundo Santos rdsedmundo

  • Belo Horizonte, Brazil
View GitHub Profile
@rdsedmundo
rdsedmundo / react_chaos.md
Created June 16, 2024 15:36
The chaos of React in medium to large web apps: has anyone experienced it differently?

I have been working with React codebases exclusively since 2016, and the quality of the code I've inherited has always been atrocious when dealing with medium to large apps. If you're just making a todo list, sure, it's all fun and games, but I'm yet to see a real commercial or enterprise-grade React app that doesn't become a disorganized mess. There has not been a single exception. I kid you not, I worked on a few AngularJS projects back in the day that were easier to manage as they grew compared to most React ones, as many things that other frameworks handle for you under the hood or make straightforward to handle manually will require boilerplate in React, and because React model is "open" and not standardized, most developers won't do it as the React team intended compared with what the docs suggest.

As a rough estimate, I've probably worked with 50 different engineers (mostly senior) doing React code across 6-7 companies. I would estimate that at most, 5-10 of them truly knew how React worked and how to

@rdsedmundo
rdsedmundo / console.sql
Created February 14, 2024 08:24
Datagrip bug
DROP TABLE IF EXISTS datagrip_bug;
CREATE TABLE datagrip_bug
(
id UUID PRIMARY KEY,
name TEXT NOT NULL,
created_at TIMESTAMPTZ
);
INSERT INTO datagrip_bug (id, name)
@rdsedmundo
rdsedmundo / cloudtrail.sh
Last active April 26, 2022 17:56
cloudtrail
# https://aws.amazon.com/premiumsupport/knowledge-center/troubleshoot-iam-permission-errors/
( echo "Time,Identity ARN,Event ID,Service,Action,Error,Message";
aws cloudtrail lookup-events --start-time "2020-01-01T00:00:00Z" --end-time "2020-01-01T23:59:59Z" --query "Events[*].CloudTrailEvent" --output text \
| jq -r ". | select(.userIdentity.arn == \"your-arn\" and .eventType == \"AwsApiCall\" and .errorCode != null
and (.errorCode | ascii_downcase | (contains(\"accessdenied\") or contains(\"unauthorized\"))))
| [.eventTime, .userIdentity.arn, .eventID, .eventSource, .eventName, .errorCode, .errorMessage] | @csv"
) | column -t -s'",'
@rdsedmundo
rdsedmundo / servicesPerAwsRegion.js
Created May 11, 2021 09:05
Compare services available on each AWS region
// https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/
(() => {
const servicesAvailableOnRegion = (region) => Array.from(document.querySelectorAll(`[data-region="${region}"] [data-plc-offer-id]`)).map(node => node.querySelector('a').innerText);
const regions = Array.from(document.querySelectorAll('[data-region]')).map(node => node.getAttribute('data-region'));
const spr = regions.reduce((acc, region) => ({...acc, [region]: servicesAvailableOnRegion(region)}), {});
console.log(spr['us-east-1'].filter(service => !spr['us-east-2'].includes(service)));
})();
@rdsedmundo
rdsedmundo / collapse_pr.js
Last active June 12, 2022 02:19
Collapse all files in Pull Request review
document.querySelectorAll('.file-info > button:first-child[aria-expanded="true"]').forEach(node => node.click());
@rdsedmundo
rdsedmundo / gist:65c6ef2e75dfb01cebed806891623fa9
Created January 20, 2021 13:59
Get IAM permissions from CloudTrail logs
const _ = require('lodash');
const devHistory = require('../event_history_dev.json');
const prodHistory = require('../event_history_prod.json');
(async () => {
const events = [...devHistory.Records, ...prodHistory.Records];
const policiesByService = {};
for (const event of events) {
brew unlink yarn
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/aacaa70e8931b2b005cb8f70703b48604f4a8d2a/Formula/yarn.rb
brew switch yarn 1.19.1
ssh -L 9200:url.com:443 -i ~/bastion.pem ec2-user@ip
@rdsedmundo
rdsedmundo / deleteAllLambdaLayers.ts
Created July 7, 2020 20:59
Deletes all lambda layers and their versions
import { Lambda } from 'aws-sdk';
const lambda = new Lambda({ region: 'us-east-1' });
async function run() {
const { Layers: layers } = await lambda.listLayers().promise();
if (!layers) {
console.log('No layers to delete.');
brew unlink yarn
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/aacaa70e8931b2b005cb8f70703b48604f4a8d2a/Formula/yarn.rb
brew switch yarn 1.19.1