erlang

Idiomatic way to ship command line tools written in Erlang

感情迁移 提交于 2019-12-05 19:10:46
问题 The problem Most of the articles and books about Erlang I could find focus on creating long running server-like applications leaving the process of command line tools creation not covered. I have a multi-app rebar3 project consisting of 3 applications: myweb - a cowboy based web service; mycli - a command line tool to prepare assets for myweb ; mylib - a library used by both myweb and mycli , depends on a NIF. As a result of the build I want to get such artifacts: an executable for the web

Erlang: How to include libraries

一曲冷凌霜 提交于 2019-12-05 18:44:27
I'm writing a simple Erlang program that requests an URL and parses the response as JSON. To do that, I need to use a Library called Jiffy. I downloaded and compiled it, and now i have a .beam file along with a .app file. My question is: How do I use it? How do I include this library in my program?. I cannot understand why I can't find an answer on the web for something that must be very crucial. Erlang has an include syntax, but receives a .hrl file. Thanks! You don't need to include the file in your project. In Erlang, it is at run time that the code will try to find any function. So the

What is the IDE of choice for Erlang development? [closed]

筅森魡賤 提交于 2019-12-05 18:08:16
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I want to get into Erlang programming, specifically some yaws stuff. (Currently, I use Eclipse for Java development.) What is the IDE

CouchDB installs fine for everything except execution of views on win7 x64

醉酒当歌 提交于 2019-12-05 18:03:57
Did a fresh install of Apache CouchDB on Windows 7 x64, using setup-couchdb-1.4.0_R16B01.exe Can access futon without any problem Can programmatically create databases and add documents (including views) Get the error pasted below when executing a view (even when executing the simplest default non-edited temporary map-reduce in Futon "map": "function(doc){ emit(null, doc); }" (in which case the same exact error text is shown in a browser pop-up) Does this error make sense to anyone? Where should I start my investigation? Notes: The path c:/cygwin/relax/APACHE~1.0/src/couchdb/ does not exist on

Splitting a list in equal sized chunks in Erlang

孤街醉人 提交于 2019-12-05 18:02:18
问题 I want to split: [1,2,3,4,5,6,7,8] into: [[1,2],[3,4],[5,6],[7,8]] It generally works great with: [ lists:sublist(List, X, 2) || X <- lists:seq(1,length(List),2) ] . But it is really slow this way. 10000 Elements take amazing 2.5 seconds on my netbook. I have also written a really fast recursive function, but I am simply interested: Could this list comprehension also be written in a different way, so that it is faster? 回答1: Try this: part(List) -> part(List, []). part([], Acc) -> lists

Erlang: difference between using gen_server:cast/2 and standard message passing

情到浓时终转凉″ 提交于 2019-12-05 17:49:19
问题 I was working though a problem and noticed some code where a previous programmer was passing messages using the standard convention of PID ! Message. I have been using gen_server:cast/2. I was wondering if somebody could explain to me the critical differences and considerations when choosing between the two? 回答1: There are a few minor differences: Obviously, the gen_server handles casts in handle_cast and "normal" messages in handle_info . A cast never fails; it always returns ok . Sending a

Problem with starting supervisor through script - Erlang

怎甘沉沦 提交于 2019-12-05 17:27:09
I have made an OTP compliant application where i have a gen_server and a supervisor. Also i have a script to start them. My script contains something like this. erl -pa module_name/ebin -name abc@hostname -setcookie test -s module_sup start_link() This does not start the supervisor. But when i do module_sup:start_link() inside the shell, it works. Also when i do erl -pa module_name/ebin -name abc@hostname -setcookie test -s module_srv start_link() i.e the server alone without the supervisor, the server gets started. So, what am i doing wrong here. Are we not allowed to start supervisor in such

Erlang - Starting a child from the supervisor module

老子叫甜甜 提交于 2019-12-05 17:17:55
I'm trying to create a supervisor which handles adding dynamic gen_servers. for a reason something is failing and I'm not really sure what. -module(supervisor_mod). -behaviour(supervisor). -export([start_link/0, add_child/1]). -export([init/1]). start_link() -> Pid=supervisor:start_link({local, ?MODULE} , ?MODULE, []), {ok,Pid}. init(_Args) -> {ok, {{simple_one_for_one, 10, 60}, [{example_proc, {example_proc, start_link, []}, permanent, brutal_kill, worker, [example_proc]}]}}. add_child(Name)-> supervisor:start_child(supervisor_mod, {example_proc, {example_proc, start_link, []}, permanent,

Erlang: binary_to_atom filling up atom table space security issue

萝らか妹 提交于 2019-12-05 16:42:40
I heard that an atom table can fill up in Erlang, leaving the system open for DDoS unless you increase the number of atoms that can be created. It looks like binary_to_existing_atom/2 is the solution to this. Can anyone explain exactly how binary_to_atom/2 is a security implication and how binary_to_existing_atom/2 solves this problem? When an atom is first used it is given an internal number and put in an array in the VM. This array is allocated statically and can fill up if enough different atoms are used. binary_to_existing_atom will only convert a binary string to an atom which already

How to check whether input is a string in Erlang?

╄→гoц情女王★ 提交于 2019-12-05 16:32:16
I would like to write a function to check if the input is a string or not like this: is_string(Input) -> case check_if_string(Input) of true -> {ok, Input}; false -> error end. But I found it is tricky to check whether the input is a string in Erlang. The string definition in Erlang is here: http://erlang.org/doc/man/string.html . Any suggestions? Thanks in advance. In Erlang a string can be actually quite a few things, so there are a few ways to do this depending on exactly what you mean by "a string". It is worth bearing in mind that every sort of string in Erlang is a list of character or