Skip to content

Instantly share code, notes, and snippets.

View hannesbe's full-sized avatar
🏠
Working from home

Hannes Van de Vel hannesbe

🏠
Working from home
View GitHub Profile
@hannesbe
hannesbe / entity_rename_find_replace.j2
Created August 7, 2019 04:34
Jinja2 template, generating hass-cli commands, to make renaming Z-Wave entities for example a lot easier
{%- set find = "shenzhen_neo_electronics_co_ltd_water_leakage_detector" -%}
{%- set replace = "boiler_water_leak_sensor" -%}
{%- for item in states -%}
{% if find in item.object_id %}
hass-cli entity rename --name "{{ item.object_id.replace(find, replace).replace("_", " ")|title }}" {{ item.entity_id }} {{ item.entity_id.replace(find, replace) }}
{%- endif -%}
{%- endfor -%}
@hannesbe
hannesbe / hass_generate_customize.j2
Last active January 2, 2019 19:02
Home Assistant Jinja template to create fast customize for groups, sensors, covers etc... Just change that first line below 'sensor' to 'group', 'covers' etc..
{% for state in states.sensor -%}
{% if loop.first %}
{% elif loop.last %}
{% else %}
{% endif %}
{{- state.entity_id }}:
friendly_name: '{{ state.attributes.friendly_name|replace("_"," ",)|title() if state.attributes.friendly_name is defined else state.name|replace("_"," ",)|title() }}'
emulated_hue_hidden: {{state.attributes.emulated_hue_hidden if state.attributes.emulated_hue_hidden is defined else 'False' }}
hidden: {{state.attributes.hidden if state.attributes.hidden is defined else "False"}}
@Snipercaine
Snipercaine / Broadlink.yaml
Created September 27, 2018 18:18
Broadlink IR and Home Assistant - Examples for Config and Automations
@basrieter
basrieter / latest-widevine.sh
Created July 31, 2018 07:37 — forked from ruario/intro-latest-widevine.md
Fetches the latest Linux Widevine binary so that it can be used by Vivaldi.
#!/usr/bin/env bash
available () {
command -v $1 >/dev/null 2>&1
}
# Make sure we have wget or curl
if available wget; then
SILENT_DL="wget -qO-"
LOUD_DL="wget"
@hannesbe
hannesbe / upgrade-rpi.sh
Last active April 30, 2018 03:17
Update script for RPi (packages + firmware)
#/bin/bash
# Upgrade script for RPi (packages + firmware)
#
# Just run this onliner to launch updates, cleanup & prompt to reboot if required
# bash <(curl -sSL https://connexeon.link/upgrade-rpi)
function needs_reboot {
if [ -f /var/run/reboot-required ]; then
read -p "Restart needed. Reboot? (y/N) " answer;
anonymous
anonymous / -
Created September 25, 2017 22:48
System: Host: nuci7-mint18 Kernel: 4.10.0-35-generic x86_64 (64 bit gcc: 5.4.0)
Desktop: Cinnamon 3.4.6 (Gtk 3.18.9-1ubuntu3.3) dm: lightdm Distro: Linux Mint 18.2 Sonya
Machine: Mobo: Intel model: NUC7i7BNB v: J31145-303
Bios: Intel v: BNKBL357.86A.0052.2017.0918.1346 date: 09/18/2017
CPU: Dual core Intel Core i7-7567U (-HT-MCP-) cache: 4096 KB
flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx) bmips: 14016
clock speeds: min/max: 400/4000 MHz 1: 3831 MHz 2: 3722 MHz 3: 3770 MHz 4: 3789 MHz
Graphics: Card: Intel Device 5927 bus-ID: 00:02.0 chip-ID: 8086:5927
Display Server: X.Org 1.18.4 drivers: intel (unloaded: fbdev,vesa)
Resolution: [email protected]
@hannesbe
hannesbe / add-connexeon-vpn.ps1
Last active January 31, 2018 17:32
Powershell script to create PPTP VPN Connexeon in Windows, for all users & no additional login required client has joined AD
Add-VpnConnection -Name "VPN Connexeon" -ServerAddress "vpn.connexeon.com" -TunnelType Pptp -EncryptionLevel Required -AuthenticationMethod MSChapv2 -AllUserConnection -RememberCredential -PassThru -UseWinlogonCredential
Set-VpnConnection "VPN Connexeon" -AllUserConnection -SplitTunneling $True
Add-VpnConnectionRoute -ConnectionName "VPN Connexeon" -DestinationPrefix 10.0.0.0/12 -PassThru
Add-VpnConnectionRoute -ConnectionName "VPN Connexeon" -DestinationPrefix 10.111.0.0/16 -PassThru
Add-VpnConnectionRoute -ConnectionName "VPN Connexeon" -DestinationPrefix 10.50.0.0/16 -PassThru
@hannesbe
hannesbe / pdns-mysql-update-snippets.sql
Last active April 8, 2017 02:37
SQL snippets to bulk update records & soa
/* Update SOA records for zones having a certain IP in the content */
UPDATE records
SET `content` = 'ns1.connexeon.com. domains.connexeon.com. 2017040701 1200 400 1209600 300'
WHERE `id` IN
(SELECT `id`
FROM records_copy
WHERE `type`='SOA'
AND `domain_id` IN
(SELECT DISTINCT `domain_id`
FROM records_copy
anonymous
anonymous / gmailAutoarchive.js
Created January 8, 2017 16:39
function gmailAutoarchive() {
var delayDays = 2; // will only impact emails more than 48h old
var maxDate = new Date();
maxDate.setDate(maxDate.getDate()-delayDays); // what was the date at that time?
// Get all the threads labelled 'autoarchive'
var label = GmailApp.getUserLabelByName("autoarchive");
var threads = label.getThreads(0, 400);
@romgrk
romgrk / dropdown.zsh
Last active December 17, 2017 22:38
# For usage with https://gist.github.com/romgrk/0ba7a864a4e6c76eefd3
# drop-down-terminal gnome extension configuration
# F11/A-F11/C-F11 size-down/medium/up the terminal
# F12 + [0-9] sets background opacity
# F11 & M-F11 = sizeup/sizedown
function _dropdown_h_normal () {
dropdownterminal h 50%
}