Erlang: Using the timer:tc function in escripts

Both escripts and timer:tc features of Erlang are very useful for writing simple test code to profile functions.

There is one tiny issue with using timer:tc/1 or timer:tc/2 from within escripts though: they will not work in the interpreted execution mode.

For example, you may have an escript such as below:

#!/usr/bin/env escript


generate_list(N) ->
  lists:seq(1, N).

main(_) ->
  io:format("time: ~p~n", [timer:tc(generate_list, [1000])]).

Running this with “escript test.erl” would yield an error:

escript: exception error: undefined function test:generate_list/1
  in function  timer:tc/2 (timer.erl, line 179)

The issue is that the default escript mode is “interpreted” and not “compiled”. This leads to it not finding the function at all.

To fix the execution, one has to add the “-mode(compile).” line to the script, and also use the timer:tc/3 form of execution instead of the timer:tc/1 or timer:tc/2.

A fixed script of the above example would thus be:

#!/usr/bin/env escript



generate_list(N) ->
  lists:seq(1, N).

main(_) ->
  io:format("time: ~p~n", [timer:tc(?MODULE, generate_list, [1000])]).

I think the same should hold for apply calls too, or any function that uses the Module-Function-Arguments style of dynamic calls.

Network on ArchLinux under VMWare Fusion

If you were trying to boot up and install (netinstall) ArchLinux under VMWare Fusion, you might run into network problems at the installation stage since the base setup doesn’t seem to configure the DHCP right.

The fix is to do the following to setup the DHCP config manually:

  1. nano /etc/rc.conf
  2. Append these contents at the end:
  3. /etc/rc.d/network restart
  4. Done! You should have proper network connectivity now.

Notes notes notes. Moar Notes!

Email’s Reply-To Header and Mailing Lists

It is very irritating to have to hit “Reply to all” in an email on a mailing list in order to make your message post back to the list and not the original author of the mail you are replying to.

I never really understand why public mailing lists never implement the reply-to munging feature to always overwrite the Reply-To fields back to the mailing list address instead of the user address. Erlang’s questions list is one such example.

The mailman software’s doc page on the topic of munging “reply-to” mentions that this is a pretty sensitive issue but I fail to see why. When I get onto a mailing list with a question, I would like to have the best responses – even if that meant it had to come from multiple people. If everyone posted to the list itself, the ensuing email “conversation” can be more effective than if everyone were to reply to only the author. In the former case, people who’ve offered solutions or suggestions can still have their answers improved upon by other people who’ve read it – thereby proving more helpful than the latter case.

There is this page which asserts the RFC’s statements on what the Reply-To really stands for, and I disagree to its views since a user getting on a mailing list does not know what they want their Reply-To to be. They are posting to a public mailing list and it would be very disappointing if the mailing list does not serve the public’s interest in sharing and improving knowledge. Following standards is a good thing when it is constructive, not destructive.

Let us get a little off-track here. Have a look at Stack Overflow, or even the newer Quora – They never hide any answers from the public when a question is replied to. The answers do not privately go to the author, nor do the comments upon it. Everything is pretty much public. As a result, people have enjoyed very good answers with edits and comments; and using web search has proven to be more effective in problem-solving at work or else ever since these sites got popular. Why can’t the same ideals, then, be applied to the archaic-yet-effective mailing lists?

I’d like to state my opinions only here (in personal spaces). I do not wish to engage in “flame wars”, which is claimed to happen in discussions on these topics and thereby refuse to bring up this topic on the mailing lists that follow no reply-to overriding.

A simple email search trick

Oh boy, I love standards.

When I was wondering how do I search for mails sent by me, where I’m also the thread originator, I looked at what GMail had to offer as it search fields and other such advanced options. In the end my search was simply:

in:sent from:me term -Re

Now am wondering why it didn’t strike me immediately to look for the “Re” keyword that makes a mail a reply de-facto. Of course, there’s a much more neater, more RFC-5322 compliant way of searching such mails, but I’m unsure if GMail supports such querying.

Arkham Spider-Man

I have to play every Spider-Man game produced, somehow. So I went ahead and got my hands on the most recent one of them, “Spider-Man: Shattered Dimensions“, and oh boy. I’m blown away!

Spider-Man: Shattered Dimensions
Spider-Man: Shattered Dimensions Box Cover showing all four playable Spider-Men -- 2099, Amazing, Noir and Ultimate (The Ultimate character comes with a Venom suit)

After playing Batman: Arkham Asylum, my bar that sets the definition of a good RPG action game just took a shot towards the sky. The game-play in it was the most involving for a comic character based RPG, based on a comic character who’s at human heights. The fights were great, the moving around the area fluid and just like how the character would do, etc.. I’m sure you’ll appreciate the game if you play it, cause the story doesn’t disappoint you either.

Along came the Spider-Man game, and brought in perhaps for the first time ever, the Spider-Man 2099 and the Spider-Man Noir characters into video games! I think they’re great characterizations. The former imposing the role upon himself to get rid of a drug addiction, and the latter just facing a twisted history with his timeless humor. Their comics are great too.

Spider-Man Noir
Spider-Man Noir -- Incapacitating a henchman. All in total silence. Way cool.

Now case-in-point: Spider-Man Noir. The Noir Spider-Man levels in Shattered Dimensions is very similar to what much of Arkham Asylum had to offer. Only, it has much more pace. Any Spider-Man game worth its salt would offer deadly combos and faster-than-eye-can-follow agility during battles, and Shattered Dimensions doesn’t disappoint. The way you could incapacitate a henchman in Arkham Asylum, you can do it with Spider-Man Noir using webbing. Sneak up on them in the darkness, and web yank them to blackouts. Its Arkham Asylum all over, but with webs and sticking on walls! I’m not getting enough of this, so am going and playing more of it now. What’s more is that it offers a great bunch of classic rogues from Spider-Man gallery, across different timelines; yet you don’t get lost!

You should try this game out, its good fun with not too repetitive themes. For Spider-Man fans, it is an imperative. Stan Lee has himself voiced over a few narrations. This one is surely a timeless classic.