Skip to content

Instantly share code, notes, and snippets.

@candale
candale / nagging_alert_notification.yaml
Last active October 17, 2024 16:23 — forked from pavax/nagging_alert_notification.yaml
Home Assistant Alert Notification Blueprint
blueprint:
name: Nagging Alerting Notification Automation
description: >
Trigger an alert based on the state of a given sensor.
The Alert is send to a mobile app device and repeats as long as the sensor is in the given state.
An additonal action can be specified. This might be useful to tts the message.
domain: automation
source_url: https://gist.github.com/pavax/08705e383bdd3b58ea7b75a1f01c7e54
input:
sensor_entity:
@candale
candale / multi_click_button.yaml
Last active October 17, 2024 14:04 — forked from Twanne/multi_click_button.yaml
Home Assistant Blueprint: Multi Click Button
blueprint:
name: Multi Click Button
author: AntonH
description: |
**Version 1.2**
Allows multi-click actions to take place on a button.
Upon reaching the number of required clicks, it executes user defined actions.
There are 3 entity types supported:
- button
#!/bin/bash
# Note: this works with openbsd-netcat
echo "Serving powerstatusforever..."
while true; do
echo -ne "HTTP/1.0 200 OK\r\n\r\n$(cat /host-sys/class/power_supply/ACAD/online)" | nc -N -l -p 5555;
test $? -gt 0 && break;
done
@candale
candale / pushbullet_notif.sh
Last active November 2, 2021 18:47
Pushbullet Simple Notificaion
#!/usr/bin/env bash
# get the API token by going here: https://www.pushbullet.com/#settings/account
API_TOKEN=''
# to create a new channel, go to https://www.pushbullet.com/my-channel
# use the chosen tag for the var below
# for existing channel, you can get the tag from here: https://www.pushbullet.com/#settings/channels
CHANNEL_TAG=''
@candale
candale / octopi.conf
Created April 9, 2020 18:30
Octopi Nginx Proxy
server {
listen 0.0.0.0:80;
server_name my-domain;
return 301 https://$host$request_uri;
}
server {
listen 0.0.0.0:443 ssl;
server_name my-domain;
ssl_certificate /etc/letsencrypt/live/printer-see.acandale.com/fullchain.pem;
@candale
candale / bokeh_real_time.py
Created March 25, 2020 18:36
Bokeh Real Time Graph
# stolen from https://rehn.me/posts/python-real-time-plotting.html
# in case that disappears
import random
from bokeh.driving import count
from bokeh.models import ColumnDataSource
from bokeh.plotting import curdoc, figure
UPDATE_INTERVAL = 100
ROLLOVER = 100 # Number of displayed data points

We had this situation where we had to move around 53 million files (HTMLs) from a bunch of folder to some other folders. The files were located in no more than 100 files, having folders with 2.5 million files. One thing worth mentioning is that the disk where the files are is with spinning disks and is also a NFS, both of whch make the access really slow.

The reason we want to move all of these files is because we no longer want to keep them in a flat structure but rather in a nested structure, using the date when the item was created; the dir structure would look something like this: %Y/%m/%d/. So we basically want to run mv $BASE_DIR/item_name.html.gz $BASE_DIR/%Y/%m/%d/item_name.html.gz for each of those 53 million files.

@candale
candale / ffmpeg_cut_portion.sh
Last active October 16, 2019 08:18
Cut portion of .mkv file with ffmpeg
file_name=$1
from=$2
to=$3
finish=$4
ext=$5
# to copy everything: -vcodec copy -acodec copy -scodec copy
copy='-acodec copy -scodec copy'
# when you get some out of sync stuff when you use -vcoded copy it's because
@candale
candale / py_problems.md
Last active May 15, 2020 08:01
FileIntegerListProblem

Docker

To start playing with docker, we are going to have to build a toy problem. The toy problem is going to be a very simple ToDo app that we're going to take to a final conclusion, having a bunch of containers doing the work with volumes, networking an the lot.

ToDo in a container

@candale
candale / Wide Fetch Cassandra
Created June 13, 2019 07:37
fetch_cassandra_wide.py
def fetch_car_hist_items(limit=None, start=None, end=None):
class StopFetch(Exception):
pass
ses = get_or_create_session()
state = {
'last_token': -9223372036854775808,
'stop_token': 9223372036854775807,