Skip to content

Instantly share code, notes, and snippets.

View kamal-github's full-sized avatar
:octocat:
Focusing

Kamal Namdeo kamal-github

:octocat:
Focusing
View GitHub Profile
@kamal-github
kamal-github / main.go
Created September 13, 2020 14:40 — forked from tomekbielaszewski/main.go
Example of RabbitMQ reconnect feature. Including recovering already registered consumers.
package main
import (
"fmt"
"log"
"time"
)
func main() {
queue := NewQueue("amqp://guest:guest@localhost:5672/", "hello")
# 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
@kamal-github
kamal-github / Go Visitor Pattern
Created September 26, 2019 13:37
Go Visitor Pattern to pass and apply options
type Logger struct {
Prop1 string
Prop2 string
}
type Option func(l *Logger) error
func Prop1Option() Option {
return func(l *Logger) error {
l.Prop1 = "hello"

Notes for K8s Services

  • create a simple service
  • expose stable address
  • expose through Env var and DNS
  • services should be created b4 client pods for th8 service
  • service name is hostname for service apart from IP, which is maintained in DNS server pod in kube-system namespace
  • Expose/Impose the external machines to Cluster and make them available to pods in the cluster -> 1) create service without selector and create Endpoints resource with external IPs. now Pods can access out of cluster nodes throough that service.
@kamal-github
kamal-github / README.md
Created December 18, 2018 20:06 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet

Main/Summary points of Go for Industrial Programming, Video

  • Do not decide your project Structure at the very end, it evolves!
  • Make configuration based sysytem, and flags are the best way to change the behaviour of your syetem function.
  • Manage goroutines lifecycle, thy are prone to leak, Always think of how this gorouting will finish/interrupt. Always try to pass some sort of interrupt func/context to interrupt e.g. func foo(execFunc func(...args interface{}) error, interupptFunc func() error) or listening to context.Done
  • Use interface at the consumer side not at the implementation package, interfaces are really good to mock the dependencies.
  • Must watch, Advanced Testing with go
  • Do not misuse context, make context Value only request scoped like request ID for DT or au
@kamal-github
kamal-github / DockerStorage.md
Last active November 4, 2018 18:06
Docker: Bind Mount vs Volumes

Bind Mount vs Volumes

  • When you use a bind mount, a file or directory on the host machine is mounted into a container. The file or directory is referenced by its full or relative path on the host machine. By contrast, when you use a volume, a new directory is created within Docker’s storage directory on the host machine, and Docker manages that directory’s contents.
  • The file or directory does not need to exist on the Docker host already. It is created on demand if it does not yet exist.
  • Both allow sharing contents amoung containers
  • Prepopulated contents obsucured in case of Bind Mount while Volume sync the contents from containers to Docker host.
  • Bind Propagation exixt only in Bind Mount.
  • Unlike a bind mount, you can create and manage volumes outside the scope of any container.
    • Create a volume: $ docker volume create my-vol
@kamal-github
kamal-github / squash-commits.sh
Created October 18, 2018 14:30 — forked from jbub/squash-commits.sh
git squash last two commits into one
git rebase --interactive HEAD~2
# we are going to squash c into b
pick b76d157 b
pick a931ac7 c
# squash c into b
pick b76d157 b
s a931ac7 c
@kamal-github
kamal-github / ZshSetup.md
Last active October 16, 2018 14:50
Zsh Setup with Ohmyzsh

Install Zsh using OhMyZsh https://github.com/robbyrussell/oh-my-zsh

For setting default user - ohmyzsh/ohmyzsh#2033 to remove the user and computer name on command prompt. set DEFAULT_USER=whoami with backquotes around whoami

Choose theme - agnoster

Install Plugins

git, golan, kubectl, sudo, docker, docker-compose, iterm2

@kamal-github
kamal-github / GoPattAllStartAtSameTime
Last active July 24, 2018 12:15
Pattern to start all go routines only after all are created
// Pattern to start all go routines only after all are created.
func goRoutine() {
<-start
// do whatever
}
func main() {
start := make(chan, struct{})