Skip to content

Instantly share code, notes, and snippets.

View paveldedik's full-sized avatar
🦠

Pavel Dedik paveldedik

🦠
View GitHub Profile
@paveldedik
paveldedik / gof.py
Created December 10, 2021 21:29
Game of Life in terminal
"""
How to run:
$ python gof.py &
$ watch -n 0.1 cat epoch.txt
"""
import time

Keybase proof

I hereby claim:

  • I am paveldedik on github.
  • I am paveldedik (https://keybase.io/paveldedik) on keybase.
  • I have a public key ASDW3LdZwY53j745qa2lqbZM8bxjUJLjpO98LdZ8HpmDIwo

To claim this, I am signing this object:

@paveldedik
paveldedik / urllib3bug.py
Created June 8, 2018 13:13
Minimal example to raise bad write entry error with urllib3 and certifi.
import certifi
import urllib3.contrib.pyopenssl
from urllib3.connectionpool import connection_from_url
urllib3.contrib.pyopenssl.inject_into_urllib3()
conn = connection_from_url('https://httpbin.org/post', cert_reqs='CERT_REQUIRED', ca_certs=certifi.where())
conn.urlopen(
method='POST',
@paveldedik
paveldedik / devtalks-haskell.hs
Created December 16, 2016 13:38
From my talk: Haskell in 10 minutes
-- :` ./
-- ++:` ./oo
-- ++++:` ./oooo
-- ++++++:` ./oooooo
-- ++++++++:`./oooooooo
-- ++++++++ohhsoooooooo
-- ++++++oyddddhsoooooo
-- ++++oyddddddddhsoooo
-- ++oyddddddddddddhsoo
@paveldedik
paveldedik / setup.py
Created September 6, 2015 19:49
Setup.py that determines application version, authors and most notably, versions of applications installed from VCS (e.g. GitHub, Google Code etc.)
# -*- coding: utf-8 -*-
import re
import os
from setuptools import setup, find_packages
from pip.req import parse_requirements
@paveldedik
paveldedik / dictionaries.py
Last active September 17, 2015 11:19
Various python dictionary-like data structures.
# -*- coding: utf-8 -*-
from collections import defaultdict
class keydefaultdict(defaultdict):
"""Defaultdict that takes inserted key as an argument.
Example::
@paveldedik
paveldedik / partitioning.py
Created January 12, 2015 14:53
Tool for partitioning very large Mergado tables.
# -*- coding: utf-8 -*-
"""
python partitioning.py -c \
"host=localhost dbname=mergado3 password=development user=dev"
-p public.stats_heureka -t id -i 100
"""
import logging
import psycopg2
@paveldedik
paveldedik / parser.py
Last active August 29, 2015 14:10
Parsing HTML using Regular Expressions and a Stack
# -*- coding: utf-8 -*-
import re
import urllib
WIKI_URL = ('http://en.wikipedia.org/wiki/'
'List_of_countries_and_dependencies_by_area')
@paveldedik
paveldedik / problems.py
Last active December 10, 2018 06:45
Implementations of some interesting algorithms in Python.
# -----------------------------------------------
# Algorithms for solving string matching problems
# -----------------------------------------------
def automaton(p, abc):
"""Builds DFA using pattern p and alphabet abc."""
m = len(p)
d = {}
for q in range(m+1):
for a in abc:
@paveldedik
paveldedik / algorithmic.tex
Last active August 29, 2015 13:57
Example of the algorithmicx package.
\documentclass[12pt]{article}
\usepackage[czech]{babel}
\usepackage{geometry}
\usepackage{lipsum}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\usepackage{algorithm}