Skip to content

Instantly share code, notes, and snippets.

View internaut's full-sized avatar

Markus Konrad internaut

View GitHub Profile
@internaut
internaut / multisplit.py
Last active November 7, 2019 15:24
Split a string by multiple characters/strings. Test the function with pytest and hypothesis.
def str_multisplit(s, sep):
"""
Split string `s` by all characters/strings in `sep`.
:param s: a string to split
:param sep: sequence or set of characters to use for splitting
:return: list of split string parts
"""
if not isinstance(s, (str, bytes)):
raise ValueError('`s` must be of type `str` or `bytes`')
@internaut
internaut / parallelized.py
Last active February 2, 2018 14:06
Runtime optimization through vectorization and parallelization
"""
Runtime optimization through vectorization and parallelization.
Script 3: Parallel and vectorized calculation of haversine distance.
Please note that this might be slower than the single-core vectorized version because of the overhead that is caused
by multiprocessing.
January 2018
Markus Konrad <markus.konrad@wzb.eu>
"""
@internaut
internaut / pcp.R
Created September 27, 2016 13:07
Comparison of Parallel Coordinate Plots for Discrete and Categorical Data in R
### generate questionnaire data
library(triangle)
set.seed(0)
q1_d1 <- round(rtriangle(1000, 1, 7, 5))
q1_d2 <- round(rtriangle(1000, 1, 7, 6))
q1_d3 <- round(rtriangle(1000, 1, 7, 2))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@internaut
internaut / README.md
Last active August 29, 2015 14:00 — forked from JanDupal/README.md

Jekyll sorted_for plugin

Quick'n'dirty Jekyll plugin for sorted cycle.

Modification

This fork fixes two issues:

  • problems when specifiying sort fields like sort_by:'weight' (with ' or " characters)
  • problems when a collection entry does not have the specified sort field