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 IOListTest do | |
use Marker | |
Application.put_env(:marker, :result_type, :iolist) | |
component :simple_list do | |
items = for c <- @__content__, do: li c | |
ul items | |
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 ToImport do | |
def hello do | |
"Hello" | |
end | |
end | |
defmodule Test do | |
import ToImport | |
defmacrop precompile(expr) do |
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 P do | |
defmacro precompile(call, block) do | |
{ expr, _ } = Code.eval_quoted(block[:do], [], __CALLER__) | |
quote do | |
def unquote(call) do | |
unquote(expr) | |
end | |
end | |
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
Performed on a MacBook Pro (2009) with a Intel® Core™2 Duo CPU P8700 @ 2.53GHz × 2, running Ubuntu 13.10 | |
doc_size: Mardown document size in KB | |
doc_times: Number of times document is parsed | |
ring_multiplier: Number of rounds messages are passed between 1000 processes | |
dirty_scheduler: Use NIF dirty scheduler true/false | |
TEST1 (two schedulers): |
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
-module(sendfile). | |
%API | |
-export([server/0, clients/0]). | |
%Internal loops | |
-export([client/1, acceptor/2, loop/2]). | |
server() -> |
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
defrecord :xmlAttribute, Record.extract(:xmlAttribute, from_lib: "xmerl/include/xmerl.hrl") | |
defrecord :xmlText, Record.extract(:xmlText, from_lib: "xmerl/include/xmerl.hrl") | |
defrecord XmlNode, element: nil do | |
def from_string(xml_string, options // [quiet: true]) do | |
{doc, []} = | |
xml_string | |
|> to_unicode_char_list | |
|> :xmerl_scan.string(options) |
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 Enex do | |
defmacro map enum, clauses do | |
fnc = {:fn, [], [clauses]} | |
quote do: Enum.map(unquote(enum), unquote(fnc)) | |
end | |
defmacro reduce enum, acc, clauses do | |
fnc = {:fn, [], [clauses]} | |
quote do: Enum.reduce(unquote(enum), unquote(acc), unquote(fnc)) | |
end |