erlang

Winows下安装RabbitMQ

送分小仙女□ 提交于 2019-12-06 10:55:17
RabbitMQ的简介 RabbitMQ是一套开源(MPL)的消息队列服务软件,是由 LShift 提供的一个 Advanced Message Queuing Protocol (AMQP) 的开源实现,由以高性能、健壮以及可伸缩性出名的 Erlang 写成;RabbitMQ支持主流操作系统Linux、Windows、MaxOX等,多种开发语言支持,Java、Python、Ruby、.Net、PHP、C/C++、Node.js等。 安装 1、下载地址:http://www.rabbitmq.com/download.html 2、 安装RabbitMQ需先安装Erlang,下载地址:http://www.erlang.org/download,下载最新版的压缩包 3、 安装过程就不截图了,安装好Erlang 和 RabbitMQ找到C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\RabbitMQ Server文件夹下的RabbitMQ Command Prompt (sbin dir)双击如图所示: 然后,进入C:\Program Files\RabbitMQ Server\rabbitmq_server-3.7.18\sbin输入命令:rabbitmq-plugins

When to “let it crash” and when to defend the code in Erlang?

喜欢而已 提交于 2019-12-06 10:04:47
问题 So, with "let it crash" mantra Erlang code is meant to be resistant to cruel world events like unexpected pulling the plug, hardware failure, and unstable network connections. On the other hand, there is defensive programming. Being new to Erlang, I wonder, how to know when I want the process just crash and when I want it to defend the flow with if , case..of , type guards? Say, I have an authentication module, which can return true / false result if authenticated successfully or not. Should

Why an epmd process doesn't exit?

跟風遠走 提交于 2019-12-06 09:55:19
Is it a bug or a feature that epmd process still exists after I exit from an erlang shell ? 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

Parsing the result obtained from mochiweb_html

纵然是瞬间 提交于 2019-12-06 09:31:59
问题 I would like to parse some content from an html file (no xml). At the moment I retrieve the structure to parse using mochiweb_html: 1> inets:start(). 2> {ok, {Status, Headers, Body}} = httpc:request("http://www.google.com"). 3> {String, Attributes, Other} = mochiweb_html:parse(Body). and the result is something like: {<<"html">>, [{<<"itemscope">>,<<"itemscope">>}, {<<"itemtype">>,<<"http://schema.org/WebPage">>}], [{<<"head">>,[], [{<<"meta">>, [{<<"itemprop">>,<<"image">>}, {<<"content">>,<

sha256 encryption in erlang

折月煮酒 提交于 2019-12-06 09:23:39
问题 i have written some code in php there i have use mhash(MHASH_SHA256, $key) and its giving result as expected.i wanna know how we can achieve same thing in erlang.i can see in crypto their is one inbuild sha function is their but i dont think so its mean for sha256. any suggestion what i have to do ? thank you in advance. 回答1: Have you seen this page, which links to an SHA-256 module for Erlang? EDIT: Apparently that code is obsolete, replaced by this module. If that still doesn't do what you

Mnesia: unexpectedly getting aborted, cyclic transactions

笑着哭i 提交于 2019-12-06 09:06:34
问题 I have a 5 processes that insert/update the same 3 records in a mnesia table. Each of these processes does its insert/updates within a single transaction. I have 5 other process that read these very same 3 records, also within a single transaction. Unless I lock the entire table as part of the multi-record transaction, I get an {aborted, {cyclic, node....}} error. My intuition is that my use-case is ordinary and should not, in of itself, result in in an aborted transaction. Can someone help

Intercept login/logout ejabberd

混江龙づ霸主 提交于 2019-12-06 09:06:14
问题 I want to know when a user is logged in and logged out from an ejabberd session in a custom module, without changing the ejabberd code. I need that because I have to execute some actions when a user logs in and clean up the actions I did when the user logs out. Also, I need to be able to logoff a user given some circumstances. So, is there a way to extend some module to get those feature? I'm still looking for some documentation that could help me with that. 回答1: You can write your own code

Erlang基础2

孤街浪徒 提交于 2019-12-06 08:41:01
1. apply apply(Mod, Func, [Arg1, Arg2, ..., ArgN]) 等价于 Mod:Func(Arg1, Arg2, ..., ArgN) 区别在于,使用apply,Mod和Func是可以算出来的。 不推荐使用apply,许多分析工具都无法得知发生了什么,编译器优化也可能不管用。 2.元数 函数参数的数量叫做元数。 函数名相同,元数不同,算是不同的函数。 3.属性 模块属性的语法是-XXX(...). -module(modname). 模块声明,必须是第一个属性。必须跟文件名一样。 -import(Mod,[Name1/Arity1, Name2/Arity2,...]) 导入了之后,就无需指定模块名了。 -export([Name1/Arity1, Name2/Arity2, ...]). 导出了之后,模块外可以使用这些函数了。 -compile(Options). 添加Options到编译器选项列表中。 -vsn(Version). 指定模块版本号 用户定义属性 -XXX(Vaule). 好像没什么不同啊。 自定义的属性,会表现为{attributes, ...}的下属数据。 通过module_info()函数可以返回一个属性列表,内含所有与编译模块相关的元数据。 module_info(X)可以返回单个属性 beam_lib:chunks(

Erlang语言基础总结

老子叫甜甜 提交于 2019-12-06 08:38:41
1.=操作符(模式匹配) 当看到一个表达式像X = 123时,它的意思看似“将整数123赋予变量X”,但这种解读是不 正确的。=不是一个赋值操作符,它实际上是一个模式匹配操作符。与其他函数式编程语言一样,Erlang的变量只能绑定一次。绑定变量的意思是给变量一个值 2. 变量和原子的语法 请注意Erlang的变量以大写字母开头。所以X、This和A_long_name都是变量。以小写字母 开头的名称(比如monday或friday)不是变量,而是符号常量,它们被称为原子(atom)。 3. 元组 如果想把一些数量固定的项目归组成单一的实体,就会使用元组(tuple)。创建元组的方法 是用大括号把想要表示的值括起来,并用逗号分隔它们。 4.列表 列表(list)被用来存放任意数量的事物。创建列表的方法是用中括号把列表元素括起来, 并用逗号分隔它们。 5.逗号、分号、句号 逗号(,)分隔函数调用、数据构造和模式中的参数。 分号(;)分隔子句。我们能在很多地方看到子句,例如函数定义,以及case、if、 try..catch和receive表达式。 句号(.)(后接空白)分隔函数整体,以及shell里的表达式。 有一种简单的方法可以记住这些:想想英语。句号分隔句子,分号分隔子句,逗号则分隔下 级子句。逗号象征短程,分号象征中程,句号则象征长程。 6.fun:基本的抽象单元

Erlang: Strange chars in a generated list

懵懂的女人 提交于 2019-12-06 08:33:39
Trying to generate a list through comprehension and at some point I start seeing strange character strings. Unable to explain their presence at this point (guessing the escape chars to be ASCII codes - but why?): 45> [[round(math:pow(X,2))] ++ [Y]|| X <- lists:seq(5,10), Y <- lists:seq(5,10)]. [[25,5], [25,6], [25,7], [25,8], [25,9], [25,10], [36,5], [36,6], [36,7], "$\b","$\t","$\n", [49,5], [49,6], [49,7], "1\b","1\t","1\n", [64,5], [64,6], [64,7], "@\b","@\t","@\n", [81,5], [81,6], [81,7], "Q\b", [...]|...] mpm In Erlang all strings are just list of small integers (like chars in C). And