This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ with secret "pki/vault/issue/server" "common_name=vault01" "alt_names=vault.service.internal,vault" "ip_sans=10.70.4.10,127.0.0.1" -}} | |
{{ .Data.private_key }} | |
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ with secret "pki/vault/issue/server" "common_name=vault01" "alt_names=vault.service.internal,vault" "ip_sans=10.70.4.10,127.0.0.1" -}} | |
{{ .Data.certificate }} | |
{{ range .Data.ca_chain -}} | |
{{ . }} | |
{{- end }} | |
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
word |> String.downcase() |> String.graphemes() |> Enum.sort() |> Enum.join() | |
Enum.join(Enum.sort(String.graphemes(String.downcase(word)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def merge_dicts(dict1, dict2): | |
merged_dict = dict1.copy() | |
merged_dict.update(dict2) | |
return merged_dict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Anagrams do | |
def anagram_counter(words, n) do | |
words | |
|> Enum.filter(fn word -> String.length(word) == n end) | |
|> Enum.reduce(%{}, fn word, lookup -> | |
Map.update(lookup, lookup_key(word), MapSet.new([word]), &MapSet.put(&1, word)) | |
end) | |
|> Enum.count(fn {_key, anagram_words} -> MapSet.size(anagram_words) > 1 end) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
def anagram_counter(words, n): | |
lookup = defaultdict(set) | |
for word in words: | |
if len(word) == n: | |
lookup[lookup_key(word)].add(word) | |
num_anagrams = 0 | |
for anagram_words in lookup.values(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Marathon 1.5+: there is a `networks` field | |
# Networking modes can't be mixed so using the first one is fine | |
def networking_mode(%{"networks" => [network | _]} = _app_json), | |
do: network |> Map.get("mode", "container") |> String.to_existing_atom() | |
# Pre-Marathon 1.5 Docker container networking mode | |
def networking_mode(%{"container" => %{"docker" => %{"network" => "USER"}}}), | |
do: :container | |
def networking_mode(%{"container" => %{"docker" => %{"network" => "BRIDGE"}}}), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def networking_mode(app_json): | |
# Marathon 1.5+: there is a `networks` field | |
networks = app_json.get('networks') | |
if networks: | |
# Modes cannot be mixed, so assigning the last mode is fine | |
return networks[-1].get('mode', 'container') | |
# Older Marathon: determine equivalent network mode | |
container = app_json.get('container') | |
if container is not None and 'docker' in container: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Envoy | Marathon | Marathon example | Envoy example | |
---|---|---|---|---|
Listener | N/A | N/A | Listener.address = SocketAddress("0.0.0.0", 80) | |
Route | marathon-lb app labels | {"HAPROXY_0_VHOST": "za.goodinternet.org"} | VirtualHost.domains = ["za.goodinternet.org"] | |
Cluster | App ID + port index | app ID = /cake-service, port index = 0 | Cluster.name = "/cake-service_0" | |
Endpoint | Task address | task address = 10.1.1.21, port = 31539 | Endpoint.address = SocketAddress("10.1.1.21", 31539) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Envoy | Nginx | HAProxy | |
---|---|---|---|
Listener | server listen | frontend bind | |
Route | server location | frontend acl | |
Cluster | upstream | backend | |
Endpoint | upstream server | backend server |