Skip to content

Instantly share code, notes, and snippets.

@nehasriva
nehasriva / sentry-pii-wrapper.py
Created April 19, 2026 03:44
Sentry before_send hook for recursive PII scrubbing
"""
Sentry's built-in scrubber only masks keys it already knows about. Custom
fields, exception messages, and POST body data regularly leak emails, tokens,
and other PII. This hook scrubs at the event level before anything leaves
the process.
Register with:
sentry_sdk.init(before_send=before_send, before_breadcrumb=before_breadcrumb)
"""
import re
@nehasriva
nehasriva / grafana-tempo-provisioning.yaml
Created April 19, 2026 03:39
Grafana datasource provisioning: Tempo + Loki with trace-to-log linking
# Grafana datasource provisioning: Tempo + Loki with trace-to-log linking.
#
# Drop in grafana/provisioning/datasources/ — Grafana loads it on startup.
#
# The `tracesToLogs.derivedFields` block is what makes the "jump from trace
# to logs" button appear in the Tempo panel. Without it you can query Tempo
# and Loki separately but there's no clickable link between a trace span
# and its correlated log lines. The `filterByTraceID: true` appends
# ?query={traceID="..."} automatically so you land on the right log lines.
#
@nehasriva
nehasriva / k8s-aws-ssm-helpers.sh
Created April 19, 2026 03:36
AWS/EKS helpers, SSM exec without SSH, multi-region Lambda audit
# ---------------------------------------------------------------------------
# ssm_to_ec2
# ---------------------------------------------------------------------------
ssm_to_ec2() {
local name="${1:?usage: ssm_to_ec2 <Name-tag> [aws-profile]}"
local profile="${2:-default}"
local instance_id
instance_id=$(aws ec2 describe-instances \
--profile "$profile" \
@nehasriva
nehasriva / k8s-deployment-probes.yaml
Created April 19, 2026 03:33
Kubernetes deployment: rolling update strategy + probes & resource limits
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
namespace: production
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
@nehasriva
nehasriva / slack-kb-config.yaml
Created April 19, 2026 03:30
Slack-to-Knowledge-Base configuration
# Drafts are posted to `review_channel` for a human to approve before
# they land in the actual knowledge base.
#
# Agent script: autodoc-kb-updater.script.md
# Requires: Slack MCP server, Claude
# ---------------------------------------------------------------------------
# Channels to monitor
# ---------------------------------------------------------------------------
channels:
@nehasriva
nehasriva / zsh-stopwatch.sh
Created April 19, 2026 03:27
Stopwatch in zsh
#!/usr/bin/env zsh
# source from ~/.zshrc
# Stopwatch (Ctrl-C to stop) — handles both GNU and BSD date
timer() {
local start=$(date +%s)
echo "Timer started. Ctrl-C to stop."
while true; do
printf "\r%s" "$(date -u -d@$(($(date +%s)-start)) +%H:%M:%S 2>/dev/null \
|| date -u -r$(($(date +%s)-start)) +%H:%M:%S)"
@nehasriva
nehasriva / dx-git-hooks.sh
Created April 19, 2026 03:25
Developer experience toolkit with git hooks and shell functions
#!/usr/bin/env bash
#
# Three patterns that save time every day:
#
# git-summary : one-line branch status (ahead/behind, staged, recent commits)
# pre-push hook : lint only the files that changed — fast enough not to hate
# commit-msg hook : auto-prepend ticket number extracted from branch name
#
# Setup:
# source this file from ~/.zshrc for git-summary
@nehasriva
nehasriva / circleci-dynamic-matrix.yml
Created April 19, 2026 03:23
CircleCI Inject timing-based test splitting into an orb job via pre-steps
# Tip: Injecting `circleci tests split` into a prebuilt orb job without
# forking the orb. The split file list lands in $BASH_ENV before the orb's
# own test command runs.
# Requires: circleci/continuation@1 (Phase 1), circleci/node@5 (Phase 2)
version: 2.1
parameters:
run-web: { type: boolean, default: false }
run-ios: { type: boolean, default: false }
@nehasriva
nehasriva / github-actions-monorepo.yml
Created April 19, 2026 02:34
GitHub Actions: monorepo path filtering + environment-gated deploys
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
# Detect which workspaces changed
changes:
@nehasriva
nehasriva / ics-calendar-deeplinks.ts
Created April 19, 2026 02:01
Generate .ics events and Google Calendar deep links from form input