Skip to content

Instantly share code, notes, and snippets.

View HugoGresse's full-sized avatar

Hugo Gresse HugoGresse

View GitHub Profile
@HugoGresse
HugoGresse / Tuya_TS0044_1_remote.yaml
Created February 16, 2024 12:39
HA Tuya TS0044 4x
blueprint:
name: ZHA - Tuya 4-Button Switch
description: Automate your Tuya 4-Button Switch using ZHA events.
domain: automation
input:
tuya_4button_switch:
name: Tuya 4-Button Switch
description: Tuya 4-Button Switch to use
selector:
device:
@HugoGresse
HugoGresse / Tuya_TS0044_1_remote.yaml
Last active February 16, 2024 12:05 — forked from Soulfly999/Tuya_TS0044_1_remote.yaml
Zigbee2MQTT - Tuya 4-Button Scene Switch blueprint for Homassistant
blueprint:
name: Tuya Zigbee 4 button remote
description: "Blueprint for use with Tuya Zigbee 4 button remote (TS0044_1) on Zigbee2MQTT"
domain: automation
input:
switch:
name: Tuya Zigbee 4 button remote
description: Tuya Zigbee 4 button remote to use
selector:
entity:
@HugoGresse
HugoGresse / zha-moes-smart-knob-control.yaml
Last active February 8, 2024 09:47
Home Assistant Smart knob TV controls
blueprint:
name: ZHA - Moes Tuya Smart Knob (TS004F) controller for media_player
description: Control the volume of the media player and set play/pause on it
domain: automation
source_url: https://gist.github.com/HugoGresse/552c494b33b2b35c4c5903f7ef28cd42
input:
remote:
name: Remote
description: Moes Tuya Smart Knob Device to use
selector:
@HugoGresse
HugoGresse / runInParallel.js
Last active April 2, 2024 19:43
Run many operations in parallel on a single array. Example: downloading 10 files by 10 files from a 1000 urls input
const runInParallel = async (dataList, numberOfParallelRequest, runFunction) => {
return new Promise((resolve) => {
const isRunCompleted = (runStatus) => {
return Object.values(runStatus).every(status => status === false)
}
const dataListSplit = splitArray(dataList, numberOfParallelRequest)
console.log('dataListSplit', dataListSplit.length)
@HugoGresse
HugoGresse / list.md
Last active March 11, 2021 15:20
React Native, the good, the bad and the ugly

Here is a small list of interesting fact about React Native, as used inside PlantNet Mobile apps for Android & iOS, 6 million users

This is a work in progress and is completed as time flies

Good

  • Fast refresh is so good
  • a big community
  • fast to dev
@HugoGresse
HugoGresse / InAppBrowser.java
Created November 29, 2019 15:13
Cordova inapp browser plugin to open the camera
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@HugoGresse
HugoGresse / instruction.md
Created June 20, 2019 20:18
Install OPENJDK and fix unifi error on RPI

When trying to connect to Unify Network Controller interface, it was not responding. Checking the port with netstat showed the service was not started but service unify statusreported the contrary.

Device: RPi 3 with 16gb storage

ISSUE

java JDK not up to date on latest raspbian image for a long time

Solution

@HugoGresse
HugoGresse / adbx
Last active November 27, 2022 11:19
Adb command to set proxy (WIP)
#!/bin/bash
usage() {
echo "Usage:"
echo " adbx proxy set"
echo " adbx proxy get"
echo " adbx proxy remove"
}
@HugoGresse
HugoGresse / FFMPEG command meetup.md
Last active March 19, 2024 18:57
FFMPEG personal list to cut & normalize video

Setup

brew install ffmpeg

Normalize audio in place (easiest solution) EBU R128

pip install ffmpeg-normalize
ffmpeg-normalize input.mp4 -o output.mp4 -c:a aac -b:a 192k --progress
@HugoGresse
HugoGresse / MainActivity.java
Created March 2, 2016 11:06
changeFragment
/**
* Change the current displayed fragment by a new one.
* - if the fragment is in backstack, it will pop it
* - if the fragment is already displayed (trying to change the fragment with the same), it will not do anything
*
* @param frag the new fragment to display
* @param saveInBackstack if we want the fragment to be in backstack
* @param animate if we want a nice animation or not
*/