Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
# Copyright (c) 2018, Sebastian Linke
# Released under the Simplified BSD license
"""
Simple interface to get user input.
Examples:
>>> import easyinput
@seblin
seblin / bits.py
Last active October 2, 2018 14:39
#!/usr/bin/env python3
class Bits(object):
def __init__(self, value=0):
"""
Build a new Bits()-object based on the given value.
Examples:
Bits(0b1001)
Bits(42)
@seblin
seblin / shcol.py
Last active December 17, 2018 12:42
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2013-2018 Sebastian Linke
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
#!/usr/bin/env python3
# Copyright (c) 2018-2019 Sebastian Linke
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
import io
import pandas as pd
TESTDATA = io.StringIO(
"""DateTime, Type, Amount, Rate
2017-01-08 11:43:00,buy,0.10000001,200.11
2017-01-08 11:43:00,buy,1.00000002,210.55
2017-01-10 16:11:44,sell,0.10000002,290.44
2017-01-11 18:43:00,buy,0.30000003,300.88
2017-01-12 18:55:00,buy,0.40000004,311.22
#!/usr/bin/env python3
from decimal import Decimal
import re
from urllib.request import urlopen
from xml.etree import ElementTree as etree
EUROFXREF_URL = 'https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml'
XPATH_PATTERN = './/*[@currency]'
RATES = {}
# https://adventofcode.com/2020/day/4
from operator import methodcaller
from pathlib import Path
INPUT_FILE = Path(__file__).parent / "input.txt"
class Document:
PASSPORT_KEYS = {
"byr", # (Birth Year)
#!/usr/bin/env python3
import fnmatch
import os
import re
import sys
from collections.abc import Iterable, Iterator, Mapping, Sequence
from dataclasses import dataclass
from itertools import batched, zip_longest
from locale import getlocale, LC_COLLATE, setlocale, strxfrm