Skip to content

Instantly share code, notes, and snippets.

View nikolaydubina's full-sized avatar

Nikolay Dubina nikolaydubina

View GitHub Profile
// https://go.dev/play/p/HTKZzENHPcG
package main
import (
"encoding/json"
"fmt"
)
type Color struct{ c uint }

Why browsers do not send If-None-Match for caching images? Why browser does not try to get 304 status code for caching?

This can be because there are video html that is trying to load at same time. This can break some browser behavior that will not even attempt to use cached images for some reason. Make preload="none" for videos to stop loading them, and then browser will attempt to use etags for images. Add Cache Control: public. This will make Safari to attempt If-None-Match and make 304 requetsts. private should also work.

// https://go.dev/play/p/1nLXyCDe1_3
// because UNIX! 🐣
package main
import "fmt"
var (
Read = Permission{0x1}
Write = Permission{0x2}
Execute = Permission{0x4}
// 🍧
package main
import "fmt"
type LRUCache struct {
size int
vals map[string]string
order PtrList
}

Convert to CSV

jq -r '[.function_name, .call_count] | @csv'
// does go unpack multiple assignment with variable returns?
// no 🙅🏻‍♂️
// https://go.dev/play/p/8wKi-2J7aL7
package main
import "fmt"
func one(v int) int { return v }
func two() (int, int) { return 2, 3 }
// slice of strings as CLI argument 🐹
// https://pkg.go.dev/flag#Value
package main
import (
"flag"
"log"
)
type arrayFlags []string
https://go.dev/play/p/Z3myZb93aNt
// base64 with invisible chars 🤖
package main
import (
"encoding/base64"
"fmt"
)
func main() {
// https://go.dev/play/p/PX6EWqZsXR4
// race condition in interface cast 😵‍💫
package main
import "fmt"
type I interface{ method() string }
type A struct{ s string }
type B struct {
u uint32
// https://go.dev/play/p/_Gt8U6GFkPk
// go embedding field mechanics ⚙️
package main
import (
"fmt"
"unsafe"
)
type A struct {