Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Who reads this?

Bogdan Bujdea thewindev

💭
Who reads this?
View GitHub Profile
@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" & ^
@thewindev
thewindev / Program.cs
Created Nov 2, 2020
SSM configuration with LocalStack in .NET Core
View Program.cs
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())
@thewindev
thewindev / s3.cs
Created Nov 2, 2020
Startup.cs configuration for S3 and LocalStack
View s3.cs
if (_environment.IsDevelopment())
{
var amazonS3 = new AmazonS3Client(new BasicAWSCredentials("abc", "def"), new AmazonS3Config
{
ServiceURL = "http://localhost:4572",
ForcePathStyle = true,
UseHttp = true
});
services.AddSingleton(typeof(IAmazonS3), provider => amazonS3);
@thewindev
thewindev / dynamodb.cs
Created Nov 2, 2020
Configure DynamoDb and LocalStack in .NET Core
View dynamodb.cs
if (_environment.IsDevelopment())
{
services.AddSingleton<IAmazonDynamoDB>(sp =>
{
var clientConfig = new AmazonDynamoDBConfig
{
ServiceURL = "http://localhost:4569",
UseHttp = true
};
return new AmazonDynamoDBClient(new BasicAWSCredentials("abc", "def"), clientConfig);
@thewindev
thewindev / docker-compose.yaml
Created Nov 2, 2020
LocalStack docker compose
View docker-compose.yaml
version: '3.7'
services:
localstack:
network_mode: bridge
image: localstack/localstack:latest
container_name: localstack
environment:
- SERVICES=s3:4572,ssm:4583,dynamodb:4569
- DATA_DIR=/tmp/localstack/data
@thewindev
thewindev / consumers.yaml
Created Oct 30, 2020
Active consumers card with auto entities
View consumers.yaml
type: conditional
conditions:
- entity: sensor.apartment_power_total
state_not: "off"
card:
type: vertical-stack
cards:
- type: custom:auto-entities
card: