Skip to content

Instantly share code, notes, and snippets.

View cronokirby's full-sized avatar
🗿

Lúcás Meier cronokirby

🗿
View GitHub Profile
defmodule Script do
@moduledoc false
use Application
alias Alchemy.Client
@token "token"
defmodule Commands do
use Alchemy.Cogs
defmacro thunk(b) do
quote do: fn -> unquote(b) end
end
defmacro a ~> b do
quote do
unquote(a) = thunk(eval(unquote(b)))
end
end
@cronokirby
cronokirby / new.py
Last active February 20, 2017 21:50 — forked from SkyLeite/new.py
def getEvents(page):
pattern = "%Y-%m-%dT%H:%M:%S%z"
start_time = datetime.datetime.utcfromtimestamp(datetime.datetime.strptime(event['start_time'], pattern).timestamp()).replace(tzinfo=pytz.utc)
now = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)
events = (x for x in userGraph.get(path='{}/events'.format(page['id'], type='page')['data'])
if now < start_time
and x['id'] not in sent)
return [Event(name=event['name'], id=event['id'], start_time=event['start_time'])
data Category = Category { catName :: String
, leaderboard :: Url} deriving (Show)
instance FromJSON Category where
parseJSON (Object o) = Category
<$> (o .: "name")
<*> (last <$> o .: "links" >>= (.: "uri"))
data RunData = RunData { runs :: [Run]} deriving (Show)
instance FromJSON RunData where
parseJSON (Object o) = RunData
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
package Counter;
public class Counter {
private int num;
public Counter(int num) {
this.num = num;
}
defp evaluate(message, code) do
result = try do
{result, _} = Code.eval_string(code, [message: message], __ENV__)
result
rescue
e -> e
end
end
defp eval_embed(input, output) do
defmodule Bot do
@moduledoc false
use Application
alias Alchemy.Client
def start(_, _) do
run = Client.start(@local, selfbot: "my_id")
use Eval
run
type Activator = Double -> Double
type Weights = Matrix
type Bias = Vector
-- A layer can be seen as a big function from Vector -> Vector
-- When the `input` is omitted, this becomes a curried function
layer :: Weights -> Bias -> Activator -> (Vector -> Vector)
layer weights bias activator input = map activator
(weights |*| input |+| bias)
defmodule Bot do
use Application
alias Alchemy.client
@token "token here"
def start(_, _) do
run = Client.start(@token)
use Commands
run