Skip to content

Instantly share code, notes, and snippets.

View essen's full-sized avatar

Loïc Hoguin essen

View GitHub Profile
@essen
essen / my_module.erl
Created October 14, 2013 03:25
Thinking in Erlang: The Code
-module(my_module).
-export([my_function/1, my_function/2]).
-export([infinite_loop/0, f/1, r/2, sort/1]).
-export([only_primes/1, is_prime/1]).
my_function(A) when is_integer(A) ->
my_function(A, 0);
my_function(A) when is_list(A) ->
my_function(list_to_integer(A), 0).
@essen
essen / http_specs.md
Last active January 10, 2022 02:01
HTTP and related specifications
%% Copyright (c) 2020, 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
-module(gun_proxied_tls).
-behaviour(gen_server).
%% Gun-specific interface.
-export([ssl_connect/2]).
-export([ssl_connect/3]).
-export([proxy_received/2]).
%% Transport callback.

Thinking in Erlang

One day Erlang training.

Goals

This training should get you started with Erlang and understand how to design a highly available distributed system. Because there is only one day, we focus on the essential concepts and skip over many details that would be covered in the normal three days course.

{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
diff --git a/src/rabbit_mgmt_wm_queue_get.erl b/src/rabbit_mgmt_wm_queue_get.erl
index 5e8bba0f..0d80355e 100644
--- a/src/rabbit_mgmt_wm_queue_get.erl
+++ b/src/rabbit_mgmt_wm_queue_get.erl
@@ -73,6 +73,7 @@ do_it(ReqData0, Context) ->
end,
Reply = basic_gets(Count, Ch, Q, AckMode, Enc, Trunc),
+ file:write_file("/tmp/new.txt", io_lib:format("~p~n", [erlang:process_info(self())])),
maybe_rejects(Reply, Ch, AckMode),
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.
%% 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
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,...}}