Skip to content

Instantly share code, notes, and snippets.

View paullaffitte's full-sized avatar

Paul Laffitte paullaffitte

View GitHub Profile
@paullaffitte
paullaffitte / ikea_e2001_e2002.yaml
Last active February 12, 2024 20:25
IKEA Styrbar (E2001/E2002) remote control blueprint for Home Assistant
# Forked from: https://github.com/EPMatt/awesome-ha-blueprints/blob/9ee5920a3633c87bd8ee8713b83bbbf4705cc31d/blueprints/controllers/ikea_e2001_e2002/ikea_e2001_e2002.yaml
# Blueprint metadata
blueprint:
name: Controller - IKEA E2001/E2002 STYRBAR Remote control
description: |
# Controller - IKEA E2001/E2002 STYRBAR Remote control
Controller automation for executing any kind of action triggered by the provided IKEA E2001/E2002 STYRBAR Remote control. Allows to optionally loop an action on a button long press.
Supports deCONZ, ZHA, Zigbee2MQTT.
@paullaffitte
paullaffitte / cmprec.sh
Created August 21, 2021 15:55
Recursively compare files
#! /bin/bash
if [[ $# != 2 ]]; then
echo "usage: cmprec <source1> <source2>"
exit 1
fi
SOURCE1=$1
SOURCE2=$2
@paullaffitte
paullaffitte / histctx.completion.bash
Last active October 28, 2021 09:45
A helper to handle multiple history contexts in bash
#!/bin/bash
function _histctx_completions {
local contexts=$(histctx ls | awk '{print $4}' | tail -n +2)
case "$COMP_CWORD" in
1)
local commands="set"
commands+=" temporary tmp"
commands+=" list ls"
@paullaffitte
paullaffitte / bash-prompt.sh
Created January 11, 2021 11:26
My personal bash prompt, including current time and kubernetes context/namespace
kube_prompt() {
echo -n '\[\e[91m\]'$(kubectl config current-context)'\[\e[39m\]'
K8S_NS=$(kubectl config view --minify --output 'jsonpath={..namespace}')
if [[ ! -z $K8S_NS ]]; then
echo "|\[\e[0;32m\]$K8S_NS\[\e[39m\]"
fi
}
date_prompt() {
echo -e "$(date +%H:%M:%S).$(date +%N | cut -b1-2)"
@paullaffitte
paullaffitte / srscopes.sh
Created September 23, 2020 12:41
List Semantic-Releases scopes in a git repository
#! /usr/bin/env bash
git log --pretty=oneline --abbrev-commit | grep -oP '\(([^\)]*)\):' | sort | uniq | cut -c2- | sed 's/..$//'
@paullaffitte
paullaffitte / hash.js
Last active May 16, 2020 17:48
Hash for fun
const inputs = [
'Bonjour monsieur Dupont ! Comment allez-vous ?..',
'Bonjour monsieur Dupont ! Comment allez-vous ?',
'Bonjour monsieur Dupond ! Comment allez-vous ?',
'test',
'testt',
'tests',
'a',
'A',
'B',
@paullaffitte
paullaffitte / hmm.js
Last active April 17, 2020 05:08
Hidden Makrov Models examples in javascript and python
/* Example from page 22
const makrovChain = {
q: {
property: 0.7,
transitions: {
q: 0.7,
r: 0.1,
s: 0.2,
},
emissions: {
@paullaffitte
paullaffitte / gen-client-cert.sh
Last active February 12, 2020 11:07
Generate client ssl certificate
#! /usr/bin/env bash
if [ $# -ne 1 ]; then
echo "please choose a name for the certificate"
exit 1
fi
openssl genrsa -out "$1.key" 4096
openssl req -new -key "$1.key" -out "$1.req"
openssl x509 -req -in "$1.req" -CA rootCA.pem -CAkey rootCA.key -set_serial 101 -extensions client -days 500 -outform PEM -out "$1.cer"
@paullaffitte
paullaffitte / three-js-oculus-go-bug.html
Created November 28, 2019 06:35
This is an example of a bug happening with three.js on oculus go with oculus browser when using a video and a canvas as textures
<!DOCTYPE html>
<html>
<body>
<div class="player">
<canvas></canvas>
<video src="https://threejs.org/examples/textures/MaryOculus.webm" loop autoplay crossOrigin="" controls="false" style="display: none;"></video>
</div>
<canvas id="texture-canvas" width="500" height="100" style="display: none;"></canvas>
@paullaffitte
paullaffitte / mlt_proxify.sh
Last active August 25, 2019 08:12
An MLT proxifier for shotcut
#!/usr/bin/env bash
INPUT="$1"
if [[ -z "$INPUT" ]]; then
echo 'Usage: proxify [filename.mlt]'
echo '(The current folder sould include a "raw" folder containing your raw footages in mp4 format)'
echo 'xpath is required for this tool to work'
exit
fi