Skip to content

Instantly share code, notes, and snippets.

View j33ty's full-sized avatar
💭
🖥 🏕

radhe j33ty

💭
🖥 🏕
  • sanity.io
  • Oslo
View GitHub Profile
@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 .
@j33ty
j33ty / regex-cheatsheet.js
Created May 16, 2019 19:48
Regex cheatsheet copied from dev.to
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"