Generate a new Elixir project using mix and add cowboy and plug as dependencies in mix.exs:
defp deps do
[
{:cowboy, "~> 1.0.0"},
{:plug, "~> 0.8.1"}
]
end| %% compile and run fold_example:test(). | |
| %% Records used here were taken from RabbitMQ's source code. | |
| -module(fold_example). | |
| -compile(export_all). | |
| -record('P_basic', | |
| {content_type, | |
| content_encoding, | |
| headers, |
| defmodule ROP do | |
| defmacro try_catch(args, func) do | |
| quote do | |
| (fn -> | |
| try do | |
| unquote(args) |> unquote(func) | |
| rescue | |
| e -> {:error, e} | |
| end |
| -- an openresty/nginx authenticator that checks bearer tokens with | |
| -- an ID service for use with `access_by_lua_file` nginx directive | |
| local http = require "resty.http" | |
| local hc = http:new() | |
| function abandon_request(status_code, response_body) | |
| ngx.header["WWW-Authenticate"] = "Bearer" | |
| ngx.status = status_code | |
| ngx.say(response_body) |
| defmodule App.Models.Settings do | |
| defstruct [ | |
| newsletter: false, | |
| publish_profile: true, | |
| email_notifications: true | |
| ] | |
| defmodule Type do | |
| @behaviour Ecto.Type | |
| alias App.Models.Settings |
| # Hello, and welcome to makefile basics. | |
| # | |
| # You will learn why `make` is so great, and why, despite its "weird" syntax, | |
| # it is actually a highly expressive, efficient, and powerful way to build | |
| # programs. | |
| # | |
| # Once you're done here, go to | |
| # http://www.gnu.org/software/make/manual/make.html | |
| # to learn SOOOO much more. |
Generate a new Elixir project using mix and add cowboy and plug as dependencies in mix.exs:
defp deps do
[
{:cowboy, "~> 1.0.0"},
{:plug, "~> 0.8.1"}
]
end| var DEFAULT_MAX_LISTENERS = 12 | |
| function error(message, ...args){ | |
| console.error.apply(console, [message].concat(args)) | |
| console.trace() | |
| } | |
| class EventEmitter { | |
| constructor(){ | |
| this._maxListeners = DEFAULT_MAX_LISTENERS |
| %% move cursor to beginning of the line | |
| io:format("\e[H"). | |
| %% clear the console | |
| io:format("\e[J"). | |
| %% both | |
| io:format("\e[H\e[J"). |
| # The simplest version is probably to use list concatenation. However, | |
| # this version ends up rebuilding the list at each step | |
| defmodule UsingConcat do | |
| def flatten([]), do: [] | |
| def flatten([ head | tail ]), do: flatten(head) ++ flatten(tail) | |
| def flatten(head), do: [ head ] | |
| end | |
| # This version is more efficient, as it picks successive head values | |
| # from a list, adding them to `result`. The trick is that we have to |