Skip to content

Instantly share code, notes, and snippets.

View tvwerkhoven's full-sized avatar

Tim van Werkhoven tvwerkhoven

  • ASML
  • Netherlands
View GitHub Profile
@tvwerkhoven
tvwerkhoven / rsync_backup.sh
Last active July 5, 2023 05:30 — forked from necolas/rsync_backup
Improved script: - Check if run as root - Clarify rsync(1) flags - Add --inplace for performance, extra preservation flags - Check bless(8) target before setting Improved exclusion file: - Included files listed by Carbon Copy Cloner
#!/bin/bash
#
# This script backups an OS X system to an external volume, effectively
# cloning it. It is based on [0], [1] and [2] for OS X and [3] and [4] for
# Linux. One could also use commercial tools like SuperDuper! or Carbon Copy
# Cloner. The latter website has an interesting list[5] on what files to
# exclude when cloning.
#
# Exclusions (from CCC[5]), see rsync_excludes_osx.txt
#
@tvwerkhoven
tvwerkhoven / notify-or-do-something-when-an-appliance-like-a-dishwasher-or-washing-machine-finishes.yaml Home Assistant Blueprint: Notify or do something when an appliance like a dishwasher or washing machine finishes
blueprint:
name: Appliance has finished+
description: Do something when an appliance (like a washing machine or dishwasher)
has finished as detected by a power sensor, and show power consumption.
domain: automation
input:
power_sensor:
name: Power Sensor
description: 'Power sensor entity (e.g. from a smart plug device).'
selector:
@tvwerkhoven
tvwerkhoven / kMeans.py
Created June 2, 2018 13:31 — forked from bistaumanga/kMeans.py
KMeans Clustering Implemented in python with numpy
'''Implementation and of K Means Clustering
Requires : python 2.7.x, Numpy 1.7.1+'''
import numpy as np
def kMeans(X, K, maxIters = 10, plot_progress = None):
centroids = X[np.random.choice(np.arange(len(X)), K)]
for i in range(maxIters):
# Cluster Assignment step
C = np.array([np.argmin([np.dot(x_i-y_k, x_i-y_k) for y_k in centroids]) for x_i in X])