Skip to content

Instantly share code, notes, and snippets.

Avatar

Marcelo Gornstein marcelog

View GitHub Profile
@marcelog
marcelog / sample_200_php_fpm.erl
Created Oct 17, 2017
Example of data returned by php-fpm on 200
View sample_200_php_fpm.erl
<<"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 Oct 17, 2017
Example of data returned by php-fpm on 404
View sample_404_php_fpm.erl
<<"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 Oct 13, 2017
Example messages returned from erl_fastcgi after running a FastCGI application
View erl_fastcgi_return_example.txt
{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 Oct 13, 2017
Calling a FastCGI application from Erlang
View erl_fastcgi_test.erl
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 Oct 13, 2017
erl_fastcgi use example in rebar.config
View rebar.config
{deps, [
{erl_fastcgi, {git, "git://github.com/marcelog/erl_fastcgi", {ref, "master"}}}
]}.
@marcelog
marcelog / test.erl
Created Oct 9, 2017
A sample Erlang module
View test.erl
-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 Oct 9, 2017
Running the sample erlang module
View run_test_module.log
$ 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 Oct 9, 2017
Data type examples in Erlang
View type_example.log
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 Oct 9, 2017
Showing how the match operator works in Erlang
View pattern_match_log.txt
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 Oct 9, 2017
Sample erlang module
View sample_module.erl
-module(sample_module).