Skip to content

Instantly share code, notes, and snippets.

@Danielbook
Danielbook / motion-illuminance-dimmable-nightmode.yaml
Last active June 8, 2024 18:14
Home Assistant blueprint. Motion-activated Light with illuminance, nightmode and dimmable
blueprint:
name: Motion-activated Light with illuminance, nightmode and dimmable
description: Turn on a light when motion is detected and illuminance is below a
set Lux level. The light will dim before it is turned off to signal that it has
not detected motion in quite a while. There is also two timers, on for daytime
and one for nighttime.
domain: automation
input:
motion_entity:
name: Motion Sensor
@sbyx
sbyx / low-battery-level-detection-notification-for-all-battery-sensors.yaml
Last active July 24, 2024 19:39
Home Assistant Blueprint: Low battery level detection & notification for all battery sensors
blueprint:
name: Low battery level detection & notification for all battery sensors
description: Regularly test all sensors with 'battery' device-class for crossing
a certain battery level threshold and if so execute an action.
domain: automation
input:
threshold:
name: Battery warning level threshold
description: Battery sensors below threshold are assumed to be low-battery (as
well as binary battery sensors with value 'on').
@coltenkrauter
coltenkrauter / fix-wsl2-dns-resolution
Last active July 24, 2024 17:10
Fix DNS resolution in WSL2
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.
@jmosbech
jmosbech / Exec-Sproc.ps1
Created May 26, 2013 19:40
Executes a Stored Procedure from Powershell and returns the first output DataTable
# Executes a Stored Procedure from Powershell and returns the first output DataTable
function Exec-Sproc{
param($Conn, $Sproc, $Parameters=@{})
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandType = [System.Data.CommandType]::StoredProcedure
$SqlCmd.Connection = $Conn
$SqlCmd.CommandText = $Sproc
foreach($p in $Parameters.Keys){
[Void] $SqlCmd.Parameters.AddWithValue("@$p",$Parameters[$p])