erlang

Parse MIME messages

流过昼夜 提交于 2020-01-04 05:30:50
问题 For my new project which has email module.i need to show all the email information on web.when i m making a call to server i m getting the base64 encoded mime data. after applying base64 decoding technique i m getting the mime data as follows: /*********************Mime data start ***********************************/ From prashant.n@geodesic.com Tue Jun 23 12:01:02 2009 Date: Tue, 23 Jun 2009 12:01:02 +0530 From: Prashant R Naik <prashant.n@geodesic.com> To: koushik.narayanan@geodesic.com

Erlang List concatenation, weird “|” sign

[亡魂溺海] 提交于 2020-01-04 01:57:07
问题 in order to become familar with Erlang, i'm trying to write my own Bubblesort Algorithm. Right now, i have the following code in my module: -module(mysort). -export([bubblesort/1]). bubblesort(L) -> sort_sequence(L, []). sort_sequence([H1|[H2|T]], Sorted) -> if H2 >= H1 -> sort_sequence(T, Sorted ++ [H1, H2]); H2 < H1 -> sort_sequence(T, Sorted ++ [H2, H1]) end; sort_sequence([H|T], Sorted) -> Sorted ++ H; sort_sequence([], Sorted) -> Sorted. first of all: please don't give me suggestions to

Handle badarg in Erlang

萝らか妹 提交于 2020-01-04 01:18:07
问题 I am very new to the Erlang and I am getting badarg error when I try to convert binary to string as shown below. Prefix = binary:bin_to_list(wh_json:get_ne_value(<<"prefix">>, Patterns)), where Patterns are: Pattern1--> {[{<<"prefix">>,<<>>},{<<"callerId">>,<<"1001">>},{<<"cid_regex">>,<<"^\\+?1001">>}]} Pattern2--> {[{<<"prefix">>,<<"12">>},{<<"callerId">>,<<"1001">>},{<<"cid_regex">>,<<"^\\+?1001">>}]} for Pattern2 it works fine but for Pattern1 I am getting this error because prefix does

Futures and Promises in Erlang

懵懂的女人 提交于 2020-01-03 17:24:18
问题 Does Erlang has equivalents for Future and Promises? Or since future and promises are solving a problem that doesn't exist in Erlang systems (synchronisation orchestrating for example), and hence we don't need them in Erlang. If I want the semantics of futures and promises in Erlang, they could be emulated via Erlang processes/actors? 回答1: You could easily implement a future in Erlang like this: F = fun() -> fancy_function() end, % fancy code Pid = self(), Other = spawn(fun() -> X = F(), Pid

Erlang (Elixir) Dialyzer - confusing supertype error

荒凉一梦 提交于 2020-01-03 17:22:14
问题 I have defined an Elixir behaviour X . A callback start_link is spec'ed as: @callback start_link( args :: producer_args, opts :: GenServer.options ) :: GenServer.on_start where producer_args type is defined as: @type producer_args :: %{job_queue_name: String.t} In the client code Y that implements the behaviour, start_link is defined as: def start_link(args = %{job_queue_name: _job_queue_name, redis_url: _redis_url}, opts) do GenStage.start_link(__MODULE__, args, opts) end Dialyzer doesn't

Packets sometimes get concatenated

爱⌒轻易说出口 提交于 2020-01-03 13:40:10
问题 I'm trying to make a simple server/application in Erlang. My server initialize a socket with gen_tcp:listen(Port, [list, {active, false}, {keepalive, true}, {nodelay, true}]) and the clients connect with gen_tcp:connect(Server, Port, [list, {active, true}, {keepalive, true}, {nodelay, true}]) . Messages received from the server are tested by guards such as {tcp, _, [115, 58 | Data]} . Problem is, packets sometimes get concatenated when sent or received and thus cause unexpected behaviors as

How does CouchDB calculate the Revision number

混江龙づ霸主 提交于 2020-01-03 09:10:11
问题 I'm trying to understand how CouchDB calculates the revision id for a document. I notice from the source that it's calculated by this bit of code here: couch_util:md5(term_to_binary([Deleted, OldStart, OldRev, Body, Atts2])) And I know that if I create a new empty document with no attachments, CouchDB always gives it a revision of 1-967a00dff5e02add41819138abb3284d which, in decimal is <<150,122,0,223,245,224,42,221,65,129,145,56,171,179,40,77>>. However, if I type the following into the

Why an epmd process doesn't exit?

爷,独闯天下 提交于 2020-01-02 16:22:10
问题 Is it a bug or a feature that epmd process still exists after I exit from an erlang shell ? 回答1: It is quite normal: EPMD is a host daemon process. Its presence is required when one intends to use distributed nodes. It is also useful when just using many nodes on the same machine. 来源: https://stackoverflow.com/questions/2013368/why-an-epmd-process-doesnt-exit

Erlang virtual machine map to which kernel thread?

倖福魔咒の 提交于 2020-01-02 09:29:51
问题 In a multiple core system there are multiple scheduler to schedule the Erlang processes. one scheduler is mapped with one CPU. My doubt is: Erlang Virtual machine is also a process running on some kernel thread. then to which to CPU it got mapped? or it share all CPUs according to the availability. (OS provide the CPU time according to the availability)? 回答1: An Erlang Virtual Machine runs as a single OS process. Within that process, it runs multiple threads, one per scheduler (and possibly