This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
. "go/ast" | |
"go/format" | |
"go/token" | |
"os" | |
) | |
func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
ε := 0.1 | |
if ε == -1+ε+1 { | |
panic("ε") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/bits" | |
"math/rand" | |
) | |
type spool struct { | |
*rand.Rand |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/bits" | |
) | |
func main() { | |
fmt.Println(bgcd(6, 36)) | |
fmt.Println(bgcd(2, 36)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/rand" | |
) | |
func main() { | |
t := 0 | |
i := 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO(as): find a production foss program where this issue exists | |
// | |
// This trivial program generates integers and prints them to | |
// standard output until it reaches 1000 or the context is done. | |
// | |
// It contains a fix for a difficult-to-find bug caused in many | |
// Go programs written by authors at all experience levels. | |
package main | |
import ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# as 2019.09.06 | |
# generate a list of iptables commands to block | |
# all ip addresses assigned to facebook via the | |
# organization's autonomous system number. | |
whois -h whois.radb.net '!gAS32934' | egrep / | tr ' ' '\n' | awk '{ printf "iptables -I OUTPUT -d %s -j REJECT\n",$1 }' |