Skip to content

Instantly share code, notes, and snippets.

Avatar

Ivor Scott Cummings ivorscott

View GitHub Profile
@ivorscott
ivorscott / preview.go
Created Jun 14, 2020
Open file in default Mac browser
View preview.go
func preview(fname string) error {
const GOOS string = runtime.GOOS
switch {
case GOOS == "darwin":
if err := exec.Command("open", fname).Start(); err != nil {
return err
}
default:
View create products table
docker-compose run migration create_products_table
View add tags to products
docker-compose run migration add_tags_to_products
View hey requests
hey -c 10 -n 2000 https://localhost:4000/v1/products
View go tool pprof
go tool pprof http://localhost:6060/debug/pprof/profile\?seconds\=10
View dlv connect
docker-compose exec debug-api dlv connect localhost:2345
View create seed file
touch ./api/internal/schema/seeds/products.sql
View insert seed data
docker-compose exec db psql postgres postgres -f /seed/products.sql
View partial.yml
volumes:
- postgres:/var/lib/postgresql/data
- ./api/scripts/:/docker-entrypoint-initdb.d/
View gist:f81ddc73dd9bb1a5069cc7d9e3e5cd49
dump:
@echo [ dumping postgres backup for $(POSTGRES_DB)... ]
@docker exec -it db pg_dump --username $(POSTGRES_USER) $(POSTGRES_DB) > ./api/scripts/backup.sql
@echo $(SUCCESS)