Skip to content

Instantly share code, notes, and snippets.

View bogdanbujdea's full-sized avatar
💭
Who reads this?

Bogdan Bujdea bogdanbujdea

💭
Who reads this?
View GitHub Profile
@bogdanbujdea
bogdanbujdea / FormRecognizer.cs
Created March 19, 2021 20:57
Analyze ID with Azure Form Recognizer
/// <summary>
/// Sends an image to Form Recognizer and returns back the URL that contains the result
/// </summary>
/// <returns></returns>
private async Task<string> StartAnalyzingImage()
{
var queryString = HttpUtility.ParseQueryString(string.Empty);
var client = _httpClientFactory.CreateClient();
@bogdanbujdea
bogdanbujdea / flow.json
Created March 4, 2021 09:57
Node-Red face recognition
[{
"id": "dc813b26.76fc98",
"type": "subflow",
"name": "Identify office person",
"info": "",
"category": "",
"in": [{
"x": 20,
"y": 160,
"wires": [{
@bogdanbujdea
bogdanbujdea / node-red-rescue-time-flow.json
Created January 13, 2021 15:48
RescueTime flow for Node-Red
[{"id":"b6e164fe.1d31e8","type":"subflow","name":"Galaxy S9 notification","info":"","category":"","in":[{"x":100,"y":80,"wires":[{"id":"af896d84.97285"}]}],"out":[{"x":600,"y":80,"wires":[{"id":"fe75d18.e659d3","port":0}]}],"env":[{"name":"message","type":"str","value":""},{"name":"title","type":"str","value":""}],"color":"#A5C13D","icon":"font-awesome/fa-mobile-phone"},{"id":"fe75d18.e659d3","type":"api-call-service","z":"b6e164fe.1d31e8","name":"Send notification","server":"8501408e.93b69","version":1,"debugenabled":true,"service_domain":"notify","service":"mobile_app_galaxy_s9","entityId":"","data":"msg.data","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":430,"y":80,"wires":[[]]},{"id":"af896d84.97285","type":"function","z":"b6e164fe.1d31e8","name":"","func":"var message = env.get(\"message\") || msg.message || global.get('GalaxyS9Message');\nvar title = env.get(\"title\") || msg.title || global.get('GalaxyS9Title');\n\nmsg.data = {\n
@bogdanbujdea
bogdanbujdea / rescue_time_score.js
Created January 13, 2021 15:42
Retrieve productivity score from RescueTime HTML widget
const globalHomeAssistant = global.get('homeassistant');
var html = msg.payload;
var attributeName = "efficiency_percent";
var start = html.indexOf(attributeName);
var attr = html.substr(start + attributeName.length + 2, 5);
msg = {};
msg.attr = attr;
msg.start = start;
msg.productivity = parseInt(attr.replace(/\"/g, "").trim());
var previousScore = parseInt(globalHomeAssistant.homeAssistant.states["sensor.productivity_score"].state);
@bogdanbujdea
bogdanbujdea / motion.yaml
Created November 22, 2020 12:15
Auto-entities card that shows my motion sensors ordered
type: custom:auto-entities
card:
type: entities
filter:
include:
- entity_id: /last_detected/
exclude:
- entity_id: "*0x*"
sort:
method: attribute
@bogdanbujdea
bogdanbujdea / sensor.yaml
Created November 18, 2020 21:01
Sensor for chair position
office_position:
friendly_name: "Office position"
value_template: >-
{% if states.binary_sensor.chair.state == 'on' %}
Standing up
{% else %}
Sitting down
{% endif %}
icon_template: >-
{% if states.binary_sensor.chair.state == 'on' %}
@bogdanbujdea
bogdanbujdea / clean_dotnet_projects.ps1
Created November 9, 2020 23:05
Powershell script for cleaning dotnet projects
Get-ChildItem -include bin,obj,packages,'_ReSharper.Caches','.vs' -Force -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse -ErrorAction SilentlyContinue -Verbose}
# Found on StackOverflow: https://stackoverflow.com/a/42762639/1091894
@bogdanbujdea
bogdanbujdea / consumers.yaml
Last active November 6, 2020 07:13
Active power consumers in Home Assistant
type: conditional
conditions:
- entity: sensor.apartment_power_total
state_not: "off"
card:
type: vertical-stack
cards:
- type: custom:auto-entities
card:
@bogdanbujdea
bogdanbujdea / setup.cmd
Created November 2, 2020 22:29
Windows setup for LocalStack and SSM
docker-compose up -d
aws --endpoint-url=http://localhost:4583 ssm put-parameter --name "/my-app-param-store/settings/intervalInSeconds" --type String --value "60" --overwrite --region "us-east-1" & ^
@bogdanbujdea
bogdanbujdea / Program.cs
Created November 2, 2020 22:20
SSM configuration with LocalStack in .NET Core
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, builder) =>
{
var env = hostingContext.HostingEnvironment;
var configurationBuilder = builder.AddJsonFile("appsettings.json", true, true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true,
reloadOnChange: true);
if (env.IsDevelopment())