Skip to content

Instantly share code, notes, and snippets.

View vuduongtp's full-sized avatar

vuduongtp vuduongtp

View GitHub Profile
@vuduongtp
vuduongtp / print.go
Last active October 26, 2022 02:51
Golang - Pretty print object as JSON format
import (
"encoding/json"
"fmt"
"reflect"
)
func PrettyPrint(i interface{}) {
fmt.Printf("Type: %s\n", reflect.TypeOf(i))
s, _ := json.MarshalIndent(i, "", "\t")
fmt.Println(string(s))
@vuduongtp
vuduongtp / md5.go
Last active October 26, 2022 01:28
Golang - MD5 Hash Encrypt
import (
"crypto/md5"
"encoding/hex"
)
func MD5Hash(text string) string {
hash := md5.Sum([]byte(text))
return hex.EncodeToString(hash[:])
}
@vuduongtp
vuduongtp / util.go
Created October 19, 2022 14:03
Golang - Convert Vietnamese accented characters to non-accented (Chuyển Tiếng Việt có dấu sang Tiếng Việt không dấu bằng ngôn ngữ Go/Golang)
import (
"regexp"
"strings"
)
func ConvertAccented(text string) string {
text = strings.ToLower(text)
var RegexpA = `à|á|ạ|ã|ả|ă|ắ|ằ|ẳ|ẵ|ặ|â|ấ|ầ|ẩ|ẫ|ậ`
var RegexpE = `è|ẻ|ẽ|é|ẹ|ê|ề|ể|ễ|ế|ệ`
var RegexpI = `ì|ỉ|ĩ|í|ị`
@vuduongtp
vuduongtp / sha256.go
Created October 26, 2022 01:28
Golang - Hash message by SHA256
import (
"crypto/sha256"
"fmt"
)
// SHA256 hash message by SHA256
func SHA256(plaintext string) *string {
data := []byte(plaintext)
hash := sha256.Sum256(data)
hashString := fmt.Sprintf("%x", hash[:])
@vuduongtp
vuduongtp / System Design.md
Created May 5, 2024 15:49 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?