Skip to content

Instantly share code, notes, and snippets.

View cronokirby's full-sized avatar
🗿

Lúcás Meier cronokirby

🗿
View GitHub Profile
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
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}}
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
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) ]
defmacro __using__(_opts) do
quote do
alias Alchemy.Cogs
require Cogs
@commands unquote(Macro.escape(%{}))
@before_compile Cogs
end
end
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
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
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)
defmodule Couchboy do
@moduledoc """
Base functions for laziness
"""
defmacro __using__(_opts) do
quote do
import Couchboy
require Couchboy
end
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.