Skip to content

Instantly share code, notes, and snippets.

View TonPC64's full-sized avatar
:shipit:
Gopher

Chanwit Piromplad TonPC64

:shipit:
Gopher
View GitHub Profile
@TonPC64
TonPC64 / stack.go
Created July 10, 2018 12:47
โจทย์ สร้าง stack ให้ push pop ได้
package main
type stack []int
func main() {
var value stack
value.push(5)
value.pop()
}
package main
import (
"strings"
"golang.org/x/tour/wc"
)
func WordCount(s string) map[string]int {
var strs = make(map[string]int)
@TonPC64
TonPC64 / map-homework.go
Created July 11, 2018 17:08
การบ้านเรื่อง map
package main
import (
"fmt"
"strings"
)
func main() {
wc := NewWordCount()
wc = wc.AddWord("I am")
@TonPC64
TonPC64 / map-homework.go
Created July 11, 2018 17:10
[MapHomework] มี type WordsCount ที่มี methods ต่างๆ แต่ยังไม่สมบูรณ์ ทำให้สมบูรณ์ที
package main
import (
"fmt"
"strings"
)
func main() {
wc := NewWordCount()
wc = wc.AddWord("I am")
module.exports = {
outDir: 'public',
babel: {
babelrc: false
},
banner: true,
format: ['umd-min'],
css: true,
plugins: ['vue']
};
module.exports = {
css: { extract: false },
outputDir: 'lib'
}
package main
import "golang.org/x/tour/pic"
func Pic(dx, dy int) [][]uint8 {
slice := make([][]uint8, dx, dx)
// loop dx
for x := 0; x < dx; x++ {
slice[x] = make([]uint8, dy, dy)
// loop dy
@TonPC64
TonPC64 / docker-compose.yml
Last active February 20, 2022 17:32
example docker compose file for distributed tracing
version: "3.9"
services:
zookeeper:
image: 'bitnami/zookeeper:latest'
ports:
- '2181:2181'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
kafka:
@TonPC64
TonPC64 / init-tracer.go
Created February 24, 2022 14:33
init tracer provider and propagator
func init() {
var exporter sdktrace.SpanExporter
var err error
// use zipkin exporter
exporter, err = zipkin.New("http://zipkin:9411/api/v2/spans")
if err != nil {
panic(err)
}
func main() {
// create server
mux := http.NewServeMux()
// wrapped handler for use propagation to extract trace signal from http header to request context
// it like a middleware
wrappedHandler := otelhttp.NewHandler(http.HandlerFunc(httpHandler), "http-server")
mux.Handle("/", wrappedHandler)
// start server