Skip to content

Instantly share code, notes, and snippets.

View eduardo-matos's full-sized avatar

Eduardo Matos eduardo-matos

View GitHub Profile
@eduardo-matos
eduardo-matos / playbook.md
Last active February 21, 2026 14:32
Example of incident response playbook for a software engineering team.

Phase 1: Identification & Triage

The goal here is to determine if the "blip" is a genuine emergency and how many people it’s affecting.

  • Declare the Incident: If a service is down, data is corrupted, or security is breached, officially declare an incident in your communication channel (e.g., Slack/Teams).
  • Assign Key Roles:
    • Incident Commander (IC): Leads the response, makes final decisions, and keeps the team focused.
    • Communications Lead: Handles updates to stakeholders and status pages.
    • Operations/SME: The engineers actually digging into the code or infrastructure.
@eduardo-matos
eduardo-matos / agents.docs.md
Created February 18, 2026 11:51
Example of rules for agents to document code

Documentation rules

Principles

  • Document intent, decisions, and contracts.
  • Do not document what is obvious from code.
  • Optimize for future maintainers.

Must Document

@eduardo-matos
eduardo-matos / agents.testing.md
Last active February 18, 2026 11:06
Example section for tests in agents.md

Automated Testing Rules

Core Principles

  • Tests protect behavior, not coverage.
  • Prefer high-signal tests.
  • Tests must fail only on real regressions.
  • Test observable behavior, never implementation details.

When Tests Are Required

@eduardo-matos
eduardo-matos / gaussian.js
Created June 18, 2021 17:09
Gaussian random value
// Source: https://stackoverflow.com/a/49434653/650656
function randn_bm(min, max, skew) {
let u = 0, v = 0;
while(u === 0) u = Math.random() //Converting [0,1) to (0,1)
while(v === 0) v = Math.random()
let num = Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v )
num = num / 10.0 + 0.5 // Translate to 0 -> 1
if (num > 1 || num < 0)
@eduardo-matos
eduardo-matos / rabbit-graceful-shutdown.js
Last active July 8, 2024 15:40
RabbitMQ graceful shutdown in NodeJS
const amqp = require('amqplib');
const uuid = require('uuid')
const CONSUMER_TAG = uuid.v4();
const QUEUE_NAME = 'my_queue'
async function main() {
const conn = await amqp.connect('amqp://guest:guest@localhost:5672/%2F');
const channel = await conn.createChannel();
await channel.assertQueue(QUEUE_NAME);
@eduardo-matos
eduardo-matos / script.sh
Created April 19, 2019 18:25
Script to run Rancher 2.0
docker run -d --restart=unless-stopped \
-p 80:80 -p 443:443 \
-v /opt/rancher:/var/lib/rancher \
rancher/rancher:latest
@eduardo-matos
eduardo-matos / install.sh
Created April 10, 2019 12:16
Install Docker on new Ubuntu 18.04 vm
apt update
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt update
apt-get install -y docker-ce
@eduardo-matos
eduardo-matos / README.md
Last active December 7, 2018 20:23
Workshop de NodeJS + Promises

NodeJS

Node é single threaded, istoé, ele é incapaz de executar duas coisas ao mesmo tempo, com exceção de operaçes de IO.

Exemplos de operação não bloqueantes: Acesso à rede, acesso à arquivos etc.
Exemplos de açes bloqueantes: Loop num array, cálculos complexos etc.

Em node, o padrão é toda função assíncrona ter uma versão síncrona, por exemplo fs.readFile e fs.readFileSync.
As verses síncronas são úteis para aplicações que não dependem de concorrência, como scripts e programas de linha de comando por exemplo.
Via de regra usamos a versão assíncrona. Em uma API, por exemplo, qualquer operação bloqueante impede que novas requisiçes sejam processadas pelo servidor, por isso é importante sempre fazer chamadas não bloqueantes.

@eduardo-matos
eduardo-matos / .md
Last active April 17, 2018 11:40
Git direto da trincheira

Git direto da trincheira

Guardar modificações sem comitar usando stash

Desfazer erro em commit específico

Recuperar código removido

  1. Ver histórico de modificações
  2. Ver modificações em arquivo específico
@eduardo-matos
eduardo-matos / pre-commit.rb
Last active October 5, 2020 13:58
Don't commit ipdb, debugger, console, and print statements.
#!/usr/bin/env ruby
FORBIDDEN = [
/\bdebugger\b/,
/\bprint\b/,
/\bconsole\.*\b/,
/\bipdb\b/,
/\b\.only\b/,
]