Skip to content

Instantly share code, notes, and snippets.

@aryszka
aryszka / mintransfers.go
Last active November 16, 2021 12:10
min transfers in Go, and without a for loop in JS and MML
package main
import (
"fmt"
"log"
"math"
"os"
"strconv"
"strings"
)
import "lists"
// with checking circular references:
fn deepEq(...a) {
fn deepEq2Lists(refs, a, b)
len(a) == len(b) &&
lists.every(fn(i) deepEq2(refs, a[i], b[i]), lists.indexes(a))
fn deepEq2Structs(refs, a, b)
len(keys(a)) == len(keys(b)) &&

A/B test with traffic switching

A/B test via cookie canary, used for sticky sessions.

step0

  • all traffic goes to backend variant-b, Kubernetes service-b-v1
apiVersion: zalando.org/v1
kind: RouteGroup
@aryszka
aryszka / 9.go
Last active June 16, 2020 21:10
package main
import (
"fmt"
"log"
)
/*
Project Euler #9:
package routeswithfallback
import (
"errors"
log "github.com/sirupsen/logrus"
"github.com/zalando/skipper/eskip"
"github.com/zalando/skipper/routing"
)
package main
/*
This tool can be used to make hanging read or write requests.
To test:
skipper -inline-routes '
read: Path("/read") -> randomContent(1000000000) -> <shunt>;
write: Path("/write") -> absorb() -> <shunt>;
@aryszka
aryszka / config.go
Last active October 6, 2019 16:02
Combine config with flags
/*
This small POC shows a possible way to combine a config file with command line flags such that the command line
flags override the settings from the config file.
*/
package main
import (
"flag"
"log"
"os"

Bevasarlo lista

  • 3 kilo krumpli
  • 75 deka fustolt szalonna
  • 1 kilo hagyomanyos magyar jellegu voroshagyma
  • egy fokhagyma
  • 0.6 kilo feher paprika, magyar jellegu
  • 0.2 kilo hegyes zoldpaprika, magyar jellegu
  • 0.8 kilo paradicsom
  • 0.5 jo kolbasz

This looks solid, nice job! Here's a code review, mostly stylistics.


the method name Matches could be just simply Match. (Somewhat following the regexp package as a convention.)


package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"net/http"
)