Skip to content

Instantly share code, notes, and snippets.

View sandromello's full-sized avatar

Sandro Mello sandromello

View GitHub Profile
@sandromello
sandromello / postgres-spec.yml
Last active August 14, 2025 17:56
Postgres Spec
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
@sandromello
sandromello / hoop-gateway-install.sh
Last active July 30, 2025 19:38
hoop-gateway-install.sh
#!/bin/bash
PGPASSWORD=$(LC_ALL=C tr -dc A-Za-z0-9_ < /dev/urandom | head -c 43 | xargs)
set -eo pipefail
function echo_normal() {
echo $'\e[1G----->' "$*"
}
@sandromello
sandromello / test-mongo-script.md
Last active July 2, 2025 12:40
Test Mongo Script

Add test Mongo Scripts into the agent

Open a bash session to the agent and add the following scripts to the /tmp folder

hoop connect bash

cat - > /tmp/mongo1 <<'EOF'
#!/bin/bash
@sandromello
sandromello / wezterm.lua
Created April 2, 2025 17:05
Wezterm Config
local wezterm = require 'wezterm'
local projects = require 'projects'
local act = wezterm.action
local config = {}
config.window_frame = {
-- Berkeley Mono for me again, though an idea could be to try a
-- serif font here instead of monospace for a nicer look?
font = wezterm.font({ family = 'Jetbrains Mono', weight = 'Bold' }),
font_size = 11,
@sandromello
sandromello / projects.lua
Created September 4, 2024 12:49
wezterm config
-- $HOME/.config/wezterm/projects.lua
local wezterm = require 'wezterm'
local module = {}
local function project_dirs()
return {
'~/work/personal/joi2',
'~/work/hoopdev/hoop',
'~/work/hoopdev/documentation',
-- ... keep going, list all your projects
@sandromello
sandromello / lb-controller.tf
Created July 31, 2024 17:47
lb-controller.tf
provider "aws" {
region = local.region
}
data "terraform_remote_state" "eks" {
backend = "s3"
config = {
bucket = "tfstate"
key = "infra/eks"
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
spec:
selector:
matchLabels:
app: postgres
strategy:
type: Recreate
@sandromello
sandromello / run_system_agent.sh
Last active July 11, 2024 18:41
System Agent
#!/bin/bash
SECRET_KEY=xagt-$(LC_ALL=C tr -dc A-Za-z0-9_ < /dev/urandom | head -c 43 | xargs)
set -eo pipefail
SECRET_KEY_HASH=$(echo -n $SECRET_KEY | sha256sum |awk {'print $1'})
psql -v ON_ERROR_STOP=1 "$POSTGRES_DB_URI" <<EOF
BEGIN;
DELETE FROM agents WHERE name = 'system';
INSERT INTO agents (id, org_id, name, mode, key_hash, status)
VALUES ('9A7C5A60-C910-4AD1-8A70-997E37123894', (SELECT id from private.orgs), 'system', 'standard', '$SECRET_KEY_HASH', 'DISCONNECTED')
ON CONFLICT DO NOTHING;
mkdir -p /opt/hoop/migrations
curl https://hoopartifacts.s3.amazonaws.com/release/1.22.22/hoopgateway_1.22.22-Linux_amd64.tar.gz -o hoopgateway.tar.gz && \
rm -rf /opt/hoop/migrations
tar --extract --file hoopgateway.tar.gz -C / --strip 1 && rm -f hoopgateway.tar.gz
chown -R root: /opt/hoop
mkdir -p /etc/hoopgateway.d
cat - > /etc/hoopgateway.d/config <<EOF
PLUGIN_AUDIT_PATH=/opt/hoop/sessions
PLUGIN_INDEX_PATH=/opt/hoop/sessions/indexes
mkdir -p /opt/hoop/pgdata
PGUSER=hoopdevuser
PGDATABASE=hoopdevdemo
PGPASSWORD="1a2b3c4d"
docker run -p 5432:5432 -d --rm --name hoopdevpg \
-e POSTGRES_USER=$PGUSER \
-e POSTGRES_DB=$PGDATABASE \
-e POSTGRES_PASSWORD=$PGPASSWORD \
-e PGUSER=$PGUSER \