Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Focusing

kamal namdeo kamal-github

:octocat:
Focusing
View GitHub Profile
View materialized_view.md

Understand error on materized view refresh concurrently.

ERROR:  cannot refresh materialized view "public.mvw_prod" concurrently
HINT:  Create a unique index with no WHERE clause on one or more columns of the materialized view.

Works

create materialized view mvw_prod as select productid, productname, supplierid from products join categories using(categoryid) where productid>5;
View dockerfile-best-practices.md
Docker file best practices
  1. order instruction by least to most frequent changing content
  2. Avoid COPY . (Copy only what is needed if possible)
  3. Don’t use latest tag, add a specific version
  4. Multi stage build -
    1. DRY
    2. small image size
    3. Build different image for test/run/lint from base buiilt image
View postgres kill runaway queries.md
Check current acticity or running query

select pid, query from pg_stat_activity where state='active';

To Cancel

select pg_cancel_backend(<pid>);

View Go - Remove first element from slice
// https://play.golang.org/p/7oTksbq9ioW
package main
import (
"fmt"
)
func main() {
View pprof_handlers.go
package main
import (
"fmt"
"log"
"net/http"
"net/http/pprof"
)
// HTTP request handler
func handler(w http.ResponseWriter, r *http.Request) {
@kamal-github
kamal-github / fan-out-in.go
Last active Nov 21, 2020
Fan out and Fan in pattern in Go
View fan-out-in.go
package main
import (
"fmt"
"runtime"
"sync"
)
func main() {
// can be a input stream such as CSV/Network/File.
@kamal-github
kamal-github / OrDoneChannel.go
Last active Nov 22, 2020
Or Done channel - Concurrency in Go Book
View OrDoneChannel.go
package main
import (
"fmt"
"time"
)
// Simpler version for Or
func OrVer2(ch ...chan struct{}) <-chan struct{} {
switch len(ch) {
@kamal-github
kamal-github / rabbitmq.go
Created Sep 17, 2020 — forked from ribice/caller.go
A robust rabbitmq client for Go
View rabbitmq.go
const (
// When reconnecting to the server after connection failure
reconnectDelay = 5 * time.Second
)
// Client holds necessery information for rabbitMQ
type Client struct {
pushQueue string
logger zerolog.Logger
connection *amqp.Connection
@kamal-github
kamal-github / main.go
Created Sep 13, 2020 — forked from tomekbielaszewski/main.go
Example of RabbitMQ reconnect feature. Including recovering already registered consumers.
View main.go
package main
import (
"fmt"
"log"
"time"
)
func main() {
queue := NewQueue("amqp://guest:guest@localhost:5672/", "hello")
View Download O'Reilly books
# wget -i this_file
http://www.oreilly.com/programming/free/files/files/microservices-for-java-developers.pdf
http://www.oreilly.com/programming/free/files/modern-java-ee-design-patterns.pdf
http://www.oreilly.com/programming/free/files/object-oriented-vs-functional-programming.pdf
http://www.oreilly.com/programming/free/files/java-the-legend.pdf
http://www.oreilly.com/programming/free/files/functional-programming-python.pdf
http://www.oreilly.com/programming/free/files/reactive-microservices-architecture-orm.pdf
http://www.oreilly.com/programming/free/files/migrating-cloud-native-application-architectures.pdf
http://www.oreilly.com/programming/free/files/software-architecture-patterns.pdf