Skip to content

Instantly share code, notes, and snippets.

@ayavilevich
ayavilevich / dsps_view_s16.c
Last active February 18, 2023 08:53
dsps_view_s16_s3 vs ansi bug demo
/* Hello World Example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include <math.h>
@ayavilevich
ayavilevich / smoke.yaml
Created October 13, 2020 17:07
Home assistant configuration for integration with RF based smoke detectors. Full article is in my blog.
binary_sensor:
- platform: mqtt
name: "Room1 Smoke Detector"
payload_on: "0x111111"
payload_off: "0x111111off"
device_class: smoke
state_topic: "tele/tasmota_rf/RESULT"
value_template: '{{ value_json.RfReceived.Data }}'
- platform: mqtt
name: "Room2 Smoke Detector"
@ayavilevich
ayavilevich / aws_ebs_leader.js
Created February 19, 2019 18:28
AWS Elastic Beanstalk "is leader instance" check for use with cron, etc (nodejs, async/await).
// based on https://gist.github.com/tony-gutierrez/de5b304fd042f6140eb61a31d0ff92d5
async function isLeader() {
try {
// get APIs
var elasticbeanstalk = new AWS.ElasticBeanstalk();
var ec2 = new AWS.EC2();
var metadata = new AWS.MetadataService();
// get ec2 instance id
const request = new Promise( (resolve, reject) => { // MetadataService.request has no support for promise, make one ourselves
metadata.request('/latest/meta-data/instance-id', (err, InstanceId) => {