Skip to content

Instantly share code, notes, and snippets.

View kokes's full-sized avatar

Ondrej Kokes kokes

View GitHub Profile
@kokes
kokes / atoi.go
Created December 17, 2020 09:05
Testing sad paths of `strconv.ParseInt` with error reporting changed from custom errors to plain `errors.New`. `atoi.go` is a combination of various files from the standard library, with only error reporting changed. `atoi_test.go` is the benchmark itself. We can see that given invalid input, `strconv.ParseInt` allocates and this dominates the r…
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package mystrconv
import "errors"
var errNotInt = errors.New("not an int")
package main
import (
"fmt"
"math"
"math/rand"
"time"
)
func main() {
@kokes
kokes / cz.txt
Last active April 29, 2020 10:49
czech domains *potentially* affected by this CAA problem https://letsencrypt.org/caaproblem/
This file has been truncated, but you can view the full file.
*.0.devklarka.cz
*.05.cz
*.0e.cz
*.0oo.cz
*.1.devklarka.cz
*.10.devklarka.cz
*.1001hry.cz
*.100letvyroci.cz
*.100py.cz
@kokes
kokes / cz.py
Last active March 3, 2020 20:38
czech domains potentially/really affected by https://letsencrypt.org/caaproblem/ (using data from Alexa top 1m)
# https://letsencrypt.org/caaproblem/
import re
import gzip
from tqdm import tqdm
fn = 'caa-rechecking-incident-affected-serials.txt.gz'
rr = re.compile(r'[\[\]\s]')
domains = set()
with gzip.open(fn, 'rt') as f:
for ln in tqdm(f):
@kokes
kokes / similar_packages.py
Last active December 2, 2019 14:08
find potential typosquatters on pypi
import json
import re
import itertools
from urllib.request import urlopen
from urllib.error import HTTPError
import lxml.html
import lxml.etree
from jellyfish import levenshtein_distance
@kokes
kokes / vzniky.tsv
Created September 14, 2019 11:25
z dat justice
rok_zapisu pocet
2019 25385
2018 37401
2017 39699
2016 37233
2015 34413
2014 151399
2013 26487
2012 26160
2011 26515
@kokes
kokes / results.txt
Last active July 27, 2019 13:42
Throughput test in Go's readline
$ go test --bench .
goos: linux
goarch: amd64
BenchmarkLines/10000000B/25/ragged:false 100 11124454 ns/op 898.92 MB/s
BenchmarkLines/10000000B/100/ragged:false 300 4151054 ns/op 2409.03 MB/s
BenchmarkLines/10000000B/1000/ragged:false 1000 1321200 ns/op 7568.87 MB/s
BenchmarkLines/10000000B/10000/ragged:false 2000 1162743 ns/op 8600.35 MB/s
BenchmarkLines/100000000B/25/ragged:false 10 113038763 ns/op 884.65 MB/s
BenchmarkLines/100000000B/100/ragged:false 30 40415252 ns/op 2474.31 MB/s
BenchmarkLines/100000000B/1000/ragged:false 100 18977939 ns/op 5269.28 MB/s
url length
http://dataor.justice.cz/api/file/sro-full-praha-2018.xml 3355483240
http://dataor.justice.cz/api/file/sro-full-praha-2017.xml 3354586558
http://dataor.justice.cz/api/file/sro-full-praha-2016.xml 3293796959
http://dataor.justice.cz/api/file/sro-full-praha-2019.xml 3280192120
http://dataor.justice.cz/api/file/sro-full-praha-2015.xml 3218226758
http://dataor.justice.cz/api/file/sro-full-praha-2014.xml 3124904235
http://dataor.justice.cz/api/file/sro-actual-praha-2019.xml 3059764522
http://dataor.justice.cz/api/file/sro-full-praha-2013.xml 3029513067
http://dataor.justice.cz/api/file/sro-actual-praha-2018.xml 3029491011
@kokes
kokes / pycon2019-talks.md
Created May 6, 2019 12:23
talks that look interesting
@kokes
kokes / netflix-cs-audio.txt
Last active November 2, 2019 20:38
Filmy s českýma titulkama na Netflixu
Alexa & Katie
All or Nothing
Angel of the Lord 2
Another Life
Backstage
Barbie Dolphin Magic
Basketball or Nothing
Beats
Black Mirror
Captain Underpants: The First Epic Movie