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 Linear do | |
@moduledoc """ | |
Various useful functions for linear algebra operations | |
""" | |
@doc ~S""" | |
Zips every element in a, with every element in b, applying a function | |
at the same time | |
## Examples |
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
defmacro __before_compile__(_env) do | |
quote do | |
defmacro __using__(_opts) do | |
commands = Macro.escape(@commands) | |
quote do | |
Alchemy.Cogs.CommandHandler.add_commands( | |
unquote(commands) |> Enum.map(fn | |
{k, {mod, arity, string}} -> | |
{eval, _} = Code.eval_string(string) | |
{k, {mod, arity, eval}} |
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 Alchemy.Discord.Gateway.RateLimiter do | |
@moduledoc false | |
# This servers as a limiter to outside requests to the individual gateways | |
alias Alchemy.Discord.Payloads | |
defmodule RateSupervisor do | |
alias Alchemy.Discord.Gateway.RateLimiter | |
use Supervisor |
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
div [] | |
[ div [ class "nav-buttons" ] | |
[ button [ hidden <| model.editing | |
|| not model.studying | |
, class "nav-button" | |
, onClick (ChangeView False studyView) ] | |
[ Icons.book black 40 ] | |
, button [ hidden model.editing | |
, class "nav-button" | |
, onClick (ChangeView False deckListView) ] |
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
defmacro __using__(_opts) do | |
quote do | |
alias Alchemy.Cogs | |
require Cogs | |
@commands unquote(Macro.escape(%{})) | |
@before_compile Cogs | |
end | |
end |
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.Char | |
fromDecimal :: Int -> Int -> String | |
fromDecimal to num = g to num [] | |
where | |
g _ 0 acc = map intToDigit acc | |
g to num acc = let (d, r) = num `divMod` to | |
in g to d (r:acc) | |
toDecimal :: Int -> String -> Int |
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.Char (ord, chr) | |
digitToInt :: Char -> Int | |
digitToInt c = o - offset o | |
where | |
o = ord c | |
offset o | |
| o == 43 = -19 | |
| o == 47 = -16 | |
| o >= 97 = 87 |
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
type Rank = String -- I.E. WR, 1st place time | |
runToString :: IO (Either String Run) -> Rank -> IO (Either String String) | |
runToString parsedRun rank = parsedRun >>= either (return . Left) process | |
where | |
process :: Run -> IO (Either String String) | |
process run = | |
let timeString = formatTime $ time run | |
in fmap (\name -> | |
printf "The %s is %s by %s\n%s" rank timeString name (video run)) | |
<$> fetchName (playerName run) (userLink run) |
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 Couchboy do | |
@moduledoc """ | |
Base functions for laziness | |
""" | |
defmacro __using__(_opts) do | |
quote do | |
import Couchboy | |
require Couchboy | |
end |
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 Nostrum.ConsumerSupervisor do | |
@moduledoc """ | |
ConsumerSupervisor for gateway event handling. | |
# Differences against Consumer | |
Unlike Consumer, This module will start up new Tasks to handle | |
events, allowing for longer running handles that don't block the entire | |
consumer. There's a limit on the amount of concurrent Tasks, so | |
it isn't possible to overload the VM in this module. |