Skip to content

Instantly share code, notes, and snippets.

user@host:~# sysctl -n net.ipv6.auto_flowlabels
1
user@host:~# curl -6 https://code.jquery.com/jquery-3.6.0.min.js -o /dev/null
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104
user@host:~# sysctl -w net.ipv6.auto_flowlabels=0
@vpereira01
vpereira01 / bigIntInc.go
Last active May 15, 2022 09:41
go big int faster increment
// bigIntInc speeds up z.Add(z, one) operations when z > 0
func bigIntInc(z *big.Int) {
zBits := z.Bits()
// big.NewInt( 9).Sign() == 1
// For speed and simplicity this only tries to increment the least significant digits.
// Using a base 10 example: 1000+1 only affects the least significant digit.
// Only when the least significant digit is 9, 1009+1, then more significant digits are affected.
if z.Sign() > 0 && zBits[0] < math.MaxUint {
// overflow does not happen due to zBits[0] < math.MaxUint check
// uint(zBits[0])++ is not allowed by Go