Skip to content

Instantly share code, notes, and snippets.

View as's full-sized avatar

as

View GitHub Profile
Christian [03/12/2019 13:31]
I think I see what they’re alluding to though
A “stream” would be the octets corresponding to one single HTTP/2 message
And there can be multiple streams over the same connection
All interwoven and beautiful af
as [03/12/2019 13:32]
it's not a message, it's a connectionette
package main
import (
"fmt"
"math/rand"
)
func main() {
t := 0
i := 0
@as
as / bgcd.go
Last active January 25, 2019 12:55
binary greatest common divisor
package main
import (
"fmt"
"math/bits"
)
func main() {
fmt.Println(bgcd(6, 36))
fmt.Println(bgcd(2, 36))
@as
as / parse.go
Created January 9, 2019 09:59
ParseFlagsOrEnv
// ParseFlagsOrEnv: Order of priority (Flag, Env, Default)
func ParseFlagsOrEnv() {
flag.VisitAll(func(fl *flag.Flag) {
if env, set := os.LookupEnv(fl.Name); set {
fl.DefValue = env
flag.Set(fl.Name, env)
}
})
flag.Parse()
package main
import (
"fmt"
"math/bits"
"math/rand"
)
type spool struct {
*rand.Rand
@as
as / mean.txt
Created November 2, 2018 00:57
Don't Re-add the Elements: The Arithmetic Mean in a Running Average Should Be Efficient
Don't Re-add all the Elements: The Arithmetic Mean in a Running Average Can Be Efficient
----------------------------------------------------------------------------------------
The arithmetic mean of a set is the sum of the set's elements, divided by the set's cardinality.
We observe this definition as a formula: A = 1/n * (a1 + a2 + ... + an), where n is the number of elements.
To demonstrate, we compute the arithmetic mean of the set (1, 2):
A(1, 2) = 1/2 * (1 + 2)
package main
import (
"fmt"
)
func main() {
ε := 0.1
if ε == -1+ε+1 {
panic("ε")
@as
as / hello.go
Created August 19, 2018 08:58
hello world in go...ast
package main
import (
. "go/ast"
"go/format"
"go/token"
"os"
)
func main() {
@as
as / godoc
Created August 17, 2018 08:17
godoc go doc missing command not found golang 1.12
go get golang.org/x/tools/cmd/godoc
#:: Q: Where's godoc?
#:: A: They removed it....
#::
#:: This is a system agnostic script that will download and install the godoc command
@as
as / self aware
Created August 9, 2018 05:39
"A challenge: to create a source code that contains a valid link to itself"
package main
import (
"crypto/sha256"
"encoding/base64"
"fmt"
"io"
)
var x = string(0x60)