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 / fan-out-in.go
Last active November 21, 2020 17:00
Fan out and Fan in pattern 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 November 22, 2020 08:27
Or Done channel - Concurrency in Go Book
package main
import (
"fmt"
"time"
)
// Simpler version for Or
func OrVer2(ch ...chan struct{}) <-chan struct{} {
switch len(ch) {
@ribice
ribice / caller.go
Last active July 7, 2023 07:07
A robust rabbitmq client for Go
go func() {
for {
err = rmq.Stream(cancelCtx)
if errors.Is(err, rabbitmq.ErrDisconnected) {
continue
}
break
}
}()
@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

@aalemayhu
aalemayhu / gs_gofmt.bash
Created March 17, 2017 09:36
Run gofmt on changed files
for x in `git status -s|awk '{ print $2}'`; do gofmt -w $x; done
@laeshiny
laeshiny / mgoTestExample.go
Last active February 18, 2022 09:23
mgo test example
package main
import (
"fmt"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"time"
)
type Content struct {
@kamal-github
kamal-github / nginxproxy.md
Created February 9, 2016 17:43 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@kamal-github
kamal-github / nginx-ssl-config
Created February 9, 2016 17:42 — forked from apollolm/nginx-ssl-config
Nginx Configuration with multiple port apps on same domain, with SSL.
# the IP(s) on which your node server is running. I chose port 3000.
upstream app_geoforce {
server 127.0.0.1:3000;
}
upstream app_pcodes{
server 127.0.0.1:3001;
}
@harlow
harlow / get_set.go
Created August 4, 2014 04:31
Get and set values of a Struct using reflection in Go Lang
type MyStruct struct {
N int
}
n := MyStruct{ 1 }
// get
immutable := reflect.ValueOf(n)
val := immutable.FieldByName("N").Int()
fmt.Printf("N=%d\n", val) // prints 1