This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Callable, Any, ParamSpec, TypeVar | |
a = TypeVar("a") | |
b = TypeVar("b") | |
c = TypeVar("c") | |
P = ParamSpec("P") | |
def delay_call( | |
func: Callable[P, a], *args: P.args, **kwargs: P.kwargs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
import itertools | |
import warnings | |
from typing import ( | |
Any, | |
Callable, | |
Generator, | |
Generic, | |
Iterable, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
MANDATORY_ENV_VARS = {'TEMP', 'USER'} | |
# Python 3.8 or higher, using empty set is falsy: | |
if missing_vars := MANDATORY_ENV_VARS.difference(os.environ): | |
raise EnvironmentError(f"The following variables were not set: {missing_vars}") | |
# Python 3.7 or lower: | |
if not MANDATORY_ENV_VARS.issubset(os.environ): | |
missing_vars = MANDATORY_ENV_VARS.difference(os.environ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import pandas as pd | |
import numpy as np | |
zelfdodingen = ( | |
pd.read_excel( | |
"https://www.cbs.nl/-/media/_excel/2020/27/aanvullende-statistiek-zelfdoding-2019.xls", | |
usecols=[0, 3, 7], # Alleen kolommen met jaartal en totaal aantal zelfdodingen | |
skiprows=4, # Eerste rijen met kolomkoppen overslaan | |
names=["Jaar", "Totaal", "Totaal per 100.000"], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from abc import ABC, abstractmethod | |
from collections.abc import Sequence | |
import copy | |
from shapely.geometry import asShape, LineString | |
class CopyMixin: | |
def copy(self, deep=False): | |
if deep: | |
return copy.deepcopy(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
tellerstanden = pd.read_excel('Tellerstanden_PIAF.xlsx', sheet_name='Blad3') | |
tellerstanden = tellerstanden.melt(id_vars=['datum '], var_name='tagcode', value_name='waarde') | |
tellerstanden.columns = ['datum', 'tagcode', 'waarde'] | |
tellerstanden.to_excel('Tellerstanden_PIAF_long.xlsx', index=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Remify & Cornify The Daily WTF | |
// @namespace https://github.com/Hugovdberg | |
// @version 0.2.1 | |
// @description Replace comments with dark green text and highlight the cornify spans. | |
// @author Hugo van den Berg | |
// @match thedailywtf.com/* | |
// @grant none | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'full.tpl' %} | |
{% set altair = {'vis_number': 0} %} | |
{% block header %} | |
<script src="https://cdn.jsdelivr.net/npm/vega@3"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vega-lite@2"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vega-embed@3"></script> | |
{{super()}} | |
{% endblock header %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'full.tpl' %} | |
{% block header %} | |
<script src="https://cdn.jsdelivr.net/npm/vega@3"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vega-lite@2"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vega-embed@3"></script> | |
{{super()}} | |
{% endblock header %} | |
{%- block data_priority scoped -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(microbenchmark) | |
library(ggplot2) | |
HugovdBerg <- function(x, method = "one", na.rm = FALSE) { | |
x <- unlist(x) | |
if (na.rm) { | |
x <- x[!is.na(x)] | |
} | |
# Get unique values |
NewerOlder