Skip to content

Instantly share code, notes, and snippets.

@asmaier
asmaier / generalized_means.md
Last active November 14, 2023 13:26
Derivation of limits of the generalised mean of two numbers

Generalized Mean

The generalized mean $M$ (also called power mean or Hölder mean) of two numbers $a$ and $b$ of degree $p$ is

$$ M_{p}(a,b) = \left(\frac{a^{p} + b^{p}}{2}\right)^{\frac{1}{p}} $$

The following derivations often make use of the trick

@asmaier
asmaier / pycaret_timeseries.ipynb
Created July 25, 2023 09:31
A first look at the new timeseries forecasting module of pyCaret
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@asmaier
asmaier / poisson_confint.ipynb
Created June 16, 2023 16:03
Computing confidence intervals for Poisson distributions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@asmaier
asmaier / latex2tufte.md
Last active November 11, 2022 21:13
Converting latex files into HTML5 with Tufte Css

Latex to Tufte-HTML

To convert LaTeX to HTML5 with tufte-css layout one first needs to copy the file tufte.css and the corresponding font directory et-book from the tufte-css github repo into your working directory.

Then we need to extract the default html5 template from pandoc via

pandoc -D html5 > html5.html

This template must be modified and the tags <article> and <section> should be added around the body of the template like

@asmaier
asmaier / KafkaProducerIT.java
Last active March 23, 2022 11:16
Simple java junit test of an apache kafka producer (works with Kafka 0.11.0.2) (see also https://github.com/asmaier/mini-kafka)
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Properties;
import org.I0Itec.zkclient.ZkClient;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
@asmaier
asmaier / load_parquet_s3.py
Last active March 5, 2021 03:43
Pyspark script for downloading a single parquet file from Amazon S3 via the s3a protocol. It also reads the credentials from the "~/.aws/credentials", so we don't need to hardcode them. See also https://hadoop.apache.org/docs/stable/hadoop-aws/tools/hadoop-aws/index.html .
#
# Some constants
#
aws_profile = "your_profile"
aws_region = "your_region"
s3_bucket = "your_bucket"
#
# Reading environment variables from aws credential file
#
@asmaier
asmaier / install_m2crypto.md
Last active May 18, 2020 17:01 — forked from andrisasuke/install_m2crypto.txt
python install m2crypto on Mac OS X

Do

$> brew install openssl
$> brew install swig

Now add these lines to your ~/.zshrc file on Mac OS X

# this is very slow, see https://github.com/Homebrew/brew/issues/3327
# OPENSSL=$(brew --prefix openssl)
# this is much faster
@asmaier
asmaier / start_cloudera.sh
Created July 17, 2017 16:19
Start script for cloudera quickstart docker container (see https://dzone.com/articles/docker-how-to-get-started-with-cloudera)
#!/bin/bash
docker run --name cdh --hostname "quickstart.cloudera" --privileged=true -t -i -d \
-p 80:80 \
-p 7180:7180 \
-p 8888:8888 \
cloudera/quickstart /usr/bin/docker-quickstart
docker exec -ti cdh /home/cloudera/cloudera-manager --express
@asmaier
asmaier / python_type_hints.md
Last active January 16, 2018 17:18
Minimal overview of Python Type Hints

Python Type Hints

  • Type after variable
  • Problem: IDE cannot suggest variable name based on type

Primitives

From

// primitive function