Skip to content

Instantly share code, notes, and snippets.

View niemyjski's full-sized avatar
😀

Blake Niemyjski niemyjski

😀
View GitHub Profile
@niemyjski
niemyjski / save-camera-snapshot-notification-on-motion.yaml
Last active March 28, 2024 13:54
Home Assistant Blueprint - Save a camera snapshot with archive when motion is detected
blueprint:
name: Save a camera snapshot when motion is detected
description: Save a camera snapshot with archive when motion is detected
domain: automation
source_url: https://gist.github.com/niemyjski/08c566a4fe64fb2e70998ee4f38c9d1e
input:
motion_sensor:
name: Motion sensor
description: The sensor wich triggers the snapshot creation
selector:
@niemyjski
niemyjski / test.cs
Created March 7, 2024 22:50
.NET always Parsing log formats
[Fact]
public void TestLogLevel()
{
Log.MinimumLevel = LogLevel.Information;
var logger = Log.CreateLogger("TestLogLevel");
logger.LogTrace("({BadBracket}}", Boolean.TrueString);
}
System.FormatException
Input string was not in a correct format. Failure to parse near offset 10. Format item ends prematurely.
@niemyjski
niemyjski / gist:a68114db0ddf1f9717f6
Last active February 28, 2024 18:23
IIS6 Exceptionless Web.config file changes
<!-- Required changes if you are using Exceptionless.Mvc -->
<system.web>
<httpModules>
<add type="Exceptionless.Mvc.ExceptionlessModule, Exceptionless.Mvc" name="ExceptionlessModule"/>
</httpModules>
</system.web>
<!-- Required changes if you are using Exceptionless.Web -->
<system.web>
<httpModules>
@niemyjski
niemyjski / description.md
Last active June 8, 2023 15:33
Report Home Assistant Battery Levels With Node-RED

I decided to share this snippet based on seeing what others were doing in this thread: https://www.reddit.com/r/homeassistant/comments/emvk9y/how_do_you_monitor_sensor_battery_levels_looking/

Basically dome device types of battery report the state in different locations and with different string values that the change node or conditional logic just doesn't work nicely. Using the conditional logic on this string state value might not be working fully how we think it is or at least didn't for me. When I was debugging it and getting 10 outputted in a 100 bucket via the gt condition. The best way I've found to handle these conditions is with a function node.

Home Assistant Feedback

@niemyjski
niemyjski / mac-arm-brew-setup.md
Last active April 19, 2023 14:07
Arm Mac New Install (Brew)
  • xcode-select --install
  • softwareupdate --all --install --force
  • softwareupdate --install-rosetta --agree-to-license
  • Brew
    • brew install --cask microsoft-teams
    • brew install --cask slack
    • brew install --cask discord
    • brew install --cask iterm2
    • brew install --cask dotnet-sdk
  • brew install --cask google-chrome
@niemyjski
niemyjski / commit-msg
Created March 30, 2023 15:05 — forked from projectpwr/commit-msg
git commit-msg hook to prepend jira ticket number to commit messages...
#!/bin/sh
# hook identifies jira ids in branch names, adds on more goodies if we are a hotifx or release branch and attempts to prevent blank commit messages...although this needs a bit more work...
COMMIT_FILE=$1
COMMIT_MSG=$(cat $1)
#First and foremost check whether the commit message is blank. if so then abort the commit. strip any spaces out too
#this one only works at present when someone tries to do git commit -m "" or git commit -m " "
#if anyone uses tools such as sourcetree, then these GUIs typically present a prompt...eg. "do you want to commit wihtout a message" and pass in optional attributes to git commit to allow this.
@niemyjski
niemyjski / prune.ts
Created March 10, 2023 12:28
Exceptionless Prune
/**
* This function will prune an object to a certain depth and return a new object.
* The following rules will be applied:
* 1. If the value is null or undefined, it will be returned as is.
* 2. If the value is a function or unsupported type it will be return undefined.
* 3. If the value is an array, it will be pruned to the specified depth and truncated.
* 4. If the value is an object, it will be pruned to the specified depth and
* a. If the object is a Circular Reference it will return undefined.
* b. If the object is a Map, it will be converted to an object.
* c. If the object is a Set, it will be converted to an array.
@niemyjski
niemyjski / Configuration.h
Last active February 5, 2023 17:17
Marlin Ender 3 Pro (SKR Mini 2.0) with Creality Touch (2/5/2023 bugfix-2.1.x) based on https://www.reddit.com/r/3Dprinting/comments/n7or5u/marlin_20x_guide_skr_mini_e3_v20_ender_3/ and other config for cr touch
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
#if false
throw null;
#else
#endif
unsafe get @event(ref string @as, byte? @throw = sizeof(double))
{
lock(typeof(get)) {}
try
@niemyjski
niemyjski / automation.yaml
Created February 23, 2022 12:51
Home Assistant: Audio - Normalize levels to 10% at 9pm
alias: Audio - Normalize levels to 10% at 9pm
trigger:
- platform: time
at: '21:00:00'
action:
- service: media_player.volume_set
data:
volume_level: 0.1
entity_id: media_player.everywhere,media_player.kitchen
mode: single