Skip to content

Instantly share code, notes, and snippets.

View michaelkuty's full-sized avatar

Michael Kutý michaelkuty

View GitHub Profile
@michaelkuty
michaelkuty / rf_bridge.py
Created June 20, 2020 20:18
Home Assistant Sonoff RF Bridge App Daemon
# RF codes located in appdaemon/config/rf_codes.yaml
93B408:
device_name: remote_ctl_1
name: button_1_left
description: Turn on scene
# sync: 0x1D4C
# low: 0x010E
C10A39:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN) #PIR
GPIO.setup(21, GPIO.OUT) # LED
GPIO.setup(4, GPIO.OUT) # RELAY
try:
@michaelkuty
michaelkuty / monitor-volume
Last active December 18, 2017 23:08 — forked from savetheclocktower/README.md
Using a rotary encoder as a volume control for the Raspberry Pi
#!/usr/bin/env python3
"""
The daemon responsible for changing the volume in response to a turn or press
of the volume knob.
The volume knob is a rotary encoder. It turns infinitely in either direction.
Turning it to the right will increase the volume; turning it to the left will
decrease the volume. The knob can also be pressed like a button in order to
turn muting on or off.
### Defining a variable for the admin API using the name of my management server and the default admin API port, which is 30004
$AdminURI = "https://localhost:30004"
### Defining a variable for the Admin Authentication Site in my environment. Default port is 300072 but is changed in this environment to use 443
$AuthSite = "https://localhost:30072"
### Defining a variable for the Client Realm, using the default value
#requires -version 2
#------------------------------------------------------------------------------
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true)]
[Guid] $StampId,
[Parameter(Mandatory=$true)]
[int32] $Size,
@michaelkuty
michaelkuty / run-tests.sh
Last active August 1, 2016 07:37
PerfKit Benchmark Stages
#!/bin/bash
run_tests() {
[ -d ./results/$CLOUD/$TEST ] || mkdir -p ./results/$CLOUD/$TEST
# run provision and preparation before run
echo "Start preparing environemnt for $TEST in the $CLOUD"
@michaelkuty
michaelkuty / jinja_renderer.py
Last active July 19, 2016 13:54
Simple Jinja renderer
import jinja2
from jinja2 import Environment
import yaml
jinja2.filters.FILTERS['yaml'] = lambda s: yaml.safe_dump(
s, default_flow_style=True)
jinja2.filters.FILTERS['parse_aliases'] = lambda s: yaml.safe_dump(
s.split(','), default_flow_style=True)
@michaelkuty
michaelkuty / deploy-site.sh
Last active September 12, 2016 11:48
Deploy leonardo site
#!/bin/bash -e
pip_install_source()
{
REMOTE=$1
EGG=$2
[ -d ../src ] || mkdir ../src
git clone $REMOTE --depth 1 ../src/$EGG
@michaelkuty
michaelkuty / flask.py
Created January 9, 2016 17:21
Salt Master Flask server
from flask import jsonify
from flask import Flask
from flask import request
import yaml
app = Flask(__name__)
@app.route("/<path:path>", methods=['POST'])
def dump_relass(path):
@michaelkuty
michaelkuty / request.js
Last active January 6, 2016 17:14
Simple HTTP client in JS for NodeJS
var request = require('request');
var rp = require('request-promise');
export default function Model(model) {
/* Encapsulate Django Rest Frameowork actions
var page = new Model('web.page');
page.list(function (pages) {