Skip to content

Instantly share code, notes, and snippets.

View thedevsaddam's full-sized avatar
🏴‍☠️
Wherever we want to go, we'll go!

Saddam H thedevsaddam

🏴‍☠️
Wherever we want to go, we'll go!
View GitHub Profile
@thedevsaddam
thedevsaddam / pget.go
Created March 10, 2020 07:56 — forked from montanaflynn/pget.go
Bounded Parallel Get Requests in Golang
package main
import (
"fmt"
"net/http"
"sort"
"time"
)
// a struct to hold the result from each request including an index
package main
import "sort"
func main() {
}
//func Solution(blocks []int) int {
// flag := 0
@thedevsaddam
thedevsaddam / rabbitmq-cluster.md
Created February 3, 2019 09:25 — forked from pobsuwan/rabbitmq-cluster.md
How to config rabbitmq server cluster [3 nodes]

How to config rabbitmq server cluster [3 nodes]

Do after install SLGInstallers

Edit /etc/hosts

vi /etc/hosts
192.168.10.157  rabbitmq-1
192.168.10.159  rabbitmq-2
192.168.10.161  rabbitmq-3
@thedevsaddam
thedevsaddam / getPassword.go
Created October 18, 2018 09:32 — forked from jlinoff/getPassword.go
Go code to prompt for password using only standard packages by utilizing syscall.ForkExec() and syscall.Wait4(), recovers from ^C gracefully.
// License: MIT Open Source
// Copyright (c) Joe Linoff 2016
// Go code to prompt for password using only standard packages by utilizing syscall.ForkExec() and syscall.Wait4().
// Correctly resets terminal echo after ^C interrupts.
package main
import (
"bufio"
"fmt"
"os"
@thedevsaddam
thedevsaddam / gojsonq.go
Created July 29, 2018 09:55
gojsonq query/access json document
package main
import "github.com/thedevsaddam/gojsonq"
const json = `{"name":{"first":"Tom","last":"Hanks"},"age":61}`
func main() {
name := gojsonq.New().JSONString(json).Find("name.first")
println(name.(string)) // Tom
}
@thedevsaddam
thedevsaddam / users.json
Created July 10, 2018 17:00
Gojsonq users.json data
{
"users":[
{
"id":1,
"name":{
"first":"John",
"last":"Ramboo"
}
},
{
@thedevsaddam
thedevsaddam / gojsonq-example-3.go
Created July 10, 2018 16:52
jsonq usages of Sum method
package main
import (
"fmt"
"github.com/thedevsaddam/gojsonq"
)
func main() {
jq := gojsonq.New().File("./sample-data.json")
@thedevsaddam
thedevsaddam / limitConcurrentGoroutines.go
Created June 5, 2018 05:54 — 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() {
@thedevsaddam
thedevsaddam / redis_cheatsheet.bash
Created May 30, 2018 07:57 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@thedevsaddam
thedevsaddam / mgoTestExample
Created January 31, 2018 12:20 — forked from laeshiny/mgoTestExample.go
mgo test example
package main
import (
"fmt"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"time"
)
type Content struct {