Skip to content

Instantly share code, notes, and snippets.

View KamilLelonek's full-sized avatar
🏋️‍♂️
Do you even lift?

Kamil Lelonek KamilLelonek

🏋️‍♂️
Do you even lift?
View GitHub Profile
defmodule MinimalServer.Endpoint do
# ...
require Logger
def start_link(_opts) do
with {:ok, [port: port] = config} <- Application.fetch_env(:minimal_server, __MODULE__) do
Logger.info("Starting server at http://localhost:#{port}/")
Plug.Adapters.Cowboy2.http(__MODULE__, [], config)
end
defmodule MinimalServer.Router do
use Plug.Router
plug(:match)
plug(:dispatch)
get "/" do
conn
|> put_resp_content_type("application/json")
|> send_resp(200, Poison.encode!(message()))
defmodule MinimalServer.Endpoint do
use Plug.Router
plug(:match)
plug(Plug.Parsers,
parsers: [:json],
pass: ["application/json"],
json_decoder: Poison
)
defmodule MinimalServer.Application do
use Application
def start(_type, _args),
do: Supervisor.start_link(children(), opts())
defp children do
[]
end
@KamilLelonek
KamilLelonek / WeatherMap.md
Created August 31, 2018 12:02
Privacy Policy for WeatherMap

Privacy Policy

Kamil Lelonek built the WeatherMap app as a Free app. This SERVICE is provided by Kamil Lelonek at no cost and is intended for use as is.

This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.

If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.

The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at WeatherMap unless otherwise defined in this Privacy Policy.

@KamilLelonek
KamilLelonek / GPScounter.md
Last active August 31, 2018 12:00
Privacy Policy for GPScounter

Privacy Policy

Kamil Lelonek built the GPScounter app as a Free app. This SERVICE is provided by Kamil Lelonek at no cost and is intended for use as is.

This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.

If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.

The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at GPScounter unless otherwise defined in this Privacy Policy.

@KamilLelonek
KamilLelonek / list.ex
Created August 4, 2018 18:10
Flatteing
defmodule List do
def flatten([]), do: []
def flatten([head | tail]), do: flatten(head) ++ flatten(tail)
def flatten(head), do: [head]
end
defmodule Http.WrapperTest do
use ExUnit.Case, async: true
alias Http.{Wrapper, Mock}
import Mox
setup :verify_on_exit!
@headers []
defmodule Http.Wrapper do
@http_adapter Application.get_env(:my_app, :http_adapter)
def post(url, body, options) do
url
|> post_url(body, options)
|> process_response_body(url)
end
defp post_url(url, body, options),
Mox.defmock(
Http.Mock,
for: Http.Behaviour
)