Skip to content

Instantly share code, notes, and snippets.

@borgand
borgand / README.md
Created April 24, 2023 07:15
Personal notification with Home Assistant + Node Red + OpenAI + Telegram

Personal Notifications with a personal touch

I wanted HA to send me notifications whether I should bring my umbrella today and when the washer or dryer machines finish. Of course, HA has it's built in notifications to mobile apps, and while these would do the job, I wasn't sure all of my family install the mobile apps, so I wanted to tap on something we already have. Comparing different notifications options, I decided to go with Telegram, since it seemed the easiest (no need to create App in dev portal).

Disclaimer: I'm quite new to both HA automations and Node Red, so I assume much of this could be done more efficiently

Node Red Nodes

@borgand
borgand / application_helper.rb
Created May 8, 2012 11:32
Rails HAML helper method to display Twitter Bootstrap alert boxes
module ApplicationHelper
# Display alert box with message or optional block
def alert_box(alert_type = :info)
haml_tag :div, :class => 'row-fluid' do
haml_tag :div, :class => "span9 alert alert-#{alert_type}" do
haml_tag :a, '×', :class => 'close', :'data-dismiss' => 'alert'
block_given? ? yield : msg
end
end
@borgand
borgand / devise.et.yml
Created April 16, 2012 10:36
Estonian translation for Devise
# encoding: utf-8
et:
errors:
messages:
expired: "on aegunud, palun küsi uus"
not_found: "ei leitud"
already_confirmed: "on juba kinnitatud, proovi sisse logida"
not_locked: "ei olnud lukus"
not_saved:
@borgand
borgand / git-merge-svn
Last active January 7, 2019 06:44
A helper script to set *svn:mergeinfo* property when using `git svn dcommit` on merged git branches.This makes it possible to merge two SVN branches using **git-svn**.NB! the merged-from branch **MUST** be pushed to SVN.USAGE: git merge-svn <branch name>EDIT: added exit condition when mergeinfo calculation fails to avoid pushing incomplete merge…
#!/bin/bash
function usage {
echo "USAGE: git merge-svn <from> [<to>]"
echo ""
echo " from The branch name to be merged FROM"
echo " to Optional branch name to be merged onto. Default: HEAD"
echo ""
}
@borgand
borgand / auth_test.sh
Created September 26, 2013 13:54
Round-trip check for Shibboleth and SimpleSAMLphp SSO setup. Uses sed to carve out tokens, so you must adapt to your HTML layout.
#!/bin/bash
# This script is used make a full roundtrip test to SimpleSAMLphp based SSO
# Exit statuses indicate problem and are suitable for usage in Nagios.
BASENAME=$(basename $0)
if [[ $1 == '-h' || $1 == '--help' ]]; then
cat <<EOF
USAGE: $BASENAME [URL] [test-string] [username] [password]
@borgand
borgand / ssl-cert-check
Last active December 31, 2017 02:45
Script to check SSL certificates for expiry. Slightly modified version of: http://prefetch.net/code/ssl-cert-check
#!/bin/bash
#
# Program: SSL Certificate Check <ssl-cert-check>
#
# Source code home: http://prefetch.net/code/ssl-cert-check
#
# Documentation: http://prefetch.net/articles/checkcertificate.html
#
# Author: Matty < matty91 at gmail dot com >
# Modified: Laas Toom <laas dot toom at gmail dot com >
#!/bin/bash
# Function to connect to SMTP and send mail to it
# returns:
# 0 - SUCCESS
# 1 - FAILURE: unable to complete session to DATA command
# 2 - FAILURE: problems after DATA command (server did not enqueue the message)
function bash_mail(){
# Default configuration
# Can be overridden by ARGV in order: TO, SUBJECT, MESSAGE, FROM, SERVER
#!/bin/bash
# Shell script to mount SSHFS while MacFusion is defunctional
# original idea by: renatojf
# written by: laas.toom@gmail.com
# Split the $1 for useful information
usr=${1/@*/}
usr=${usr:=$USER}
[[ $1 =~ ":" ]] && dst=${1/*:/}
@borgand
borgand / Vagrantfile
Created October 7, 2014 10:29
Generic multi-machine Vagrantfile that supports fast and easy way to get testing machines up and running. Provisioning is done through multi-tier shell scripting
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Landrush domain name suffix
# https://github.com/phinze/landrush
# For linux:
# sudo apt-get install -y resolvconf dnsmasq
# sudo sh -c 'echo "server=/vm/127.0.0.1#10053" > /etc/dnsmasq.d/vagrant-landrush'
# sudo service dnsmasq restart
#
@borgand
borgand / hangman.rb
Created February 10, 2016 18:52
Hangman implemented in 1 line of Ruby. Probably the ugliest piece of code I have written, but I was intrigued (and inspired) by the [Hangman implemented in 3 lines of Python](https://gist.github.com/danverbraganza/3320ccedd0eef2f2b88d)
->(license,word,scaffold,man,f){puts "You #{f.(word,scaffold,[],10,man,f) ? 'win!' : "loose!\n" + scaffold%man}\nWord was: #{word}"}.( 'https://opensource.org/licenses/MIT',File.read('/usr/share/dict/words').split.shuffle.find{|w| w=~/^\w+$/}.upcase,"|======\n| |\n| %4$s %1$s %6$s\n| %3$s%2$s%5$s\n| %7$s %9$s\n| %8$s %10$s\n|",%w(O T - \\ - / / | \\ | ),->(word,scaffold,guesses,guesses_left,man,f){[$stdout.print("#{guesses.join(', ')}(#{guesses_left} guesses left)\n #{scaffold%(man.take(10-guesses_left) + [' '] * guesses_left)}\n #{word.gsub(/./){|c| (guesses.include?(c) ? c : '_') + ' '}}: "), ->(guess){[(guesses<<guess).uniq!,word.include?(guess) && guesses_left || guesses_left -= 1][1]}.(gets[0].chomp.upcase)][1] > 0 ? (word.each_char.all?{|c| guesses.include?(c)} ? true : f.(word,scaffold,guesses,guesses_left,man,f)) : false})