How does one access command line flag (arguments) as environment variables in Erlang. (As flags, not ARGV) For example:
RabbitMQ cli looks something like:
erl \
...
-sasl errlog_type error \
-sasl sasl_error_logger '{file,"'${RABBITMQ_SASL_LOGS}'"}' \
... # more stuff here
If one looks at sasl.erl you see the line:
get_sasl_error_lo...
First of all, I'm an Erlang rookie here. I need to interface with a MySQL database and I found the erlang-mysql-driver. I'm trying that out, and am a little confused by some of the syntax.
I can get a row of data from the database with this (greatly oversimplified for brevity here):
Result = mysql:fetch(P1, ["SELECT column1, column2 ...
(I have tagged this question as Python as well since I understand Python code so examples in Python are also welcome!).
I want to create a simple window in wxWidgets:
I create a main panel which I add to a form
I associate a boxsizer to the main panel (splitting it in two, horizontally).
I add LeftPanel to the boxsizer,
I add RightPanel...
I've been writing a game in JavaScript, and it's time to make it multiplayer. I would like to use AJAX long-polling to get the current game state, as well as implement the lobby.
The server just needs to perform basic functions, like store the gamestate in the mysql database, retrieve the gamestate, and format the scoreboard.
I think...
I need to put data in a file since my other function takes a file as input.
How to I create a uniq filename in Erlang?
Something like unix "tempfile", do it exist?
...
Hello -
Can anyone show me how to build a simple XML document using XMERL? The documentation only shows how to append to a current XML document that is read from a file. I want to create a new XML document from scratch.
For example, I want to write a simple structure like this out to an XML file:
Data = {myNode,[{foo,"Foo"},{bar,"Bar"...
I am experimenting with ErlyDB in a non-erlyweb environment and I am not having much luck.
I have a 'Thing' table for testing, and a corresponding Thing module:
-module(thing).
-export([table/0, fields/0]).
table() ->
thing.
fields() ->
[name, value].
The module itself works - I can query the database fine using ([Thing] = ...
Further to my adventures with Erlang and ErlyDB. I am attempting to get ErlyDB working with BeepBeep
My ErlyDB setup works correctly when run outside of the BeepBeep environment (see Debugging ErlyDB and MySQL). I have basically take the working code and attempted to get it running inside BeepBeep.
I have the following code in my contr...
I recently installed Erlang RFC4627 (JSON-RPC) with the debian package. I ran the test server using:
sudo erl -pa ebin
and then at the prompt:
test_jsonrpc:start_httpd().
returned
ok
I tested with http://:5671/ and got the success messages.
When I try to run rabbitmq-http2 however, I get the errors that the readme says are cau...
I would like to fetch the IP address and port number of an incoming TCP/IP connection. Unfortunately gen_tcp's accept and recv functions only give back a socket, while gen_udp's recv function also gives back the address information. Is there a straightforward way to collect address information belonging to a socket in Erlang?
...
I need to pad the output of an integer to a given length.
For example, with a length of 4 digits, the output of the integer 4 is "0004" instead of "4". How can I do this in Erlang?
...
I've been looking at the selection on Amazon and
"The Power of Events: An Introduction to Complex Event Processing in Distributed Enterprise Systems" sounds like it has way too much fluff, but the other choices like:
"Event-Based Programming: Taking Events to the Limit" sound too much like a cookbook and tie you to particular framewo...
Is there a faster way (possibly bit manipulation?) to find the size needed for an integer of a given value? Here's what I've got:
uint_length(Value) ->
if Value < 256 -> 1;
Value < 65535 -> 2;
Value < 4294967295 -> 4
end.
sint_length(Value) ->
if Value < 128 andalso Value >= 0 -> 1;
Value < 32767 andalso Value >= 0 -> 2;
Va...
For my application, I'm importing the calendar event from google calendar. The only problem which I'm facing is Time zone list. I'm getting the timezone as output from google calendar xml, which I have to check with time zone list and add time accordingly... so from where I can get this standard time zone list.. or some other alternati...
I'm trying to understand how one should design middlewares for EWGI compatibility. Given that there is no EWGI compliant web server yet, I can only ask for your opinion.
If I understand the spec. correctly, a middleware receives an #ewgi_context{} record as input, and returns another record of the same type.
Question is, is the middlew...
A common pattern in Erlang is the recursive loop that maintains state:
loop(State) ->
receive
Msg ->
NewState = whatever(Msg),
loop(NewState)
end.
Is there any way to query the state of a running process with a bif or tracing or something? Since crash messages say "...when state was..." and show the crashed process...
From what I've read in the docs, gen_servers don't trap exits. Moreover, my understanding is that if a process starts another process with spawn_link, and the child process crashes, the parent crashes too.
However, this is not what I'm seeing. I've got a gen_server that spawn_links a process. I set up a function in the child process lik...
Why does compiling this code:
triples( [], _,_,_)->
[];
triples( Self, X, Y, none )->
[ Result || Result = { X, Y, _} <- Self ].
report:
./simple_graph.erl:63: Warning: variable 'X' is unused
./simple_graph.erl:63: Warning: variable 'Y' is unused
./simple_graph.erl:64: Warning: variable 'X' is unused
./simple_graph.erl:64: Warn...
I have tried installing Erlang 13B through to 12B to follow the tutorials.
Everytime I get to c(tut), I get an error instead of (ok, tut), so it seems like there are no modules installed, can anyone point me in the right direction?
I've tried e-macs but I don't really know how to use it and haven't even got close to getting the erlang...
EDIT:
I'm not looking to use parameters as a general purpose way to construct Erlang programs--I'm still learning the traditional design principles. I'm also not looking to emulate OOP. My only point here is to make my gen_server calls consistent across server instances. This seems more like fixing a broken abstraction to me. I can imag...