This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://github.com/eranyanay/1m-go-websockets/tree/master/3_optimize_ws_goroutines | |
| https://github.com/mcastilho/fast-topic-matching/blob/master/trie.go | |
| A serverless cluster computing system for the Go programming language | |
| https://github.com/grailbio/bigslice | |
| Managing CPU load in Golang | |
| https://blog.ellation.com/managing-cpu-load-in-golang-515b9356bc5 | |
| Let’s Write a Simple Event Bus in Go |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "io" | |
| "log" | |
| "math/rand" | |
| "net/http" | |
| "time" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| ) | |
| type Dispatcher struct { | |
| // A pool of workers channels that are registered with the dispatcher | |
| maxWorkers int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| define('DATEFMT', 'Y-m-d\TH:i:s.u'); | |
| /* Bounded box from "Common objects" */ | |
| class BBox { | |
| var $x1, $y1, $x2, $y2; | |
| function __construct($x1, $y1, $x2, $y2) { | |
| $this->x1 = $x1; | |
| $this->y1 = $y1; | |
| $this->x2 = $x2; | |
| $this->y2 = $y2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func FindPhoneNumber(filename string) []byte { | |
| b, _ := ioutil.ReadFile(filename) | |
| b = regexp.MustCompile("[0–9]+").Find(b) | |
| return append([]byte{}, b...) | |
| } | |
| sao chép dữ liệu cần thiết thành một slice mới nhờ hàm append, biến tham khảo tới slice cũ sẽ được giải phóng khi ra khỏi hàm. | |
| var a []*int{...} | |
| // phần tử cuối cùng sẽ được gán giá trị nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // thêm phần tử 0 vào cuối slice a | |
| a = append(a, 0) | |
| // lùi những phần tử từ index i trở về sau | |
| copy(a[i+1:], a[i:]) | |
| // gán vị trí thứ i bằng x | |
| a[i] = x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // mở rộng không gian của slice a với array x | |
| a = append(a, x...) | |
| // sao chép len(x) phần tử lùi về sau | |
| copy(a[i+len(x):], a[i:]) | |
| // sao chép array x vào giữa | |
| copy(a[i:], x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func CoverMapUrl(m map[string]string) string { | |
| mS := "" | |
| for k, v := range m { | |
| mS += k + "=" + v + "&" | |
| } | |
| return mS[:len(mS)-1] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| db.getCollection('users').aggregate([ | |
| { | |
| $project: { | |
| "_id":0, | |
| "age": { | |
| $divide: [ | |
| { | |
| $subtract: [ | |
| new Date(), | |
| { $ifNull: ["$birthday", new Date() ]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func GetNamePrefix(msgName string) (prefix string) { | |
| items := strings.Split(msgName, ".") | |
| prefix = strings.Join(items[0:len(items)-1], ".") | |
| return | |
| } | |
| func GetName(msgName string) (name string) { | |
| items := strings.Split(msgName, ".") | |
| name = items[len(items)-1] | |
| return |