Skip to content

Instantly share code, notes, and snippets.

@mfridman
mfridman / PostgreSQL_index_naming.rst
Created September 12, 2019 03:58 — forked from popravich/PostgreSQL_index_naming.rst
PostgreSQL index naming convention to remember

The standard names for indexes in PostgreSQL are:

{tablename}_{columnname(s)}_{suffix}

where the suffix is one of the following:

  • pkey for a Primary Key constraint;
  • key for a Unique constraint;
  • excl for an Exclusion constraint;
  • idx for any other kind of index;
@mfridman
mfridman / README.md
Created November 15, 2022 01:56 — forked from reegnz/README.md
CamelCase <--> snake_case conversion in jq

CamelCase <--> snake_case conversion with jq

tl;dr

I provide you with 3 jq lib functions that will help you in converting between snake_case and CamelCase.

The interface

I want to change keys in my json from camelcase to snake_case.

@mfridman
mfridman / ANSI.md
Created May 21, 2022 00:45 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@mfridman
mfridman / postgres_queries_and_commands.sql
Created March 3, 2021 19:03 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@mfridman
mfridman / shpod.sh
Created November 27, 2020 15:49
Use by jpetazzo/shpod
#!/bin/sh
# For more information about shpod, check it out on GitHub:
# https://github.com/jpetazzo/shpod
if [ -f shpod.yaml ]; then
YAML=shpod.yaml
else
YAML=https://raw.githubusercontent.com/jpetazzo/shpod/main/shpod.yaml
fi
if [ "$(kubectl get pod --namespace=shpod shpod --ignore-not-found -o jsonpath={.status.phase})" = "Running" ]; then
echo "Shpod is already running. Starting a new shell with 'kubectl exec'."
@mfridman
mfridman / rsa_util.go
Created October 23, 2019 04:01 — forked from miguelmota/rsa_util.go
Golang RSA encrypt and decrypt example
package ciphers
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha512"
"crypto/x509"
"encoding/pem"
"log"
)
@mfridman
mfridman / go-ssh-hostkey.go
Last active June 15, 2020 21:25
Go host key checking for non-standard port(s)
// thes below two functions are talked about in
// http://mfridman.com/2017/09/04/go-ssh-hostkey.html
func validatePort(s string) (string, error) {
// empty string defaults to port 22, ports 1-65535 valid, otherwise error
if s == "" {
// it is the caller's responsibility to pass in a valid, non-empty port
return "22", nil
}
i, _ := strconv.Atoi(s)
@mfridman
mfridman / keybase.md
Created April 10, 2020 21:51
keybase verification

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@mfridman
mfridman / drone.pr
Created April 1, 2020 23:48 — forked from woky/drone.pr
CI=drone
CI_BUILD_CREATED=1538244194
CI_BUILD_EVENT=pull_request
CI_BUILD_FINISHED=1538244196
CI_BUILD_LINK=https://github.com/rchain-drone/droneci-test/pull/2
CI_BUILD_NUMBER=2
CI_BUILD_STARTED=1538244194
CI_BUILD_STATUS=success
CI_COMMIT_AUTHOR=woky
CI_COMMIT_AUTHOR_AVATAR=https://avatars0.githubusercontent.com/u/620147?v=4
@mfridman
mfridman / five.md
Created November 24, 2019 23:33
top 5 most common .goreleaser files

10666361bf2ddb7070c9ea6756b1e8ce327a9edb

8 found

builds:
  # List of builds
  - # First Build
    env:
    - CGO_ENABLED=0