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 / 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"}}
@hannesbe
hannesbe / curl-header-with-follow-redirect.sh
Created August 25, 2018 16:06 — forked from rvflash/curl-header-with-follow-redirect.sh
Display request headers with command line curl and follow redirects
#!/usr/bin/env bash
declare -- url="$1"
if [[ -z "$url" ]]; then
echo "Missing url"
exit 1
fi
# @example https://goo.gl/
curl -sLD - "$url" -o /dev/null
@hannesbe
hannesbe / hassio_spotify_playlists.sh
Last active July 8, 2018 16:49
Gets your spotify playlists (name and uri), useful for configuring a Home Assistant Spotify player (https://community.home-assistant.io/t/spotify-playlist-player/22491). This should work as is on hassio, for other setups change /config/.spotify-token-cache to the actual path of your HA config/.spotify-token-cache
# Gets your spotify playlists (name and uri), useful for configuring a Home Assistant Spotify player (https://community.home-assistant.io/t/spotify-playlist-player/22491).
# This should work as is on hassio, for other setups change /config/.spotify-token-cache to the actual path of your HA config/.spotify-token-cache
HA_SPOTIFY_TOKEN=`cat /config/.spotify-token-cache | jq --raw-output .access_token`
curl -X GET "https://api.spotify.com/v1/me/playlists?offset=0&limit=50" -H "Authorization: Bearer $HA_SPOTIFY_TOKEN" | jq '.items[] | {name: .name, uri: .uri}'
@hannesbe
hannesbe / fix_zsh_history.sh
Created July 5, 2018 23:57
Fix for a corrupt `.zsh_history` file
cd ~
mv .zsh_history .zsh_history_bad
strings .zsh_history_bad > .zsh_history
fc -R .zsh_history
@hannesbe
hannesbe / install_themes.sh
Last active March 18, 2018 15:38 — forked from molcay/install_themes.sh
Themes from Noobslab.com
#!/bin/bash
sudo add-apt-repository ppa:noobslab/themes
sudo add-apt-repository ppa:noobslab/icons
sudo add-apt-repository ppa:ravefinity-project/ppa
sudo add-apt-repository ppa:snwh/pulp
sudo apt-get update
sudo apt-get install humanitary-gtk-theme
sudo apt-get install humanitary-icon-theme
@hannesbe
hannesbe / install-rpi-watchdog.sh
Last active March 17, 2018 20:40 — forked from P8H/install_watchdog.sh
Watchdog install script for Raspberry Pi
#/bin/bash
# Watchdog install script for raspberry pi
# based on http://binerry.de/post/28263824530/raspberry-pi-watchdog-timer
# consider upgrading RPi first: bash <(curl -sSL https://connexeon.link/upgrade-rpi)
#
# Just run this oneliner:
# bash <(curl -sSL https://gist.github.com/hannesbe/c2018b397691bc1a32b6e039c2300dc8/raw)
sudo -u root -H /bin/bash <<EOF
@hannesbe
hannesbe / install-unifi-rpi.sh
Last active March 18, 2018 08:17
Install script for UBNT Unifi controller on RPi
#/bin/bash
# Install script for UBNT Unifi controller on RPi
#
# Just run this onliner to install
# bash <(curl -sSL https://gist.github.com/hannesbe/48c6c45c99cfe9d41cc90a78ef965c25/raw)
echo "deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti" | sudo tee /etc/apt/sources.list.d/100-ubnt.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv C0A52C50
sudo apt-get update
@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;
@hannesbe
hannesbe / fix_gitlab_https_repo.sh
Last active March 13, 2018 06:11 — forked from m14t/fix_github_https_repo.sh
Convert HTTPS gitlab clones to use SSH
#/bin/bash
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password (for GitLab repos).
#
# Just run this from your clone's path:
# bash <(curl -Ss https://gist.githubusercontent.com/hannesbe/f7ad2c8bbbfa7be6f76456183539f853/raw)
REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'`
if [ -z "$REPO_URL" ]; then
echo "-- ERROR: Could not identify Repo url."
echo " It is possible this repo is already using SSH instead of HTTPS."
@hannesbe
hannesbe / install-source-code-pro.sh
Created February 18, 2018 05:54
Script to install Source Code Pro font on Ubuntu (17.10)
[ -d /usr/share/fonts/opentype ] || sudo mkdir /usr/share/fonts/opentype
sudo git clone https://github.com/adobe-fonts/source-code-pro.git /usr/share/fonts/opentype/scp
sudo fc-cache -f -v