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
| ####### Shortcut Hotkeys ############# | |
| # open terminal | |
| alt - return : open -n /Applications/Alacritty.app | |
| # restart Yabi, SpaceBar, and SKHD | |
| alt + shift - r : \ | |
| launchctl kickstart -k "gui/${UID}/homebrew.mxcl.yabai"; \ | |
| skhd --reload | |
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
| # Cloudflare IPv4 https://www.cloudflare.com/ips-v4/ | |
| # Cloudflare IPv6 https://www.cloudflare.com/ips-v6/ | |
| KONG_REAL_IP_HEADER=Cf-Connecting-Ip | |
| KONG_TRUSTED_IPS=173.245.48.0/20,103.21.244.0/22,103.22.200.0/22,103.31.4.0/22,141.101.64.0/18,108.162.192.0/18,190.93.240.0/20,188.114.96.0/20,197.234.240.0/22,198.41.128.0/17,162.158.0.0/15,104.16.0.0/13,104.24.0.0/14,172.64.0.0/13,131.0.72.0/22,2400:cb00::/32,2606:4700::/32,2803:f800::/32,2405:b500::/32,2405:8100::/32,2a06:98c0::/29,2c0f:f248::/32 | |
| KONG_REAL_IP_RECURSIVE=on |
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
| user nginx; | |
| worker_processes auto; | |
| error_log /dev/stderr warn; | |
| pid /var/run/nginx.pid; | |
| worker_rlimit_nofile 100000; | |
| events { | |
| worker_connections 102400; |
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 ( | |
| "reflect" | |
| "testing" | |
| "github.com/kr/pretty" | |
| ) | |
| func TestSulfuras(t *testing.T) { |
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" | |
| "math" | |
| ) | |
| type Play struct { | |
| Name string | |
| Type string |
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 readFile() error { | |
| return &os.PathError{Op: "read", Path: "/a/b", Err: errors.New("read error")} | |
| } | |
| func main() { | |
| err := readFile() | |
| // การ assert type แบบเดิม | |
| if e, ok := err.(*os.PathError); ok { | |
| fmt.Printf("type assertion, error match os.PathError: %#v\n", e) |
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
| errOriginal := &os.PathError{Op: "read", Path: "/a/b", Err: errors.New("read error")} | |
| // สร้าง error ใหม่ ยังเก็บ(ห่อ) type เดิมไว้ข้างใน | |
| err := fmt.Errorf("wrapped error: %w", errOriginal) | |
| errInner := errors.Unwrap(err) | |
| fmt.Printf("inner error type: %T, error value: %#v\n", errInner, errInner) |
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
| errOriginal := &os.PathError{Op: "read", Path: "/a/b", Err: errors.New("read error")} | |
| // ไม่ได้ห่อ แค่สร้าง error ใหม่จาก error เดิม | |
| err := fmt.Errorf("create new error: %v", errOriginal) | |
| fmt.Printf("error value: %T\n", err) | |
| // สร้าง error ใหม่ ยังเก็บ(ห่อ) type เดิมไว้ข้างใน | |
| err = fmt.Errorf("wrapped error: %w", errOriginal) | |
| fmt.Printf("error value: %T\n", err) |
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 insertInfo() error { | |
| // do work here. | |
| return sql.ErrTxDone | |
| } | |
| func main() { | |
| // จากแบบเดิม | |
| err := insertInfo() | |
| if err == sql.ErrTxDone { | |
| fmt.Println("old way: compare error with sql.ErrTxDone") |
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 ( | |
| "database/sql" | |
| "errors" | |
| "fmt" | |
| "os" | |
| ) | |
| func insertInfo() error { |
NewerOlder