Skip to content

Instantly share code, notes, and snippets.

@svenakela
svenakela / cards.yaml
Created February 17, 2024 21:42
Home Assistant 3 phase gauges
- type: horizontal-stack
cards:
- type: gauge
entity: sensor.p1ib_current_l1
max: 25
segments:
- from: 0
color: '#2980B9'
- from: 3
color: '#48C9B0'
@svenakela
svenakela / terraform.tf
Created November 16, 2023 11:47
Deploy Azure Container Group (Docker) in Private Vnet With Public Access, all in Terraform
# Running a docker container in Azure private virtual network (vnet) with public access
# The container must be in a manually created vnet if you want to do peering to another
# private network. In this config the subnet gives permission to use blob storage for
# the containe group.
#
# Public IP - Load balancer - Backend pool ---- vnet
# | | |
# LB rule | subnet ----- Container group - Docker app
# | | | |
# Probe | Security Group |
@svenakela
svenakela / np48h-apexcharts.yaml
Last active November 14, 2023 21:04
Home Assistant apexcharts-card 48 h Nordpool
# Example screenshot:
- type: custom:apexcharts-card
graph_span: 48h
header:
title: Elpris (kr/kWh)
show: true
experimental:
color_threshold: true
all_series_config:
stroke_width: 1
// Cap everything
"My kid is a stupid jump rat"
.toLowerCase()
.split(' ')
.map(word => word.charAt(0).toUpperCase() + word.substring(1))
.join(' ');
// MLA Style - All words <= 3 chars are lowercase, except first and last word.
// MLA style word matching that always should be lower case. There are combinations as well, like "as long as" and "even if", that should be non cap to be perfect
@svenakela
svenakela / BodyContentLenghtTest.java
Created March 15, 2019 10:40
Get the content length of a body and add it the CONTENT_LENGTH header with Spring's Reactive WebClient
import java.nio.charset.StandardCharsets;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
public class BodyContentLenghtTest {
@svenakela
svenakela / CollectionDuplicateTest.java
Last active May 2, 2019 12:58
Finding duplicates in a list
package barky;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Assertions;
@svenakela
svenakela / RedirectingWebClient.java
Last active August 28, 2019 19:40
Spring WebClient Wrapper allowing for redirects
package se.cygni.bootcamp.mashup.core;
import java.util.Optional;
import org.springframework.http.HttpHeaders;
import org.springframework.web.reactive.function.client.ClientResponse;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;