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/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 {
// locally can upload tens of GBs
package main
import (
"fmt"
"io"
"net/http"
"os"
"path"
)
// 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;
// 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"
)

144.96

package main

import "fmt"

func main() {
	var x float32 = 144.96
	var y float64 = 144.96
// https://go.dev/play/p/oyMTzj-WQRq
package main
import "fmt"
func main() {
x := "‌"
if x != "" {
panic("no.way.")
}
// https://go.dev/play/p/mcWx20GtkaO
// 🌊
package main
import "fmt"
type SGD int64
func (as SGD) Add(bs SGD) SGD { return as + bs }
package main
import (
"errors"
"fmt"
"unsafe"
)
type Currency uint8
// format string slice strings with whitespace can collide 🤪
// https://go.dev/play/p/EqnE9ZWHcjh
package main
import "fmt"
func main() {
fmt.Printf("%v\n", []string{"a b", "c"})
fmt.Printf("%v\n", []string{"a", "b", "c"})
// I am applying function on two things and they tell me how 🐁
// https://go.dev/play/p/8iGGh8Tebgw
package main
import "fmt"
type Summer interface {
Sum(other Summer) Summer
}