Skip to content

Instantly share code, notes, and snippets.

View niemyjski's full-sized avatar
😀

Blake Niemyjski niemyjski

😀
View GitHub Profile
@niemyjski
niemyjski / motion_light_illuminance.yaml
Created December 15, 2020 01:40
homeassistant blueprint - Turn on a light when motion is detected and Illuminance is low.
blueprint:
name: Turn the light on when motion is detected
description: Turn on a light when motion is detected and Illuminance is low.
domain: automation
source_url: https://github.com/niemyjski/home-assistant-config/tree/master/blueprints/automation/niemyjski/motion_light.yaml
input:
motion:
name: Motion Sensor
description: The motion sensor wich triggers the light to turn on
selector:
@niemyjski
niemyjski / App.test.tsx
Created January 31, 2022 18:02
React Exceptionless Jest Mock (Jest doesn't yet support esm modules).
import { ClassAttributes, HTMLAttributes } from "react";
jest.mock("@exceptionless/react", () => {
return {
__esModule: true,
Exceptionless: {
startup: jest.fn()
},
ExceptionlessErrorBoundary: (props: JSX.IntrinsicAttributes & ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement>) => {
return <div {...props} />;
@niemyjski
niemyjski / Mark500ErrorsAsCritical.cs
Created November 22, 2021 14:19
Exceptionless Mark 500 Errors as critical
[Priority(100)]
public class Mark500ErrorsAsCritical : IEventPlugin {
public void Run(EventPluginContext ctx) {
if (!String.Equals(ctx.Event.Type, Event.KnownTypes.Error))
return;
if (ctx.ContextData.IsUnhandledError)
ctx.Event.Tags.Add(Event.KnownTags.Critical);
}
}
@niemyjski
niemyjski / Ignore404sFromNonUsers.cs
Created October 18, 2021 14:14
Exceptionless Ignore 404 from non users
ExceptionlessClient.Default.Configuration.AddPlugin<Ignore404sFromNonUsers>();
[Priority(100)]
public class Ignore404sFromNonUsers : IEventPlugin {
public void Run(EventPluginContext ctx) {
if (!String.Equals(ctx.Event.Type, Event.KnownTypes.NotFound))
return;
// Ignore any 404 that doesn't have user info.
ctx.Cancel = !ctx.Event.Data.ContainsKey(Event.KnownDataKeys.UserInfo);
@niemyjski
niemyjski / docker-compose.yml
Last active October 15, 2021 02:36
Home Assistant Portainer docker-compose for double-take & compreface
version: '3.7'
volumes:
double-take:
postgres-data:
services:
double-take:
container_name: double-take
image: jakowenko/double-take:1.4.1
@niemyjski
niemyjski / exceptionless.cs
Last active December 15, 2020 21:45
Exceptionless Ignore Third Party Exceptions
// Create our own client instance so we aren't conflicting if anyone else is using exceptionless in an addon.
private readonly ExceptionlessClient _client = new ExceptionlessClient();
_client.Configuration.AddPlugin<IgnoreLicensingAndNonGeneratorExceptionsPlugin>();
[Priority(30)]
private class IgnoreLicensingAndNonGeneratorExceptionsPlugin : IEventPlugin {
private static readonly List<string> _handledNamespaces = new List<string> {
"MyNamespace",
"MyThirdPartyDependencyNamespace"
};
@niemyjski
niemyjski / motion_switch_illuminance.yaml
Created December 15, 2020 01:41
homeassistant blueprint - Turn on a switch when motion is detected and Illuminance is low.
blueprint:
name: Turn the switch on when motion is detected
description: Turn on a switch when motion is detected and Illuminance is low.
domain: automation
source_url: https://github.com/niemyjski/home-assistant-config/tree/master/blueprints/automation/niemyjski/motion_switch.yaml
input:
motion:
name: Motion Sensor
description: The motion sensor wich triggers the light to turn on
selector:
- badges: []
cards:
- entity: weather.smartweather
name: Forecast
show_forecast: true
type: weather-forecast
- entities:
- entity: sensor.smartweather_wind_bearing
- entity: sensor.smartweather_wind_chill
- entity: sensor.smartweather_wind_direction
@niemyjski
niemyjski / Python3 Virtualenv Setup.md
Created January 30, 2020 01:36 — forked from pandafulmanda/Python3 Virtualenv Setup.md
Setting up and using Python3 Virtualenv on Mac

Python3 Virtualenv Setup

Requirements
  • Python 3
  • Pip 3
$ brew install python3
@niemyjski
niemyjski / main.py
Created January 19, 2020 14:34
Kohler DTV+ Proxy Disconnect Issue
import aiohttp
import asyncio
import requests
async def main():
url = "http://IP_OF_SHOWER_CONTROLLER_HERE/values.cgi?_=1579384493390"
response = requests.get(url)
print(response.json())