Skip to content

Instantly share code, notes, and snippets.

View kokes's full-sized avatar

Ondrej Kokes kokes

View GitHub Profile
@kokes
kokes / 01porady.py
Created March 28, 2018 19:35
stahovani titulku z ivysilani
"""
Stáhni seznam pořadů z webu iVysílání
"""
import json
from urllib.parse import urljoin
import lxml.html
burl = 'http://www.ceskatelevize.cz/ivysilani/podle-abecedy'
ht = lxml.html.parse(burl).getroot()
@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")
@kokes
kokes / cesko.json
Created August 20, 2016 21:10
Z map http://www.gadm.org/country udělá TopoJSON mapu Česka včetně správných kódů bývalých okresů (např. CZ0100 pro Prahu).
{"transform": {"scale": [5.313528560244354e-05, 3.3324728237661636e-05], "translate": [12.09076023101818, 48.54084014892584]}, "arcs": [[[40697, 63495], [-26, -506], [-12, -143], [-39, -128], [-114, -234], [-51, -53], [-153, -128], [-64, -31], [-242, -45], [-38, -15], [-51, -30], [-153, -136], [-128, -151], [-38, -53], [-64, -158], [-51, -53], [-76, -30], [-230, -53], [-165, -91], [-217, -68], [-191, -90], [-293, -68], [-344, -106], [-141, -22], [-191, -8], [-191, 15], [-229, 38], [-64, 0], [-77, -8], [-318, -68], [-77, -30], [-153, -75], [-229, -98], [-166, -46], [-242, -53]], [[35879, 60770], [26, 227], [0, 143], [-13, 129], [-26, 68], [-25, 37], [-64, 38], [-153, 60], [-89, 68], [-26, 15], [-140, 46], [-63, 30], [-153, 136], [-39, 53], [-102, 196], [-38, 75], [-13, 46], [-12, 135], [-13, 265], [-26, 120], [-38, 61], [-76, 90], [-102, 196], [-39, 76], [-25, 83], [-13, 91], [0, 135], [0, 182], [13, 128], [25, 113], [13, 30], [64, 91], [13, 38], [12, 30], [0, 75], [-12, 76], [-13, 30], [-77, 121], [-50, 135],
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
*.11.devklarka.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 / 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
@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