erlang

Tailing a binary file in Erlang adds mysterious bit-string

I want to run tail on a named pipe to facilitate some binary logfile processing. The problem is that mysterious data is being added to the beginning of the stream. I run my tests by starting the erlang process with the opened port (open_port) and then I use another shell to cat the bin into the named pipe. Here is a simple function for ...

Decode JSON with mochijson2 in Erlang

I have a var that has some JSON data: A = <<"{\"job\": {\"id\": \"1\"}}">>. Using mochijson2, I decode the data: Struct = mochijson2:decode(A). And now I have this: {struct,[{<<"job">>,{struct,[{<<"id">>,<<"1">>}]}}]} I am trying to read (for example), "job" or "id". I tried using struct.get_value but it doesn't seem to work...

Distribute CouchDB as part of a Rails app?

I am working on a Rails project and the Architect has asked me to investigate bundling CouchDB into to application so that it can be deployed by Capistrano across multiple platforms and managed by Rake. My expectation was that I could set up the Erlang VM on the various environments and then distribute the CouchDB application with Cap...

Exception error in Erlang

So I've been using Erlang for the last eight hours, and I've spent two of those banging my head against the keyboard trying to figure out the exception error my console keeps returning. I'm writing a dice program to learn erlang. I want it to be able to call from the console through the erlang interpreter. The program accepts a number o...

erlang OTP Supervisor crashing

I'm working through the Erlang documentation, trying to understand the basics of setting up an OTP gen_server and supervisor. Whenever my gen_server crashes, my supervisor crashes as well. In fact, whenever I have an error on the command line, my supervisor crashes. I expect the gen_server to be restarted when it crashes. I expect comm...

How to set up Erlang + Emacs with erlang.el?

I have downloaded and installed Erlang and EmacsW32. But how do I use erlang.el in Emacs? Where do I place it or install it? I have read Erlang/OTP R13B04 documentation and Erlang mode for Emacs documentation but I haven't found any information about how to set up it. UPDATE 1: I have found more documentation on The Erlang mode for Ema...

Cannot spawn an erlang supervisor from the shell.

I've implemented a gen_server and supervisor: test_server and test_sup. I want to test them from the shell/CLI. I've written their start_link functions such that their names are registered locally. I've found that I can spawn the test_server from the command line just fine, but a spawned test_sup does not allow me to interact with the s...

What are Erlang processes behind the scenes?

I've got very limited knowledge about Erlang, but as far as I understand, it can spawn "processes" with a very low cost. So I wonder, what are those "processes" behind the scenes? Are they Fibers? Threads? Continuations? ...

Finding some good Erlang books

Two questions: 1) What's the best book for learning to program in Erlang? 2) And also what's the best reference book for the proficient Erlang programmer? Thanks guys! ...

Erlang: Find intersections in a ets table

I have an ets with the next items: [at, {other_place}, me], [other_place, {place}, {other_place}]], [at, {place}, me], [on, {surface}, {object}], [small, {object}] And I have the list [[at, door, me],[on, floor, chair],[small, bannanas]] I need to compare every item in the ets table to an item in the list and if the first one is the ...

How to profile an Erlang program in terms of memory usage?

I would like to further enhance the efficiency of an existing Erlang program. First I would like to identify bottlenecks and then decide on where to further optimize. I have tryed fprof, but it only gives information on total and average runtime. I would most like to see a log similar to the output of fprof, but in terms of average and...

String regex matching in Erlang

How would I do regex matching in Erlang? All I know is this: f("AAPL" ++ Inputstring) -> true. The lines that I need to match "AAPL,07-May-2010 15:58,21.34,21.36,21.34,21.35,525064\n" In Perl regex: ^AAPL,* (or something similar) In Erlang? ...

Store standalone attachments in Couchdb using ecouch Library

How do I store standalone attachments in Couchdb using eCouch library. Ecouch provides doc_create/3 and doc_Create/2, can we make use of any of these functions? Did anyone has success in storing and retrieving attachments using eCouch? Thanks in advance. ...

How do I install LFE on Ubuntu Karmic?

Erlang was already installed: $dpkg -l|grep erlang ii erlang 1:13.b.3-dfsg-2ubuntu2 Concurrent, real-time, distributed function ii erlang-appmon 1:13.b.3-dfsg-2ubuntu2 Erlang/OTP application monitor ii erlang-asn1 1:13.b.3-dfsg-2ubuntu2 Er...

Erlang: How do you reload an application env configuration?

How do you reload an application's configuration? Or, what are good strategies for managing dynamic application configuration? For example, let's say I had log levels and I wanted to change them at runtime. Also, let's assume this is one of many such options. Does it make sense to have a "configuration server" that holds configuration ...

Erlang: What's a good way to automatically assign node names?

I want to have an EC2 based cluster that can grow and shrink at will. No node will be special in any way nor do I want them to have to coordinate their names with any other nodes. I don't want to hard code the names since I want to use one image and spin them up as needed. I understand nodes have to have names to communicate, though. Wha...

Erlang code explained

Hi, I am having a bit of trouble getting my head around the following erlang code -module(threesix). -export([quicksort/1]). quicksort(Pivot, Left, Right, []=_Src) -> {Left, Pivot, Right}; quicksort(Pivot, Left, Right, [H|T]=_Src) when H < Pivot -> quicksort(Pivot, [H|Left], Right, T); quicksort(Pivot, Left, Righ...

any erlang library to query imap servers?

is there any erlang library to query imap servers? ...

Erlang: Why don't I see error_logger:info_msg output when connected by remsh?

I think the question title says it all, but, I connect to a running node with the -remsh flag, and I run my usual Common Test sanity tests, but none of the error_logger:info_msg messages appear in the shell. Why? ...

[ERLANG] Priority send and receive

I have a problem that I wonder if it can be efficiently implemented in ERLANG. I have a bunch of nodes communicating with each other using a protocol that adds priority information to messages. I would like to be able to send the highest priority messages first (at the sender) and handle them first at the receiver, before the lower-prio...