Skip to content

Instantly share code, notes, and snippets.

View lasseebert's full-sized avatar

Lasse Skindstad Ebert lasseebert

View GitHub Profile

Wise Home - home assignment

Let's say Wise Home wants to expand globally, and we need an interface to find countries with large population densities and accessible languages. Build a tool to help management decide where to expand:

#!/bin/bash
set -e
echo "Installing minecraft server"
read -p "ssh to the server. Press any key to continue."
echo ""
echo "Copy and paste:"
@spec c() :: :ok | :error
def c do
case a() do
:ok ->
:ok = b()
:ok
:error ->
:error
end
@spec c() :: :ok | :error
def c do
with :ok <- a() do
:ok = b()
:ok
else
:error -> :error
end
end
defmodule DialyzerTest do
@spec a() :: :ok | :error | :another_error
def a do
[:ok, :error, :another_error] |> Enum.random()
end
@spec c() :: :ok | :error
def c do
with :ok <- a() do
:ok
simple_dialyzer_test.ex:14:pattern_match
The pattern can never match the type.
Pattern:
:error
Type:
:another_error
defmodule DialyzerTest do
@spec a() :: :ok | :error
def a do
[:ok, :error] |> Enum.random()
end
@spec b() :: :ok | :another_error
def b do
[:ok, :another_error] |> Enum.random()
end
{
"data": [
{
"attributes": {
"name": "Grimas Lair"
},
"id": "78",
"relationships": {
"addresses": {
"data": [
{
"data": [
{
"attributes": {
"apartment": "All devices"
},
"id": "262",
"relationships": {
"address": {
"data": {
#!/bin/bash
#
# Fetches users from the Wise Home API. Requires valid email and password to run.
#
# Requirements:
# - jq (https://stedolan.github.io/jq/download/)
#
# Usage:
# fetch_users_from_legolas_by_property.sh <email> <password> <property_id>