Skip to content

Instantly share code, notes, and snippets.

View j33ty's full-sized avatar
💭
🖥 🏕

radhe j33ty

💭
🖥 🏕
View GitHub Profile
@j33ty
j33ty / drop-all-schemas.sql
Created July 9, 2024 22:48
Drop all postgresql schemas in a batch
CREATE OR REPLACE FUNCTION drop_all ()
RETURNS VOID AS
$$
DECLARE rec RECORD;
BEGIN
-- Get all the schemas
FOR rec IN
SELECT nspname FROM pg_catalog.pg_namespace WHERE (nspname != 'public') and (nspname NOT LIKE 'pg_%') and (nspname != 'information_schema') LIMIT 50
LOOP
EXECUTE format('DROP SCHEMA "%s" CASCADE', rec.nspname);
@j33ty
j33ty / gist:b3a753fc69cc85348d2246d5aab5082f
Created August 18, 2023 13:54
Zed based Rose Themes for slightly solarized Slack
Light Theme
#F9F4EE,#EEE8D5,#486570,#F9F4EE,#E8E1D8,#486570,#2AA198,#DC322F,#486570,#F9F4EE
Dark Theme
#292C33,#EEE8D5,#CFC2AE,#292C33,#6F7073,#CFC2AE,#5D8687,#5D8687,#CFC2AE,#292C33
@j33ty
j33ty / jsonb.sql
Created May 30, 2020 16:05
JSONB Cheatsheet
-- Copied from https://www.alexedwards.net/blog/using-postgresql-jsonb
-- Create a table with a JSONB column.
CREATE TABLE items (
id SERIAL PRIMARY KEY,
attrs JSONB
);
-- You can insert any well-formed json input into the column. Note that only
-- lowercase `true` and `false` spellings are accepted.
@j33ty
j33ty / fluxctl-cheatsheet.sh
Created May 28, 2020 12:10
fluxctl cheatsheet
# fluxctl cheatsheet
## Use different namespace than default for flux daemon.
export FLUX_FORWARD_NAMESPACE={kube_ns}
fluxctl --k8s-fwd-ns={kube_ns} list-workloads
## List all workloads
fluxctl list-workloads
## List all workloads in all namespaces
@j33ty
j33ty / ssh-tunneling.sh
Created December 26, 2019 08:23
SSH Tunneling
# Local port forwarding
# Forward all the requests on localhost:8000 to restricted-domain.com:80 via remote-server.com
ssh -L 8000:restricted-domain.com:80 user@remote-server.com
# Remote port forwarding
# Forward all requests to remote-server.com:8000 to your localhost:3000
ssh -R 8000:localhost:3000 user@remote-server.com
@j33ty
j33ty / gpg-cheatsheet.md
Last active July 29, 2019 08:06
GPG Cheatsheet

GnuPG is a complete and free implementation of the OpenPGP standard.

Exporting keys

  • Export key to file: gpg -o key.gpg --export <KEY ID>
  • Export key in ASCII: gpg -o key.asc --export --armor <KEY ID>

Note: Omitting the -o|--output option will print the key to stdout.

Importing keys

  • gpg --import key.gpg

Variable substitution

$\{var:-word}: If var is null or unset, word is substituted for var. The value of var does not change.

$\{var:=word}: If var is null or unset, var is set to the value of word.

$\{var:?message}: If var is null or unset, message is printed to standard error. This checks that variables are set correctly.

$\{var:+word}: If var is set, word is substituted for var. The value of var does not change.

@j33ty
j33ty / print-memory.go
Created May 22, 2019 20:54
Go print current memory
package main
import (
"runtime"
"fmt"
"time"
)
func main() {
// Print our starting memory usage (should be around 0mb)
@j33ty
j33ty / postgres-cheatsheet.sql
Last active April 1, 2024 19:16
Postgres Cheatsheet
/*
***********************************************
psql -h host -U user db: Connect to database
psql -E: Describe the underlaying queries of the \ commands
psql -l: List all database and exit
\q: Quit
\c db_name: Switch database
\l: Show databases
\d table_name: Show table info
@j33ty
j33ty / docker-registry.sh
Created May 20, 2019 06:47
Docker registry
curl -ks registry/v2/_catalog | jq '.["repositories"] | join(" ")' | tr -d '"'
curl -ks registry/v2/go/tags/list | jq .
curl -ks registry/v2/_catalog | jq .