I hereby claim:
- I am tokafish on github.
- I am tokafish (https://keybase.io/tokafish) on keybase.
- I have a public key ASBBeP7V3NUWKnZIhv8N6FCqGf3QEX3PiVm7zVDYQ8WEXQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| for {event, instrumenters} <- app_instrumenters do | |
| start_callbacks = Phoenix.Endpoint.Instrument.compile_start_callbacks(event, instrumenters) | |
| stop_callbacks = Phoenix.Endpoint.Instrument.compile_stop_callbacks(event, instrumenters) | |
| def instrument(unquote(event), var!(compile), var!(runtime), fun) | |
| when is_map(var!(compile)) and is_map(var!(runtime)) and is_function(fun, 0) do | |
| unquote(start_callbacks) | |
| start = :erlang.monotonic_time | |
| try do | |
| fun.() |
| defmodule Phoenix.Ecto.SQL.Sandbox do | |
| @config_path "/phoenix/ecto/sql/sandbox/" | |
| def path_for(repo, pid) do | |
| "#{@config_path}#{:erlang.pid_to_list(pid)}|#{Atom.to_string(repo)}" | |
| end | |
| end | |
| defmodule Phoenix.Ecto.SQL.Sandbox do | |
| # ... | |
| def call(conn, sandbox) do | |
| conn |> fetch_cookies |> allow_sandbox_access(sandbox) | |
| end | |
| defp allow_sandbox_access(%{req_cookies: %{@cookie_name => configuration}} = conn, sandbox) do | |
| [pid_string,repo_string] = configuration |> URI.decode |> String.split("|") | |
| owner = to_pid(pid_string) |
| defmodule Phoenix.Ecto.SQL.Sandbox do | |
| import Plug.Conn | |
| @cookie_name "phoenix.ecto.sql.sandbox" | |
| def init(opts), do: opts | |
| def call(%{request_path: @config_path <> configuration} = conn, _opts) do | |
| conn |> put_resp_cookie(@cookie_name, configuration) |> send_resp(200, "OK") |> halt | |
| end |
| defmodule ConcurrentAcceptance.Endpoint do | |
| # rest of endpoint omitted | |
| if Application.get_env(:concurrent_acceptance, :sql_sandbox) do | |
| plug Phoenix.Ecto.SQL.Sandbox | |
| end | |
| plug ConcurrentAcceptance.Router | |
| end |
| config :concurrent_acceptance, sql_sandbox: true |
| defmodule ConcurrentAcceptance.AcceptanceCase do | |
| use ExUnit.CaseTemplate | |
| using do | |
| quote do | |
| use Hound.Helpers | |
| import Ecto.Model | |
| import Ecto.Query, only: [from: 2] | |
| import ConcurrentAcceptance.Router.Helpers |
| defmodule MessageSpammer.Connector do | |
| use Supervisor | |
| def start_link do | |
| Supervisor.start_link(__MODULE__, []) | |
| end | |
| def init(_) do | |
| IO.puts "Starting Connector" | |
| defmodule CombinationsBenchmark do | |
| def combinations(collection, k) do | |
| List.last(do_combinations(collection, k)) | |
| end | |
| defp do_combinations(list, k) do | |
| combinations_by_length = [[[]]|List.duplicate([], k)] | |
| List.foldr list, combinations_by_length, fn x, next -> | |
| sub = :lists.droplast(next) |