Skip to content

Instantly share code, notes, and snippets.

@jay-babu
jay-babu / useful.sql
Created April 17, 2024 16:37
Useful SQL Commands
-- table size, index size, total size
SELECT
table_name,
pg_size_pretty(table_size) AS table_size,
pg_size_pretty(indexes_size) AS indexes_size,
pg_size_pretty(total_size) AS total_size
FROM (
SELECT
table_name,
pg_table_size(table_name) AS table_size,

jq -r ".accessToken" ~/.aws/sso/cache/10c4f2dbd6011f68dc44925dcadadae57ef918c1.json

aws sso get-role-credentials --role-name AdministratorAccess --account-id 260558796113 --access-token

@jay-babu
jay-babu / idealImplShapes.go
Created October 4, 2022 02:26
SOLID: Open-Closed Principle `ideal`
package main
import (
"fmt"
"math"
)
type geometry interface {
// Area of a shape
area() float64
@jay-babu
jay-babu / badImplShapes.go
Created October 4, 2022 01:57
SOLID: Open-Closed Principle `bad`
package main
import (
"fmt"
"math"
)
type badRect struct {
Width, Height float64
}
@jay-babu
jay-babu / idealImplCustomer.go
Created September 30, 2022 01:58
Single Responsibility Principle `idealImpl`
package main
import (
"encoding/json"
"fmt"
)
type CustomerInfo interface {
Name() string
Address() string
@jay-babu
jay-babu / badImplCustomer.go
Last active September 30, 2022 01:57
Single Responsibility Principle `badImpl`
package main
import "fmt"
type badImplCustomer struct {
Name string
Address string
Order int
OrderComplete bool
}
@jay-babu
jay-babu / fieldVsConstructorInjection.go
Last active July 17, 2022 02:05
Field Vs. Constructor Injection
package main
import (
"net/http"
)
type FieldInjection struct {
foo http.Server
bar http.Server
}
@jay-babu
jay-babu / main.go
Created December 10, 2021 00:14
DI With Interfaces Golang
func main() {
area := ProvideShape()
fmt.Println(area)
}
@jay-babu
jay-babu / injectDependency.go
Created December 5, 2021 06:08
Golang DI Injectors
// Provider
func NewFirebaseApp() *firebase.App {
opt := option.WithCredentialsFile(filename)
app, err := firebase.NewApp(context.Background(), nil, opt)
if err != nil {
log.Fatalf("error initializing app: %v\n", err)
}
return app
}
@jay-babu
jay-babu / basicDependency.go
Last active December 5, 2021 05:26
Golang DI Code Snippets
// Provider
func NewFirebaseApp() *firebase.App {
opt := option.WithCredentialsFile(filename)
app, err := firebase.NewApp(context.Background(), nil, opt)
if err != nil {
log.Fatalf("error initializing app: %v\n", err)
}
return app
}