Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Who reads this?

Bogdan Bujdea thewindev

💭
Who reads this?
View GitHub Profile
@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:
@thewindev
thewindev / subflow.json
Last active Oct 21, 2020
Node-Red subflow for sending notifications
View subflow.json
[{"id":"3c8ad50a.81cbba","type":"subflow","name":"Subflow 1","info":"","category":"","in":[{"x":-20,"y":80,"wires":[{"id":"6d65619b.8360a"}]}],"out":[],"env":[{"name":"message","type":"str","value":"Hello","ui":{"label":{"en-US":"Message"}}},{"name":"title","type":"str","value":"","ui":{"label":{"en-US":"Notification title"}}}],"color":"#DDAA99"},{"id":"8f27018e.a9918","type":"api-call-service","z":"3c8ad50a.81cbba","name":"Send notification","server":"8501408e.93b69","version":1,"debugenabled":true,"service_domain":"notify","service":"mobile_app_galaxy_s9","entityId":"","data":"{\"message\": $env('message'), \"title\": $env('title')}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":810,"y":60,"wires":[[]]},{"id":"6d65619b.8360a","type":"time-range-switch","z":"3c8ad50a.81cbba","name":"Is it between 10 PM and 8 AM?","lat":"","lon":"","startTime":"22:00","endTime":"08:00","startOffset":0,"endOffset":0,"x":210,"y":80,"wires":[[],["d710e0e9.28
@thewindev
thewindev / todoist
Created Oct 20, 2020
Todoist API payload
View todoist
msg.headers = {};
msg.method = "POST";
msg.url = "https://api.todoist.com/sync/v8/sync";
var taskId = "4271193756";
msg.payload = "token=<insert your token here>&commands=%5B%7B%22type%22%3A%20%22item_update_date_complete%22%2C%20%22uuid%22%3A%20%22" +
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
}) + "%22%2C%20%22args%22%3A%20%7B%22id%22%3A%20" + taskId + "%7D%7D%5D"
msg.headers["content-type"] = "application/x-www-form-urlencoded"
@thewindev
thewindev / configuration.yaml
Last active Oct 20, 2020
Configuring a variable using home-assistant-variables
View configuration.yaml
var:
latest_hashnode_article_id:
friendly_name: 'Latest article ID'
icon: 'mdi:blogger'
@thewindev
thewindev / hashnode
Last active Oct 20, 2020
Query for retrieving ids of Hashnode articles
View hashnode
{
user(username: "bogdan") {
publication {
posts(page: 0){
cuid,
title
}
}
}
}