This file contains hidden or 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
| #!/bin/bash | |
| # Create InfluxDB and Grafana 4.4.3 (latest) | |
| source /etc/os-release | |
| OPSYS=${ID^^} | |
| curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add - | |
| test $VERSION_ID = "8" && echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list | |
| test $VERSION_ID = "9" && echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list | |
| curl https://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add - |
This file contains hidden or 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
| #!/bin/bash | |
| # create new folder for the day | |
| DATE=`date +%Y-%m-%d_%H-%M-%S` | |
| BACKUP_PATH=~/openhab2-backup | |
| # backup metadata in ./meta | |
| mkdir -p $BACKUP_PATH | |
| sh /usr/share/openhab2/runtime/bin/backup $BACKUP_PATH/openhab2-backup-$DATE.zip |
This file contains hidden or 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
| #! /usr/bin/python3 | |
| try: | |
| # For Python 3.0 and later | |
| from urllib.request import urlopen | |
| from urllib.parse import quote | |
| except ImportError: | |
| # Fall back to Python 2's urllib2 | |
| from urllib2 import urlopen | |
| from urllib2 import quote |
This file contains hidden or 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
| #!/usr/bin/env bash | |
| set -e | |
| url="https://web.getbring.com/locale/articles.de-DE.json" | |
| echo "GET ${url}" >&2 | |
| curl -X GET \ | |
| -H 'Content-Type: application/json' \ | |
| "${url}" | \ | |
| jq --raw-output 'to_entries[] as $e | "\($e.value)"' | \ |
This file contains hidden or 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 Union | |
| def scale(x: Union[int|float], | |
| min_x: Union[int|float], max_x: Union[int|float], | |
| a: Union[int|float], b: Union[int|float]) -> float: | |
| """ | |
| Scale a number x relative to domain [min_x, max_x] to a domain [a,b] | |
| Parameters: | |
| x (int|float): The value to scale |
This file contains hidden or 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 numpy as np | |
| from typing import Union | |
| def cyclical_feature(x: Union(float|np.array), max_x: float): | |
| """ | |
| Transforms a linear scale feature to a feature pair that represent a cyclical one. | |
| Assumes that the feature is in interval [0, max_x] | |
| See also https://towardsdatascience.com/cyclical-features-encoding-its-about-time-ce23581845ca | |
This file contains hidden or 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
| # Rename this distribution example file to motion.conf | |
| # | |
| # This config file was generated by motion 4.1.1 | |
| # Documentation: /usr/share/doc/motion/motion_guide.html | |
| ############################################################ | |
| # Daemon | |
| ############################################################ | |
| # Start in daemon (background) mode and release terminal (default: off) |
This file contains hidden or 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 numpy as np | |
| def filter_tensor_by_mx(tensor, mx): | |
| tshape = tensor.shape | |
| row_ix = np.arange(mx.shape[0]) | |
| col_ix = np.arange(mx.shape[1]) | |
| ix = np.array(np.meshgrid(row_ix, col_ix)).T.reshape(-1,2).T | |
| pane = rnd_ix_mx.ravel() | |
| res = tensor[pane, ix[0], ix[1]].reshape(mx.shape) | |
| return res |
This file contains hidden or 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 | |
| import seaborn as sns | |
| def cardinalities(df: pd.DataFrame, plot: bool = False): | |
| """ | |
| Analyses cardinalities in a data frame | |
| df DataFrame the data frame to be analyized | |
| plot Plot whether to plot rather than return the result DataFrame | |
| returns (DataFrame, Plot) of a matrix M(i,j) that reads row-wise, |
This file contains hidden or 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 scipy | |
| import scipy.cluster.hierarchy as sch | |
| def cluster_corr(corr_array, inplace=False, impute_nan=False): | |
| """ | |
| Original author: @WYegelwel (https://wil.yegelwel.com/cluster-correlation-matrix/) | |
| Rearranges the correlation matrix, corr_array, so that groups of highly | |
| correlated variables are next to eachother | |
OlderNewer