Skip to content

Instantly share code, notes, and snippets.

View gsingharoy's full-sized avatar

Gaurav Singha Roy gsingharoy

View GitHub Profile
@gsingharoy
gsingharoy / sample_sellable_stock.json
Created July 17, 2021 08:41
Sample Sellable Stock JSON Event (Message)
{
"meta": { // Basic meta information about the event.
"source": "stock-system",
"published_at": "2021-07-17T06:50:33Z"
},
"data": { //Represents the main data model of the event
// Unique identifier to identify the article across all systems in the company
"article_id": "423b7e24-e6d9-11eb-ba80-0242ac130004",
package main
import (
"fmt"
"net/http"
)
func main() {
// A slice of sample websites
urls := []string{
package main
import "fmt"
func sum(a int, b int, c chan int) {
c <- a + b // send sum to c
}
func main() {
c := make(chan int)
package main
import (
"fmt"
"net/http"
"sync"
)
func main() {
// A slice of sample websites
package main
import (
"fmt"
"net/http"
"time"
)
func main() {
// A slice of sample websites
package main
import (
"fmt"
"net/http"
)
func main() {
// A slice of sample websites
urls := []string{
package main
import (
"fmt"
"net/http"
)
func main() {
// A slice of sample websites
urls := []string{
@gsingharoy
gsingharoy / manhattan_distance.rb
Created October 20, 2017 10:02
A service to calculate the manhattan distance from a certain point.
# This class represents a service which can be used to find all the reachble points
# from a point specified in a matrix.
# Any point is reachable only by moving horizontally or vertically and not diagonally.
class ManhattanDistance
attr_reader :block_matrix, :center_x, :center_y
# Takes input of a matrix which has values all 0 and only one 1
# The distance would be calculated from the point which has 1
def initialize(block_matrix)
@block_matrix = block_matrix
package main
import "github.com/julienschmidt/httprouter"
//Reads from the routes slice to translate the values to httprouter.Handle
func NewRouter(routes Routes) *httprouter.Router {
router := httprouter.New()
for _, route := range routes {
var handle httprouter.Handle
package main
import "github.com/julienschmidt/httprouter"
/*
Define all the routes here.
A new Route entry passed to the routes slice will be automatically
translated to a handler with the NewRouter() function
*/
type Route struct {