Skip to content

Instantly share code, notes, and snippets.

Loïc Hoguin essen

Block or report user

Report or block essen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View man cowboy_req.txt
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‐
View cowboy:start_clear.man
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())
@essen
essen / fw_resource.erl
Last active Sep 17, 2016
Thoughts on callback interface for describing resources in an hypermedia framework
View fw_resource.erl
-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() :: ...
View Makefile
include erlang.mk
ifdef SKIP_DEPS
deps::
$(verbose) for dep in $(ALL_APPS_DIRS) ; do \
mkdir -p $$dep/ebin; \
done
$(verbose) for dep in $(ALL_APPS_DIRS) ; do \
$(MAKE) -C $$dep IS_APP=1 || exit $$?; \
done
View versioning.asciidoc

A common concern with REST APIs is how do you version them? The answer is often something like put the version in the beginning of the URI path. But that’s a terrible advice. This prevents you to make small updates to your API, because you need to duplicate everything every time you increase the version.

A good way to version an API is to not do it. Instead, you can version the media types.

View map_req.erl
-module(map_req).
-export([init/2]).
init(#{method := <<"GET">>} = Req, State) ->
cowboy_req:reply(204, Req),
{ok, Req, State}.
View gist:e5408e99e41dbcc058de
== .erl .core
module.erl: header.hrl behavior.erl parse_transform.erl
module.core:
ebin/$(PROJECT).app:: $(ERL_FILES) $(CORE_FILES)
erlc ... $?
== .xrl .yrl
@essen
essen / Makefile
Last active Aug 27, 2015
Including .mk files from deps
View Makefile
PROJECT = ttt
DEPS = stuff
dep_stuff = git https://github.com/essen/stuff master
include erlang.mk
-include $(DEPS_DIR)/stuff/dist.mk
$(DEPS_DIR)/stuff/dist.mk: $(DEPS_DIR)/stuff ;
View you need a schedule.asciidoc

You need a schedule, man

Overview

Have three kinds of projects/work:

  • money making (gotta buy bread)

  • first class (generally involves a large number of users and/or me having a lot of fun)

  • second class (satellite and toy projects)

@essen
essen / epcap.mk
Created May 21, 2015
Example Makefile generated by erlang.mk when autopatching rebar projects
View epcap.mk
ERL_CFLAGS = -fPIC -I /usr/lib/erlang/erts-6.4/include -I /usr/lib/erlang/lib/erl_interface-3.7.20/include
ERL_LDFLAGS = -L /usr/lib/erlang/lib/erl_interface-3.7.20/lib -lerl_interface -lei
EPCAP_CFLAGS= -DHAVE_PCAP_CREATE
EXE_LDFLAGS = -lpcap $(ERL_LDFLAGS)
EXE_CFLAGS = $(EPCAP_CFLAGS)
EXE_CFLAGS = $(EPCAP_CFLAGS) -DEPCAP_RLIMIT_NOFILES=1
all:: ../priv/epcap
You can’t perform that action at this time.