erlang

How to compile erlang code loaded into a string?

泪湿孤枕 提交于 2021-02-06 05:34:18
问题 I have a generated string that contains the code for an erlang module. Is there a way to compile the generated module straight from the string? Or is there a way to convert the string into the format needed for compile:forms/1 ? Or will I have to save it to a temp file first and then compile it with compile:file/1 ? Alternatively, I can add support to the compile module, but there must be a reason why the good people that write erlang haven't added it. 回答1: You need to scan your string into

How to compile erlang code loaded into a string?

≡放荡痞女 提交于 2021-02-06 05:33:27
问题 I have a generated string that contains the code for an erlang module. Is there a way to compile the generated module straight from the string? Or is there a way to convert the string into the format needed for compile:forms/1 ? Or will I have to save it to a temp file first and then compile it with compile:file/1 ? Alternatively, I can add support to the compile module, but there must be a reason why the good people that write erlang haven't added it. 回答1: You need to scan your string into

Why does Erlang if statement support only specific functions in its guard?

北战南征 提交于 2021-02-05 07:57:25
问题 Why does the Erlang if statement support only specific functions in its guard? i.e - ok(A) -> if whereis(abc)=:=undefined -> register(abc,A); true -> exit(already_registered) end. In this case we get an "illegal guard" error. What would be the best practice to use function's return values as conditions? 回答1: Coming from other programming languages, Erlang's if seems strangely restrictive, and in fact, isn't used very much, with most people opting to use case instead. The distinction between

Centos搭建EMQX和EMQ-Dashboard(踩坑精华版)

旧巷老猫 提交于 2021-02-03 12:41:11
背景 最近在做物联网平台性能分析,最终选择EMQX作为对比对象。我小试牛刀地搭建了一下EMQX,并顺便安装了一下EMQX的Dashboard插件: emqx-dashboard 。 简介: EMQX: EMQ X (Erlang/Enterprise/Elastic MQTT Broker) 是基于 Erlang/OTP 平台开发的开源物联网 MQTT 消息服务器。 EMQX-Dashboard:EMQ X的Web控制台,项目地址: https://github.com/emqx/emqx-dashboard.git 安装 EMQX安装 1.安装所需要的依赖包 sudo yum install -y yum-utils device-mapper-persistent-data lvm2 2. 使用以下命令设置稳定存储库,以 CentOS7 为例 sudo yum-config-manager --add-repo https://repos.emqx.io/emqx-ce/redhat/centos/7/emqx-ce.repo 3. 安装最新版本的 EMQ X Broker sudo yum install emqx 4. 启动并检查状态 emqx start && emqx_ctl status EMQ-Dashboard安装 我的机器环境为Centos7

On_load_function_failed : cberl_nif (Erlang)

我是研究僧i 提交于 2021-01-29 04:11:32
问题 I am using https://github.com/chitika/cberl. My current application version is 1.2.1. Which is running fine. I created a new release 1.2.2 which upgraded fine. But when I started a new instance it failed on 1.2.2. It keep on throwing cberl error. If I start my prev release 1.2.1 and then upgrade it to 1.2.2 again then it works fine. But starting from scratch doesn't. My application (say test) failed to start. Command I used : bin/test console . OTP version used : 18.2. Compiled on OTP 18.2.

On_load_function_failed : cberl_nif (Erlang)

蹲街弑〆低调 提交于 2021-01-29 04:06:09
问题 I am using https://github.com/chitika/cberl. My current application version is 1.2.1. Which is running fine. I created a new release 1.2.2 which upgraded fine. But when I started a new instance it failed on 1.2.2. It keep on throwing cberl error. If I start my prev release 1.2.1 and then upgrade it to 1.2.2 again then it works fine. But starting from scratch doesn't. My application (say test) failed to start. Command I used : bin/test console . OTP version used : 18.2. Compiled on OTP 18.2.

Elixir - find sub-bitstring within larger bitstring

久未见 提交于 2021-01-28 20:34:05
问题 How would I go about finding if a sub-bitstring is present with another bitstring in Elixir? I need to verify that bitstring X exists somewhere within bitstring Y for testing purposes. Is there a simple way to do this with existing functions? x = "bar" y = "foo bar baz" some_substring_function(x, y) with some_substring_function returning a truthy value. Thanks in advance! 回答1: You can use the =~ operator: iex> "hello world" =~ "hello" true The String module also has some convenience functions

could not compile dependency :salty, “mix compile” failed

…衆ロ難τιáo~ 提交于 2021-01-28 11:54:09
问题 I am compiling my application with mix compile and there an error is occurring for the dependency salty . I have already added the dependency salty and libsodium . But still error is not resolved. this is my mix.exs file with all the dependencies. defp deps do [ {:poison, "~> 3.0", override: true}, {:syndicate, in_umbrella: true}, {:xarango, "~> 0.7.0"}, {:ecto, "~> 3.1"}, {:phoenix, "~> 1.4.0"}, {:gettext, "~> 0.11"}, {:cowboy, "~> 2.6"}, {:joken, "~> 2.0"}, {:ecto_sql, "~> 3.0"}, {:jason, "

How does erlang -import work?

时间秒杀一切 提交于 2021-01-28 07:06:33
问题 I'm trying to write some app using mochiweb. App tree: tree . ├── aniaggregator2.iml ├── deps │ └── mochiweb │ ├── CHANGES.md │ ├── doc │ ├── ebin │ │ ├── .... │ │ ├── mochiweb_html.beam │ │ ├── .... │ ├── examples │ │ ├── ...... │ ├── include │ │ └── ...... │ ├── LICENSE │ ├── Makefile │ ├── README │ ├── rebar │ ├── rebar.config │ ├── scripts │ │ ├── entities.erl │ │ └── new_mochiweb.erl │ ├── src │ │ ├── ..... │ │ ├── mochiweb_html.erl │ │ ├── ..... │ ├── support │ │ ├── ..... │ └── test │

Can't get two Erlang nodes to communicate

限于喜欢 提交于 2021-01-27 17:12:54
问题 No matter what I try, I can't get two different nodes to communicate. This is probably a very simple problem to solve. I have created the file .cookie.erlang and I've placed it into my home directory. Then I open a terminal window and type the following commands: erl -sname user1@pc erlang:set_cookie(node(),cookie). In another terminal window I type: erl -sname user2@pc erlang:set_cookie(node(),cookie). Now if I type the following command in the first terminal window: net_adm:ping(user2@pc).