Programming
Algorithms & Data Structures
- Algorithms
- [The Algorithm Design Manual](https://www.amazon.com/Algorithm-Design-Manual-St
defmodule PCache do | |
def start do | |
# data = for i <- 0..1_000, do: {i, i}, into: %{} | |
spawn(fn -> | |
accept_reads() | |
end) | |
end | |
def get(pid) do | |
us = self() |
defmodule Huddle.Application do | |
@moduledoc false | |
use Application | |
def start(_type, _args) do | |
children = [ | |
Endpoint, | |
Repo, | |
{RedisClient, redis_config()} |
# This file contains the configuration for Credo and you are probably reading | |
# this after creating it with `mix credo.gen.config`. | |
# | |
# If you find anything wrong or unclear in this file, please report an | |
# issue on GitHub: https://github.com/rrrene/credo/issues | |
# | |
%{ | |
# | |
# You can have as many configs as you like in the `configs:` field. | |
configs: [ |
defmodule RabbitConnection do | |
@moduledoc """ | |
RabbitMQ client connection | |
""" | |
@behaviour :gen_statem | |
use AMQP | |
alias AMQP.Basic | |
@exchange "messages_exchange" |
defmodule Demo do | |
def demo do | |
_once_per_second = Demo.start(:once, 200) | |
_ten_per_second = Demo.start(:ten, 220) | |
_hundret_per_second = Demo.start(:hundret, 250) | |
IO.puts("Launced processes") | |
Process.sleep(1_500) | |
[:once, :ten, :hundret] |> show() |> IO.inspect() |
defmodule Huddle.Tesla.Retry do | |
@moduledoc """ | |
Adds exponential backoff + retry logic to tesla | |
""" | |
# Maximum times to retry | |
@max_retries 5 | |
# Base delay retry value is 50ms | |
@delay 50 |
Imagine that we have an application where user's have a location. We want to find the weather for their current location using an external service call. We want to provide this functionality in a json api. A basic implementation might look like this.
def create
user = User.find(params[:id])
I hereby claim:
To claim this, I am signing this object:
import Data.List | |
type Query = String | |
type Choice = String | |
type Score = Int | |
data Match = Found String String Int Int | |
| Boundary String String Int Int | |
| Sequential String String Int Int |