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
fun fetchDataFromUrl(url: String): String { | |
val uri = URI.create(url) | |
val connection = uri.toURL().openConnection() as HttpURLConnection | |
connection.requestMethod = "GET" | |
val responseCode = connection.responseCode | |
return if (responseCode == HttpURLConnection.HTTP_OK) { | |
connection.inputStream.bufferedReader().use { | |
it.readText() | |
} |
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
global: | |
scrape_interval: 3s # Intervalo de tempo entre requisição de métricas | |
evaluation_interval: 15s # Avaliação de regras | |
external_labels: | |
monitor: 'codelab-monitor' | |
# Regras | |
rule_files: | |
# - "regras" |
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
#! /bin/sh | |
docker service create --replicas 1 --name meu-prometheus \ | |
--mount type=bind,source=/tmp/prometheus.yml,destination=/etc/prometheus/prometheus.yml \ | |
--publish published=9090,target=9090,protocol=tcp \ | |
prom/prometheus | |
docker service create \ | |
--replicas 10 \ | |
--name ping_service \ |
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
#! /bin/bash | |
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-444.0.0-linux-x86_64.tar.gz | |
tar -xf google-cloud-cli-444.0.0-linux-x86.tar.gz | |
./google-cloud-sdk/install.sh | |
#./google-cloud-sdk/bin/gcloud init | |
gcloud auth login --no-launch-browser | |
REGIAO='regiao' | |
DIRETORIO='diretorio' |
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 nginx | |
RUN apt-get update && apt-get install -y git | |
RUN git clone https://github.com/tiagodavi70/survey_viewer.git | |
RUN mv survey_viewer/* /usr/share/nginx/html | |
# docker build -t teste_repo . | |
# docker run -p 80:80 -d teste_repo |
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
# Abrindo e fechando | |
arquivo1 = open("arquivo1.txt", "r") | |
print(arquivo1.read()) | |
arquivo1.close() | |
with open("arquivo1.txt", "r") as arquivo1: | |
print(arquivo1.read()) |
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 | |
from pprint import pprint | |
from copy import deepcopy | |
def arvore(): return defaultdict(arvore) | |
def dicts(t): return {k: dicts(t[k]) if type(t[k]) is not defaultdict else dict(t[k]) for k in t} | |
def apresentar(d): | |
for k, v in d.items(): | |
if isinstance(v, 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
# Fila | |
from collections import deque | |
fila = deque([1, 2, 3, 4]) | |
print("Fila criada", fila, "adicionando elementos agora") | |
fila.append(5) # Adiciona elementos | |
fila.append(3) | |
fila.append(8) |
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
# Criação de um dicionário | |
meu_dicionario = {"chave1": "valor1", "chave2": 2, "chave3": ["valor", 3]} | |
# Criando um dicionário com informações de uma pessoa | |
pessoa = { | |
"nome": "Tiago", | |
"idade": 31, | |
"cidade": "Aveiro" | |
} |
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
# Criando uma lista de números inteiros | |
lista_numeros = [1, 2, 3, 4, 5] | |
lista_numeros_range = list(range(1,6)) | |
# Criando uma lista de cadeia de caracteres | |
lista_nomes = ["João", "Maria", "Carol", "Tiago"] | |
# Criando uma lista mista com diferentes tipos de dados | |
lista_mista = [10, "texto", True, 3.14] |
NewerOlder