Archive for the ‘erlang’ Category
Thursday, July 15th, 2010
First, make sure you have the compile flag (+debug_info) set when compiling your source, then fire up the debugger:
1> i:im().
My Erlang Makefile:
EBIN_DIR := ebin
SRC_DIR := src
EXAMPLES_DIR := examples
INCLUDE_DIR := include
ERLC := erlc
ERLC_FLAGS := +debug_info +native -W -I $(INCLUDE_DIR) -o $(EBIN_DIR)
all:
@mkdir -p $(EBIN_DIR)
$(ERLC) $(ERLC_FLAGS) $(SRC_DIR)/*.erl
clean:
@rm -rf $(EBIN_DIR)/*
@rm -f erl_crash.dump
Read up ...
Posted in erlang | No Comments »
Friday, July 9th, 2010
This was really useful for me in scripting TextEdit to run my unit tests, as Erlide has been crashing every time I use it.
erl -run mymodule myfunc -run init stop -noshell
http://www.trapexit.org/Running_Erlang_Code_From_The_Command_Line
Posted in erlang, tips | No Comments »
Wednesday, April 22nd, 2009
Gen_server is a great way to create simple servers without having to write a lot of code at all. Here's a brief overview to get you started.
For some reason, figuring out how the gen_server behavior works in erlang was kind of a pain for me. I think it's ...
Posted in erlang, gen_server | No Comments »
Friday, April 17th, 2009
If you're running into trouble with Mnesia not writing your data to disk, make sure you create the schema BEFORE you start mnesia. Otherwise you'll get errors like
opt_disc. Directory "c:/Documents and Settings/jhaddad/workspace/Mnesia.localhost@whatever" is NOT used.
Posted in erlang | No Comments »
Tuesday, November 11th, 2008
I hate looking stuff up. I just like having this type of thing 1 click away, in a nice summary. This post is mostly for me.
Define a record:
-record( rule, {ruleid, site, rule, original} ).
You can define a record in the shell using rd:
99> rd(rule, {ruleid, site, rule, original} ...
Posted in erlang | No Comments »
Monday, November 10th, 2008
Leex is an erlang version of Lex, a Lexical Analyzer Generator written by Robert Virding. Robert (and several others in #erlang on freenode) were incredibly helpful and considerate in helping me understand these tools.
Leex is a tokenizer. It breaks the pieces of your file or text into tokens. ...
Posted in erlang, leex | No Comments »
Wednesday, October 15th, 2008
In my last post, I covered using guards with Erlang's ETS select/2 functionality.
However, what if you're looking to select a count of the number of matches for a given pattern? Lets use select_count for that.
You can use the same pattern matching I covered in my previous post.
There's ...
Posted in erlang | 2 Comments »
Friday, October 10th, 2008
Not every time we want to pull data out of an erlang ETS table is it as straightfoward as the previous example. Sometimes we want to get all values that are greater than zero, rather than just constants. We'll need to use the ets:select function, which has support for ...
Posted in erlang | 1 Comment »
Thursday, October 9th, 2008
I hate having to look stuff up to get examples, especially when I have to click on more than the first google link to figure things out. As a result, here's a very, very basic intro do doing matching with ETS and erlang. It's similar to a SELECT ...
Posted in erlang | No Comments »