Skip to content

Instantly share code, notes, and snippets.

View manigandand's full-sized avatar
👨‍💻
Go, MongoDB, NodeJS, Kubernetes

Manigandan Dharmalingam manigandand

👨‍💻
Go, MongoDB, NodeJS, Kubernetes
View GitHub Profile
@manigandand
manigandand / reflect_map.go
Created March 7, 2018 11:00
Convert type interface to map using reflect
package main
import (
"fmt"
"reflect"
)
type Book struct {
ID int
Title string
@manigandand
manigandand / list_directory.go
Last active August 6, 2021 18:22
List files in a directory using golang
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
)
@manigandand
manigandand / limitConcurrentGoroutines.go
Created March 29, 2018 12:37 — forked from AntoineAugusti/limitConcurrentGoroutines.go
Limit the maximum number of goroutines running at the same time
package main
import (
"flag"
"fmt"
"time"
)
// Fake a long and difficult work.
func DoWork() {
@manigandand
manigandand / AtomSnipets
Created May 21, 2018 09:47
AtomSnipets
'.source.go':
'ginkgo snipet':
'prefix': 'ginkgo'
'body': """var _ = Describe("Describe", func() {
Describe("Main Describe", func() {
Context("Context", func() {
It("Scenario", func() {
By("Test By")
Expect("test goginko").To(Equal("test goginko"))
})
@manigandand
manigandand / nsq_setup.sh
Last active June 1, 2018 15:07
NSQ Setup using Docker
sudo docker pull nsqio/nsq
#first time
sudo docker run --name lookupd -p 4160:4160 -p 4161:4161 nsqio/nsq /nsqlookupd
# run as background
sudo docker run -p 4160:4160 -p 4161:4161 nsqio/nsq /nsqlookupd
sudo docker pull nsqio/nsq
sudo docker run --name nsqd -p 4150:4150 -p 4151:4151 \
nsqio/nsq /nsqd \
@manigandand
manigandand / links.txt
Last active July 10, 2018 11:59
Golang pprof: profiling and tooling reference links
@manigandand
manigandand / client_proxy.go
Created July 19, 2018 10:21
golang client proxy
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
)
@manigandand
manigandand / query.psql
Created August 1, 2018 13:18
Get distinct unqiue results
select a.id from TableA a \
JOIN TableB b ON a.id=b.tablea_id \
JOIN TableC AS c ON b.tableb_id=c.id \
where c.name IN ('java','python') \
group by a.id \
having count(distinct c.name)=2;
@manigandand
manigandand / postgres-cheatsheet.md
Created August 1, 2018 14:04 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@manigandand
manigandand / installation_steps.md
Last active September 10, 2018 12:44
Yahoo’s Kafka Manager Installation