Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Who reads this?

Bogdan Bujdea thewindev

💭
Who reads this?
View GitHub Profile
@thewindev
thewindev / Program.cs
Created Mar 19, 2021
Retrieve fields from ID with Form Recognizer
View Program.cs
static async Task Main(string[] args)
{
var resultUrl = await StartAnalyzingImage(); // defined here https://gist.github.com/thewindev/a3a06af46693b890e968fbf810d2b50d
IdentificationResult result;
do
{
await Task.Delay(1000); // wait 1 second before checking, otherwise the API will return 429
var json = await _client.GetStringAsync(resultUrl);
result = JsonConvert.DeserializeObject<IdentificationResult>(json);
@thewindev
thewindev / FormRecognizer.cs
Created Mar 19, 2021
Analyze ID with Azure Form Recognizer
View FormRecognizer.cs
/// <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();
@thewindev
thewindev / flow.json
Created Mar 4, 2021
Node-Red face recognition
View flow.json
[{
"id": "dc813b26.76fc98",
"type": "subflow",
"name": "Identify office person",
"info": "",
"category": "",
"in": [{
"x": 20,
"y": 160,
"wires": [{
View node-red-rescue-time-flow.json
[{"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
@thewindev
thewindev / rescue_time_score.js
Created Jan 13, 2021
Retrieve productivity score from RescueTime HTML widget
View rescue_time_score.js
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);
@thewindev
thewindev / motion.yaml
Created Nov 22, 2020
Auto-entities card that shows my motion sensors ordered
View motion.yaml
type: custom:auto-entities
card:
type: entities
filter:
include:
- entity_id: /last_detected/
exclude:
- entity_id: "*0x*"
sort:
method: attribute
@thewindev
thewindev / sensor.yaml
Created Nov 18, 2020
Sensor for chair position
View sensor.yaml
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' %}
@thewindev
thewindev / clean_dotnet_projects.ps1
Created Nov 9, 2020
Powershell script for cleaning dotnet projects
View clean_dotnet_projects.ps1
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
@thewindev
thewindev / consumers.yaml
Last active Nov 6, 2020
Active power consumers in Home Assistant
View consumers.yaml
type: conditional
conditions:
- entity: sensor.apartment_power_total
state_not: "off"
card:
type: vertical-stack
cards:
- type: custom:auto-entities
card:
@thewindev
thewindev / setup.cmd
Created Nov 2, 2020
Windows setup for LocalStack and SSM
View setup.cmd
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" & ^