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/0bbwnZYMKSa
// go@v1.19 does not recognize two wrapped errors
// go@v1.20 recognizes two wrapped errors
package main
import (
"errors"
"fmt"
)
// https://google.github.io/comprehensive-rust/basic-syntax/scopes-shadowing.html
fn main() {
let a = 10;
println!("before: {a}");
{
let a = "hello";
println!("inner scope: {a}");
let a = true;
// locally can upload tens of GBs
package main
import (
"fmt"
"io"
"net/http"
"os"
"path"
)
// https://go.dev/play/p/eDtSd13eu5r
// graph walking from start to end 🦔🐾🐾🐾
package main
import "fmt"
type Graph map[int][]int
func sliceContains[T comparable](vs []T, v T) bool {
for _, q := range vs {
// https://go.dev/play/p/_Gt8U6GFkPk
// go embedding field mechanics ⚙️
package main
import (
"fmt"
"unsafe"
)
type A struct {
// 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/Z3myZb93aNt
// base64 with invisible chars 🤖
package main
import (
"encoding/base64"
"fmt"
)
func main() {
// slice of strings as CLI argument 🐹
// https://pkg.go.dev/flag#Value
package main
import (
"flag"
"log"
)
type arrayFlags []string
// 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 }

Convert to CSV

jq -r '[.function_name, .call_count] | @csv'