Skip to content

Instantly share code, notes, and snippets.

View borgand's full-sized avatar

Laas Toom borgand

  • Estonia
View GitHub Profile
@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 / 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})
@borgand
borgand / config-metarefresh.php
Last active November 25, 2015 16:05
TAAT eduGAIN metadata automaatne laadimine koos authproc lisamisega. Peamine juhend: https://simplesamlphp.org/docs/stable/simplesamlphp-automated_metadata
<?php
$config = array(
'sets' => array(
'edugain' => array(
'cron' => array('hourly'),
'sources' => array(
array(
@borgand
borgand / compile_static_git.sh
Last active August 29, 2015 14:13
Compile static git (e.g. for use in jailed server environment). NB! The kernel version must match that of the destination for the binary to work.
#!/bin/sh
# What git version to build
git_version="2.2.2"
# let's make sure we have all we need to proceed
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel autoconf
# Download sources
cd /tmp
@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 / 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 >
@borgand
borgand / activeadmin.et.yml
Created February 18, 2014 15:21
ActiveAdmin Estonian translation
et:
active_admin:
dashboard: Töölaud
dashboard_welcome:
welcome: "Tere tulemast Active Adminisse. See on vaikimisi töölaud."
call_to_action: "Et lisada töölauale sektsioonie, uuri 'app/admin/dashboard.rb'"
view: "Vaata"
edit: "Muuda"
delete: "Kustuta"
delete_confirmation: "Oled sa kindel, et soovid seda kustutada?"
@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 / Asset.php
Last active December 17, 2015 08:59
A SimpleSAMLphp Asset helper to produce MD5-fingerprinted URLs to assets. This allows long-term agressive caching by the browser while retaining instantaneous refreshing when the asset changes. Put this file in some SSP module's lib directory and rename the class name to match the module name (e.g. sspmod_mymodule_Asset).
<?php
/**
* Helper class for working with Assets
*
* @author Laas Toom, University of tartu
*/
class sspmod_utmodule_Asset {
/**
* Get absolute URL to a specified asset.
@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 ""
}