Skip to content

Instantly share code, notes, and snippets.

Edvard Majakari EdvardM

Block or report user

Report or block EdvardM

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View .pylintrc_compact
EdvardM /
Last active Jun 17, 2019
Simple bootstrapt script intended to be used /w curl or similar
#!/usr/bin/env bash
# This script is intended to setup things so that more advanced project commands (doit, poetry) can be easily used
set -eu
echo "Creating venv to ${VENV_DIR} unless present"
test -d ${VENV_DIR} || python3 -m venv ${VENV_DIR}
echo "Activate venv and install poetry"
EdvardM /
Last active Jun 4, 2019
Most simple tenacity usage
# Just a simple one-liner to quickly make a thing retrieable
import tenacity as tn
@tn.retry(wait=tn.wait_exponential(multiplier=1, min=10), stop=tn.stop_after_attempt(5))
EdvardM /
Last active Apr 14, 2019
Toy program for playing with D'Hondt system
import argparse
import logging
import random
import string
from itertools import groupby
from operator import itemgetter
PARTIES = ["Kesk", "Kok", "SDP", "Sin", "PS", "Vihr", "Vas", "RKP", "KD", "TL", "EOP", "FP", "IPU", "KP", "KTP", "Lib",
"PP", "SKE", "SKP"]
EdvardM /
Last active Jun 18, 2019
Just a simply utility to apply sequence of functions, applying each in turn to return value of previous application
def mapply(init, *funs, stop=lambda x: x is None):
Apply list of funs from first to last, stopping when encountering first
return value of None.
init (Any): initial value
*funs (*Callable[..., Any]): List of functions to apply
Keyword args:
EdvardM /
Last active Jul 14, 2018
Just a simple tool to remap long regular patterns with shorter ones, useful for comparing two sets of data for equality
import re
import sys
import string
def _get_fh(has_fname):
if has_fname:
return open(sys.argv[1])
return sys.stdin
EdvardM /
Created Apr 24, 2018
Simple pre-commit hook for checking python files with pycodestyle before committing
set -u
FILES=$(git diff --cached --name-only --diff-filter=ACM)
pycodestyle ${FILES}
EdvardM /
Last active Mar 27, 2018
Make mock assertion failures readable
# mock objects print assertion failures in a way that is hard to read.
# Example:
# AssertionError: Expected call: <mock assertion failure: 1122331 ...>
# Actual call: <mock assertion failure: 112331 ...>
# After the patch:
# AssertionError:
EdvardM / bowling.hs
Last active Mar 19, 2018
Bowling kata, haskell version
View bowling.hs
-- Credits to awesome Haskell Master Sami Hangaslammi (shangaslammi) who told to learn unfoldr, which
-- leads IMO to very elegant solution.
-- 2012: original version, Hspec outdated, no longer available
-- 2018-03-19: Updated to recent Hspec
-- Running: cabal install hspec-2.4.4 && runhaskell bowling.hs
import Test.Hspec
import Data.List (unfoldr)
EdvardM /
Created Feb 21, 2018
Simple stats module
from statistics import mean, median_low, stdev, mode
def stat(lst):
if not lst:
return None
_min = min(lst)
_max = max(lst)
_mean = mean(lst)
You can’t perform that action at this time.