Skip to content

Instantly share code, notes, and snippets.

This is a simple benchmark that tests the performance of several
locking implementations. Each example implements a connection
pool that provides `get_connection()` to retrieve a connection
from the pool and `release()` to return a connection back to the
The `test()` function creates an instance of `pool_class` and
creates `num_threads` `threading.Thread` instances that simply call
`pool.get_connection()` and `pool.release()` repeatedly until
honzakral /
Created December 2, 2019 10:20
External display switcher
PRIMARY=$(xrandr| grep -P '^[[:alnum:]-]+ connected primary' | cut -d ' ' -f 1)
SECONDARY=$(xrandr| grep -P '^[[:alnum:]-]+ connected (?!primary)' | head -n 1 | cut -d ' ' -f 1)
OUTPUTS=$(xrandr | sed -ne '2,$s;^\([^ ]\{1,\}\).*;\1;p' | grep -v "^$PRIMARY\$")
CMD="xrandr --output $PRIMARY --primary --auto "
function resolution {
xrandr | sed -ne "/$1/,/^[^ ]/s;^ [[:space:]]*\([0-9xip]\{1,\}\) .*;\1;p"

Keybase proof

I hereby claim:

  • I am honzakral on github.
  • I am honzakral ( on keybase.
  • I have a public key ASC44AI9qQetZNTdBWjaYJitFwRRI-X7g3dMXl6Pp0hQWQo

To claim this, I am signing this object:

honzakral /
Last active March 11, 2021 09:47
Super simple inverted index in Python
import re
from collections import defaultdict, Counter
def bold(txt):
return '\x1b[1m%s\x1b[0m' % txt
DATA = [
'title': 'Django',
'description': 'Django is a high-level Python Web framework that '
honzakral /
Created April 15, 2016 17:44
Dynamic template mappings in python DSL
from elasticsearch_dsl import DocType, Object, MetaField
class MyDoc(DocType):
inner = Object()
class Meta:
dynamic_templates = MetaField([
'strings_in_inner': {
'path_match': 'inner.*',
honzakral / README.rst
Last active September 27, 2018 19:38
CLI for elaasticsearch-py helpers

Elasticsearch CLI

Experimental CLI interface for the helpers in the `python library`_.

Main purpose is to expose the bulk functionality to enable rapid loading of data into an elasticsearch cluster. Combined with the scan command it can also be used to reindex data from elasticsearch into a different index or cluster.

honzakral /
Last active October 31, 2021 02:20
snake game in python
import pygame
from pygame.locals import *
from random import randint
import os, sys
"LEFT": (-1, 0),
"RIGHT": (1, 0),
# -*- coding: cp1250 -*-
class Halda():
"""halda - dokumentace
TYP 1A na vrcholu nejmenší hodnota, prosté položky
TYP 1B na vrcholu nejmenší hodnota, strukturované položky
TYP 2A na vrcholu největší hodnota, prosté položky
TYP 2B na vrcholu největší hodnota, strukturované položky
### 0 Konstrukční procedury
"query": {
"bool": {
"must": [
"query_string": {
"query": "\"ruby\" OR \"rubi\" OR \"rubz\"",
"default_operator": "or"
honzakral / README.rst
Last active December 25, 2015 22:08
Coding Dojo

WTF Game

Created at PyCon PL as a coding dojo challenge