inotify is a cool linux kernel service, that lets you subscribe to file system events. For example, if you are interested in reacting to changes in the file "~/.emacs", and since you are not a lamer you abhor polling, you would like to be able to do something like;
inoteefy:watch(File,Fun).
where Fun gets called every time File c...more
At times you sit there at the typical Erlang conferences and hear Kostis Sagonis speak of dialyzer, typer and all the funky tools. It sounds just so great. The downside is of course that all the tools require an effort on your part. You need to read docs, understand new things and most probably change your source code in order for it to be ... w...more
For years I've wanted to start tech blogging, however not having my own RSS/blogging software always put me off. After all, what lame webserver hacker am I, blogging on someone elses RSS software. Now,
finally my friend Tobbe Tornquist did what I never did, went live with homegrown Atom code - and here I am - invited to redhoterlang.com<...more
I recently added a simple Twitter page to redhoterlang.com. It didn't require many lines of code. First we have the main function:
run() ->
Url = twitter_atom_search_url("erlang"),
Digest = base64:encode_to_string(twitter_user()++":"++twit...moreThere has recently been some discussions about ugly coding patterns like:
State1 = foo(State, ...
State2 = bar(State1, ...
State3 = baz(State2, ...
People have argued that they want destructive assignment, variable rebinding and what not.
But the thing is, doing it this way have very nice properties. For...more
I have made a little proof of concept of how Seethrough could be used as an alternative/complement to the current record-based way of constructing the HTML with Nitrogen. The gen...more
I've uploaded a little program named: exrefcheck, to Github, that we are using at Kreditor. It is a front end to xref that can be run as a standalone program. I find it extremely useful and I have caught nu...more
It is amazing that there is no decent HTML parser in the OTP distro!
As the cure, I suggest that OTP brings in the HTML parser from Mochiweb (if Bob Ippolito permits); or even better, bring in the whole of MochiWeb...
Cheers, Tobbe
...moreLots of non-emacs users are hacking Erlang nowadays it seems. This is all very good. However, the difference in indentation makes it a bit cumbersome when you want to contribute with some code.
Here is a nice little command that you can run on your code (if you're unsure that your indentation conforms to the standard).
I've put eldap, taken from jungerl, and put it at github. You'll find it here:
This way it will be easer for people to contribute (I belive that e.g ejabberd has a separate copy of eldap that has diverged from what is in jungerl).
Btw: github us great ...more
On my server at home I'm running a number of experimental systems written in Erlang. Many of them have a web interface that I want to ex...more
I got inspired by one of the talks at QCon 2008 in London the other week. This guy had made a DSL (Domain Specific Language) which resembled natural language.
This, I thought, would be nice to have as a layer on top of Mnesia QLC comprehensions. This way, even a non-Erlang person would be able to retreive data from a Mnesia DB. This coul...more
I just wrota a little Erlang library that implements Comet. This makes it easy to manipulate the DOM in the browser from the Erlang server side. You can get the code from my git repository (git clone git://www.tornkvist.org/domerl).
To use it, add the following to your HTML head:
<script type="text/javascript"...moreThe question often comes up: how can I reload my recompiled modules in an easy way. Here is some code (curtesy some Russian Erlang hacker that I have lost my reference to, please add your name as a comment below to receive your well earned credit :-)
lm() ->
[c:l(M) || M <- mm()].
mm() ->
modified_modules(...moreHere is a simple example of an AJAX request. (this is an updated, and better, example compared to the original one).
Setup the DOM
In the file ''ex1.html'' we create the DOM with a little HTML and add some Javascript that will talk with the Erlang server side.
<html>
<head>
<script type="text/jav...moreI think it would be nice to have arithmetic sequences in Erlang as they do in Haskell. For example:
[2..5] => [2,3,4,5]
[2,4..8] => [2,4,6,8]
[2,1.8..1] => [2,1.8,1.6,1.4,1.2,1]
The semantics is thus something like:
[a,b..c] => d=b-a, [a,a+d,a+d*2,a+d*3,..etc...]
...moreI just finished a little sendfile linked in driver. The idea was to explore the serving of static content. Somewhat disapointing, I couldn't notice any differences between a standard Yaws server and the iserve/ifile (sendfile) setup. On my LAN I got around 10 MB/s regardless.
Anyway, if you want to try it out. Do like this:
more
If you want to make sure that your distributed Erlang node only listens to a particular IP address and/or port you can make use of the kernel parameters: inet_dist_use_interface, inet_dist_listen_min, inet_dist_listen_max. Note: by setting the last two parameters to the same port, only that port will be used. An exampl...more
I have made the excellent iserve web server, described over at trapexit.org, available at my git repos.
Below is an example that show how to use iserve:more
There is a thread going on at the erlang-list, talking about XML processing. I'm just documenting a couple of solutions to the problem of parsing the following XML:
<Export>
<Product>
<SKU>403276</SKU>
<ItemName>Trivet</ItemName>
<CollectionNo>0</CollectionNo>
<...moreLets have a look at the current Erlang syntax and see if it can
be improved upon. When we define a function we begin with the
function name followed by the input arguments. For example, if
we begin to define a function: max(X,Y)... , but wait!
Why do we need to wrap the input arguments with parenthesises?
And why do the Variables ha...more
I decided to try and learn some Haskell this summer. What started this was some discussions on the Erlang mailing list about the Erlang syntax. At some point I suggested that an alternative syntax very well could be proposed as long as it could be executed on the Beam machine.
So in order to get some feeling for the syntax of other funct...more
We talked about the perms/1 function below at the #erlang channel the other day:
%% perms([1,2,3]) =>
%% [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
perms([]) -> [[]];
perms(L) ->
[[H|T] || H <- L,
T <- perms(L--[H])].
Recursive List Comprehensions l...more
On Tuesday 24th of July, there will be an ErlLounge in Stockholm. We will meet around 17:00 (5pm) on O'Learys bar, Vasagatan, close to the Central Station.
We will drink some beer and chat about Erlang as usual :-)
See you there!
--Tobbe
...moreNow, when Emacs 22 is released, it is even easier to get to the #erlang channel at irc.freenode.net. You just need to setup a couple of things in your ~/.emacs and then type M-x irc.
Begin by loading rcirc and define the IRC server, your Nickname and the channels you wa...more
Erlang has a very useful debugger. Here comes a quick intro on howto get it running. First you must debug compile your code.
1> c(x, [debug_info]).
{ok,x}
2> m(x). % check if it is debug compiled
Module x compiled: Date: June 4 2007, Time: 22.04
Compiler options: [export_all,debug_info,export_all]
....
moreI'm back again with a report from my forays into Erlang and Ajax land. This time I will try and be somewhat more consistent and keep my Blog updated continously.
If you read my earlier blog attempt you may think (based on the look of the site) that not much has happend. But things has happend! Unde...more