Skip to content

Instantly share code, notes, and snippets.

View x4b1's full-sized avatar
🔥
Breaking things

Xabi x4b1

🔥
Breaking things
View GitHub Profile
@x4b1
x4b1 / main.go
Last active January 3, 2024 07:21
festak downloader
package main
import (
"context"
"fmt"
"io"
"log"
"net/http"
"os"
"path/filepath"
@x4b1
x4b1 / close.sql
Created January 19, 2022 07:58
close all pg connections
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'TARGET_DB' -- ← change this to your DB
AND pid <> pg_backend_pid();
@x4b1
x4b1 / ro.sql
Created November 19, 2021 11:18
postgres user read only permissions
-- Create ro user
CREATE USER ro_user WITH PASSWORD 'secret_password';
-- Give access to database
GRANT CONNECT ON DATABASE database_name TO ro_user;
-- Give access to schema
GRANT USAGE ON SCHEMA schema_name TO ro_user;
-- Allow select to all tables
GRANT SELECT ON ALL TABLES IN SCHEMA schema_name TO ro_user;
-- Allow Select for future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT SELECT ON TABLES TO ro_user;

Keybase proof

I hereby claim:

  • I am xabi93 on github.
  • I am xabi93 (https://keybase.io/xabi93) on keybase.
  • I have a public key ASDZw02Y7SLLyRgHAeqU2P8RIQVT83mwkTM_ltEOHZUIMAo

To claim this, I am signing this object: