Archive for the ‘erlang’ Category

Erlang: Understanding gen_server

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 ...

Erlang: Create schema before starting mnesia

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.

Erlang Records Cheatsheet

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} ...

Erlang: Installing Leex

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. ...

Erlang – Working with ets:select_count

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 ...

Erlang: ETS Matching with Guards (select/2)

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 ...

Erlang: Super Basic ETS Matching Tutorial

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 ...