- Algorithms
- [The Algorithm Design Manual](https://www.amazon.com/Algorithm-Design-Manual-St
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
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() |
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
defmodule Huddle.Application do | |
@moduledoc false | |
use Application | |
def start(_type, _args) do | |
children = [ | |
Endpoint, | |
Repo, | |
{RedisClient, redis_config()} |
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
# 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: [ |
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
defmodule RabbitConnection do | |
@moduledoc """ | |
RabbitMQ client connection | |
""" | |
@behaviour :gen_statem | |
use AMQP | |
alias AMQP.Basic | |
@exchange "messages_exchange" |
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
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() |
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
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:
- I am keathley on github.
- I am keathley (https://keybase.io/keathley) on keybase.
- I have a public key whose fingerprint is 127E 4801 6473 B025 9666 DDEC 646E F51E 2C11 C8A1
To claim this, I am signing this object:
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
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 |
NewerOlder