erlang

export data from mnesia to excel

这一生的挚爱 提交于 2019-12-13 08:09:02
问题 I have the table user -record(person, {id, firstname, lastname}). this table contains this values : 1 francoi mocci 2 test tes my goal is how can I export this data from mnesia to excel I know the inverse way meaning transfer data from excel to mnesia the solution in this case is to converse the excel in csv.file then use this kind of code to parse the csv file : %%% --- csv parser in Erlang. ------ %%% To help process large csv files without loading them into %%% memory. Similar to the xml

Erlang process hanging when it tries to kill itself

家住魔仙堡 提交于 2019-12-13 07:18:23
问题 I am running my erlang process with this script #!/bin/sh stty -f /dev/tty icanon raw erl -pa ./ -run thing start -run init -noshell stty echo echok icanon -raw my Erlang process: -module(thing). -compile(export_all). process(<<27>>) -> io:fwrite("Ch: ~w", [<<27>>]), exit(normal); process(Ch) -> io:fwrite("Ch: ~w", [Ch]), get_char(). get_char() -> Ch = io:get_chars("p: ", 1), process(Ch). start() -> io:setopts([{binary, true}]), get_char(). When I run ./invoke.sh , I press keys and see the

Output data of Erlang List as a HTML in Yaws

送分小仙女□ 提交于 2019-12-13 06:44:02
问题 Have a look at my index.yaws file below <html> <body> <h4>Data:</h4> <erl> out(Arg) -> Data = utilities:get_raw_data(), {html, io_lib:format("~p", [Data])}. </erl> <erl> out(Arg) -> Data = utilities:get_raw_data(), lists:foreach(fun(X) -> {Id, Fname, Lname} = X, io:format("ID: ~p ", [Lname]) end, Data). </erl> </body> </html> The first part of the code runs correctly producing output such as [{3,"Matt","Williamson3"}, {2,"Matt","Williamson2"}, {1,"Matt","Williamson"}] There is no error on the

Centos7 安装rabbitmq

╄→尐↘猪︶ㄣ 提交于 2019-12-13 06:43:34
一、RabbitMQ简单介绍 RabbitMQ就是当前最主流的消息中间件之一。RabbitMQ是一个开源的AMQP实现,服务器端用Erlang语言编写,支持多种客户端,如:Python、Ruby、.NET、Java、JMS、C、PHP、ActionScript、XMPP、STOMP等,支持AJAX。用于在分布式系统中存储转发消息,在易用性、扩展性、高可用性等方面表现不俗。 在目前分布式的大环境下,成为非常常用的消息队列,以下详细说明怎么在centos7 上安装部署rabbitmq,并列举简单的维护,方便运维同学能更好的维护rabbitmq的正常运行。由于一般生产环境,不管是erlang还是 rabbitmq都不能随便进行版本升级,每次升级都是要谨慎的,所以这里推荐都使用源码安装,这样就固定了版本,不会出现通过yum安装的话,不小心升级了版本导致服务故障等的问题。当然yum安装会更简单,这里就不做介绍,有兴趣的参考官方文档即可。 二、Centos7下安装rabbitmq rabbitmq是erlang语言编写的,安装rabbitmq之前,需要先安装erlang,这里用erlang的源码进行安装,erlang安装包官网下载地址:http://erlang.org/download/ wget http://erlang.org/download/otp_src_21.1.tar.gz

Inconsistent tcp_socket behavior in Erlang

穿精又带淫゛_ 提交于 2019-12-13 06:18:13
问题 In order to read input 1 character at a time, I wrote a c program that uses ssty raw . I use this character.c program to call an erlang file, naive_tcp.erl which sends a message over socket to a listening server on the same machine. I expect this server, naive_tcp2.erl , to write back with 26 lines of descending integers and an 80 character long string with 2 "|" pipes in it, so that it lines up on the 80x26 terminal. What happens instead is very inconsistent printing of data. Running .

Using odbc, are separate sql_query/2 invocations involving Select guaranteed ACID when followed by a commit

大城市里の小女人 提交于 2019-12-13 05:57:20
问题 I know that the ODBC library has a commit/2 and commit/3, but I'm not sure if I am interpreting its use correctly. If I do the following create a session with the {auto_commit, off} attribute and then do a series of separate sql_query/2 SELECT statements (not batched statements, but separate invocations of sql_query/2) followed by a commit/2 Are the selects all done within a single transaction guaranteeing ACID properties? 回答1: It seems that unixodbc-oracle driver is buggy, i.e. it doesn't

Host couchdb on heroku

烈酒焚心 提交于 2019-12-13 05:25:18
问题 I would like to host couchdb in a free heroku instance. I found here on stackoverflow an answer and it says, it is possible to host erlang code on heroku. Now I had the idea, to host couchdb on heroku. But it doesn't work. Here is my try: .>git clone https://github.com/apache/couchdb .git Cloning into 'couchdb'... remote: Counting objects: 55066, done. remote: Compressing objects: 100% (1582/1582), done. remote: Total 55066 (delta 2125), reused 3094 (delta 1808) Receiving objects: 100% (55066

Erlang VM -s argument misbehaving

陌路散爱 提交于 2019-12-13 05:15:38
问题 When I start up a function within the erl shell, it works fine. When I try to invoke the same function with erl ... -s module function, it fails. The line of code that eventually fails is: start(Port) -> mochiweb_http:start([{port, Port}, {loop, fun dispatch_requests/1}]). I'm positive that Port is set correctly. My error message is: =CRASH REPORT==== 17-Jan-2010::00:21:09 === crasher: initial call: mochiweb_socket_server:acceptor_loop/1 pid: <0.65.0> registered_name: [] exception exit:

Create list across many processes in Erlang

。_饼干妹妹 提交于 2019-12-13 04:52:01
问题 Ok, I am even having a hard time thinking of how to describe what I need. But it is really quite simple. I want to spawn n number of processes that generate n number of IDs. I have this working with some simple recursion and printing to the terminal. Where I am struggling is creating a list accessible to each of these spawned processes where I can accumulate the ids. then, when the processes are complete, I need to print-out any duplicates. I tried a few different options with ets tables and

Pausing/suspending entire Erlang program

余生颓废 提交于 2019-12-13 04:50:52
问题 Is there a simple way to suspend/pause an entire Erlang program without resorting to using OS commands (e.g. sysinternals pssuspend for Windows)? Ideally I would like to resume the program on return from an external program. 回答1: As W55tKQbuRu28Q4xv said you can "pause" process. To perform that and not lose all the messages that were sent to your process while it was paused do selective receive. Assuming that your process is a gen_server it can look like this: handle_info(pause, State) ->