Skip to content

Instantly share code, notes, and snippets.

Tables:
- User (user_id varchar, user_name varchar, user_email varchar)
- Order (order_id varchar, user_id varchar, date timestamp)
- Product (product_id varchar, product_name varchar, price integer)
- ProductOrder (order_id varchar, product_id varchar, quantity integer)
Write the SQL query to get for each user the 5 products they ordered the most over the last 7 days.
# Write a function findWord that takes a list of letter combinaisons in input, and returns the
# word issued from the combinaisons. There is always a unique solution.
# assert findWord(["P>E", "E>R", "R>U"]) == "PERU"
# assert findWord(["I>N", "A>I", "P>A", "S>P"]) == "SPAIN"
# assert findWord(["U>N", "G>A", "R>Y", "H>U", "N>G", "A>R"]) == "HUNGARY"
# assert findWord(["I>F", "W>I", "S>W", "F>T"]) == "SWIFT"
# assert findWord(["R>T", "A>L", "P>O", "O>R", "G>A", "T>U", "U>G"]) == "PORTUGAL"
# assert findWord(["W>I", "R>L", "T>Z", "Z>E", "S>W", "E>R", "L>A", "A>N", "N>D", "I>T"]) == "SWITZERLAND"
# assert findWord(["O>K"]) == "OK"
➜ terraform-provider-consul git:(master) ✗ TF_ACC_CONSUL_LOG=1 make testacc TESTARGS=-run=TestAccDataConsulPeerings_basic
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... | grep -v 'vendor') -v -run=TestAccDataConsulPeerings_basic -timeout 2m
? github.com/hashicorp/terraform-provider-consul [no test files]
=== RUN TestAccDataConsulPeerings_basic
==> Starting Consul agent...
Version: '1.14.0'
Build Date: '2022-11-15 16:39:54 +0000 UTC'
Node ID: '44a4fd95-14f6-4f1d-8b17-f2b1ed90e09e'
Node name: 'primary'
# Print the following in the console from 1 to 100:
# 1
# 2
# Fizz
# 4
# Buzz
# Fizz
# 7
# 8
# Fizz
# Write a function `replace_dashes` that takes a
# dictionnary as input and rename the keys so that
# every '_' is replaced by '-'.
# Your function should not change the values, for
# example, if the input is:
# {
# "key_1": "value_1",
# "key_2": "value_2",
# "key_3": {
# "key_4": "value_4"

Scaling a Compose App

In this exercise we will learn to scale a service from Docker Compose up or down.

Scaling a service

Any service defined in our docker-compose.yml can be scaled up from the Compose API; in this context, 'scaling' means launching multiple containers for the same service, which Docker Compose can route requests to and from.

Starting a Compose App

In this exercise, we will learn how to:

  • Read a basic docker compose yaml file and understand what components it is declaring
  • Start, stop, and inspect the logs of an application defined by a docker compose flag

Preparing Service Images

Container Port Mapping

We will now learn to:

  • forward traffic from a port on the docker host to a port inside a container's network namespace
  • define ports to automatically expose in a Dockerfile

Port Mapping at runtime

  1. Run an nginx container with no special port mapping:

Introduction to Container Networking

We will now learn how to:

  • Create docker bridge networks and attach containers to them
  • Design networks of containers that can successfully resolve each other via DNS and reach each other accros Docker software defined network.

Inspecting the Default Bridge

  1. See what networks are present on your host:

Database Volumes

Launching Postgres

  1. Download a postgres image, and look at its history to determine its default volume usage.
$ docker pull postgres:9
$ docker image inspect postgres:9