Skip to content

Instantly share code, notes, and snippets.

View marcelog's full-sized avatar

Marcelo Gornstein marcelog

View GitHub Profile
@marcelog
marcelog / sample_200_php_fpm.erl
Created October 17, 2017 17:17
Example of data returned by php-fpm on 200
<<"X-Powered-By: PHP/5.6.30\r\na: b\r\nb: b\r\nc: b\r\nd: b\r\ne: b\r\nf: b\r\nh: b\r\ni: b\r\nj: b\r\nk: b\r\nl: b\r\nm: b\r\nn: b\r\no: b\r\np: b\r\nq: b\r\nContent-type: text/html; charset=UTF-8\r\n\r\n">>
<<"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n</html>">>
@marcelog
marcelog / sample_404_php_fpm.erl
Created October 17, 2017 17:15
Example of data returned by php-fpm on 404
<<"Status: 404 Not Found\r\nX-Powered-By: PHP/5.6.30\r\nContent-type: text/html; charset=UTF-8\r\n\r\nFile not found.\n">>
@marcelog
marcelog / erl_fastcgi_return_example.txt
Created October 13, 2017 20:32
Example messages returned from erl_fastcgi after running a FastCGI application
{fast_cgi_stdout,600,<<"X-Powered-By: PHP/5.6.30\r\nContent-type: text/html; charset=UTF-8\r\n\r\n">>}
{fast_cgi_stdout,600,<<"<html>">>}
{fast_cgi_stdout,600,<<"</html>">>}
{fast_cgi_done,600}
{fastcgi_request_done,600,fast_cgi_connection_reset}
@marcelog
marcelog / erl_fastcgi_test.erl
Last active October 13, 2017 20:25
Calling a FastCGI application from Erlang
test() ->
Host = "127.0.0.1",
Port = 9000,
TryToReconnectEveryMillis = 1000,
% Start a persistant FastCGI connection to the application server
{ok, FastCGIConnection} = erl_fastcgi:start_link(
Host, Port, TryToReconnectEveryMillis
),
@marcelog
marcelog / rebar.config
Created October 13, 2017 20:12
erl_fastcgi use example in rebar.config
{deps, [
{erl_fastcgi, {git, "git://github.com/marcelog/erl_fastcgi", {ref, "master"}}}
]}.
@marcelog
marcelog / test.erl
Created October 9, 2017 20:42
A sample Erlang module
-module(test).
-export([my_fun/1]).
my_fun(X) ->
my_other_fun(X) + 1.
my_other_fun(X) ->
X + 1.
@marcelog
marcelog / run_test_module.log
Created October 9, 2017 20:41
Running the sample erlang module
$ erlc test.erl
$ ls -las test*
8 -rw-r--r-- 1 marcelog wheel 536 Oct 9 17:40 test.beam
8 -rw-r--r-- 1 marcelog wheel 104 Oct 9 17:40 test.erl
$ erl
Erlang/OTP 19 [erts-8.0] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V8.0 (abort with ^G)
1> test:my_fun(1).
3
@marcelog
marcelog / type_example.log
Created October 9, 2017 20:27
Data type examples in Erlang
1> An_Atom = some_name.
some_name
2> A_List = [1, 2, An_Atom, <<1, 2, 3>>].
[1,2,some_name,<<1,2,3>>]
3> Something_Like_A_Boolean = true.
true
4> A_Map = #{key1 => 1, key2 => A_List}.
#{key1 => 1,key2 => [1,2,some_name,<<1,2,3>>]}
5> A_Tuple = {1, 2, 3}.
{1,2,3}
@marcelog
marcelog / pattern_match_log.txt
Created October 9, 2017 19:37
Showing how the match operator works in Erlang
1> X = 1.
1
2> X = 1.
1
3> X = 2.
** exception error: no match of right hand side value 2
@marcelog
marcelog / sample_module.erl
Created October 9, 2017 18:34
Sample erlang module
-module(sample_module).