Skip to content

Instantly share code, notes, and snippets.

View essen's full-sized avatar

Loïc Hoguin essen

View GitHub Profile
@essen
essen / fw_resource.erl
Last active September 17, 2016 20:07
Thoughts on callback interface for describing resources in an hypermedia framework
-module(fw_resource).
-type resource() :: module().
-type uri() :: string().
-type relation() :: index | self | ...
-type action() :: fetch | stream | create | replace | append | process | delete | patch | atom().
-type media_type() :: atom().
-type internal_representation() :: any().
-type request() :: ...
COWBOY:START_CLEAR(3) COWBOY:START_CLEAR(3)
NAME
cowboy:start_clear - Listen for connections using plain TCP
DESCRIPTION
start_clear(Name :: ranch:ref(),
NumAcceptors :: non_neg_integer(),
TransportOpts :: ranch_tcp:opts(),
ProtocolOpts :: opts())
cowboy_req(3) Cowboy Function Reference cowboy_req(3)
NAME
cowboy_req - HTTP request and response
DESCRIPTION
The module cowboy_req provides functions to access, manipulate and
respond to requests.
There are four types of functions in this module. They can be differ‐
[{h1,<<"cowboy_req:method(3)">>},
{h2,<<"Name">>},
{p,[<<"cowboy_req:method - HTTP method">>]},
{h2,<<"Description">>},
{listing,#{language => <<"erlang">>},
<<"method(Req :: cowboy_req:req()) -> Method :: binary()">>},
{p,[<<"Return the request's HTTP method.">>]},
{p,[<<"The method can also be obtained using pattern matching:">>]},
{listing,#{language => <<"erlang">>},<<"#{method := Method} = Req.">>},
{h2,<<"Arguments">>},

cowboy_req(3)

Name

cowboy_req - HTTP request and response

Description

The module cowboy_req provides functions to access, manipulate and respond to requests.

MacPorts
$ port install erlang git gmake
diff --git a/c_src/lg_tracer.c b/c_src/lg_tracer.c
index 8551dbc..6110d7a 100644
--- a/c_src/lg_tracer.c
+++ b/c_src/lg_tracer.c
@@ -111,6 +111,9 @@ NIF_FUNCTION(enabled)
ERL_NIF_TERM tracers, value;
ErlNifPid tracer;
+ // @todo We can go one step further by having the one pid
+ // in its own value in the map, skipping a get_map_value step.
They sent the most messages
===========================
Process ID Count Most recent message
---------- ----- -------------------
<7778.470.0> 134588 {notify,{event,channel_closed,...}}
<7778.459.0> 66961 {code_call,<7778.459.0>,{load_binary,...}}
<7778.485.0> 29706 pause
<7778.494.0> 29477 {'$gen_cast',{deliver,{...},...}}
<7778.468.0> 1353 {channel_exit,1,{writer,...}}
%% Copyright (c) 2017, Loïc Hoguin <essen@ninenines.eu>
%%
%% Permission to use, copy, modify, and/or distribute this software for any
%% purpose with or without fee is hereby granted, provided that the above
%% copyright notice and this permission notice appear in all copies.
%%
%% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
%% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
%% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
%% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
do_get_remote_pid_tcp(Socket) when is_port(Socket) →
do_get_remote_pid_tcp(inet:sockname(Socket));
do_get_remote_pid_tcp(SockName) →
AllPorts = [{P, erlang:port_info(P)} || P ← erlang:ports()],
[Pid] = [
proplists:get_value(connected, I)
|| {P, I} ← AllPorts,
proplists:get_value(name, I) ≡ "tcp_inet",
inet:peername(P) ≡ SockName],
Pid.