Skip to content

Instantly share code, notes, and snippets.

@ja7ad
ja7ad / main.go
Last active October 10, 2023 08:54
nats nak with dynamic delay (step by step)
package main
import (
"context"
"encoding/json"
"errors"
"github.com/brianvoe/gofakeit/v6"
"github.com/hashicorp/golang-lru/v2/expirable"
"github.com/lithammer/shortuuid/v3"
"github.com/nats-io/nats.go"
@ja7ad
ja7ad / lottery.go
Last active August 6, 2023 05:21
Lottery Game and Add to number
package main
import (
"encoding/json"
"fmt"
"log"
"math/rand"
"net/http"
"time"
)
@ja7ad
ja7ad / main.go
Created May 2, 2023 07:18
elastic example query
package main
import (
"context"
"fmt"
"github.com/elastic/go-elasticsearch/v7"
"log"
"strings"
)
@ja7ad
ja7ad / clear_test.go
Last active April 30, 2023 05:50
benchmark clear feature in go1.21
package main
import (
"testing"
"time"
)
func BenchmarkClearMapWithDelete(b *testing.B) {
b.ReportAllocs()
test := createMap(100000)
openapi: 3.0.1
info:
title: test.proto
version: version not set
servers:
- url: /
tags:
- name: Foo
paths:
/list:

Keybase proof

I hereby claim:

  • I am ja7ad on github.
  • I am ja7ad (https://keybase.io/ja7ad) on keybase.
  • I have a public key ASAuJdzUEQ_92uwvICZ6YYfO4naBwTuVlf8Np4Ni3kdsSwo

To claim this, I am signing this object:

@ja7ad
ja7ad / README.md
Last active September 7, 2022 03:59
mongodb with builder pattern

MongoDB Constructor with Builder Pattern

You can create new object of mongodb client and database

Example

package main

import "log"
@ja7ad
ja7ad / main.go
Last active August 2, 2022 06:09
nats embbeded server
package main
import (
"fmt"
"time"
"github.com/nats-io/nats-server/v2/server"
"github.com/nats-io/nats.go"
)
@ja7ad
ja7ad / normalize.go
Last active July 20, 2022 06:26
normalize number with any type
package main
import (
"fmt"
"github.com/nyaruka/phonenumbers"
"strings"
"unicode"
)
var numberList = []string{
@ja7ad
ja7ad / proto.md
Last active February 28, 2022 12:07
Protocol Buffers Principles

Protocol Buffers Structures

syntax = "proto3";
option go_package = "github.com/Ja7ad/bookstore";

service Greeter {
  rpc GetBook(GetBookRequest) returns (Book) {}
  rpc AddBook(AddBookRequest) returns (Book) {}
  rpc AddManyBook(AddManyBookRequest) returns (google.protobuf.Empty) {}
  rpc UpdateBook(UpdateBookRequest) returns (Book) {}