Sunday, October 23, 2011

Potion - a language of dots

Potion is a little language and runtime by why the lucky stiff. Not much potion can be found from the net, so I wanted to conjure some. Check my Church numerals implementation from github: https://github.com/avuori/Churchpotion.

In many ways conjuring potion feels like writing Python and, not surprisingly, Ruby, but there are differences. One of the most distinctive syntactical feature is that in Potion dot is not used as a separation of an object and a message as in many object oriented languages, but rather, as in prose, as an indication of the end of something. 

Potion is a language of dots, and that becomes quickly apparent, as one ends up ending nested blocks of potion with several dots...... Though in some potion recipe it was mentioned that there is a convenience method of using a single underscore to end nested blocks of code to avoid the trail of dots. To me however, "dotting" was a delightful practise, like sprinkling salt into my sweet potion to make it perfect.

Potion is jitted to machine code before execution. Before that potion is compiled to an intermediate bytecode format (what seemed like a register-based virtual machine code). You can get the Potion implementation from github: https://github.com/fogus/potion. I think in some fork I saw a REPL as well but I did not try it.

A final tip: If you want to compile Potion runtime in Linux, you may need to create a symlink /lib/libdl.so -> /lib/libdl.so.2.

I discovered Potion from a fogus' post - be sure to check that as well!

Thursday, January 6, 2011

How to listen to a netradio channel when the firewall blocks the port

TCP port 8000 is being blocked in the customer's premises where I'm currently working. This is a Windows box. Putty resolves the problem easily for me, with some support from a remote FreeBSD setup. A GNU/Linux box would do the same.

1. Configure Putty to forward a TCP port to some local port in the FreeBSD machine.
From Putty configuration,
-> Connection -> SSH -> Tunnels -> "Add a new forwarded port"

  • In the Source port field, type some port, that is the port where you will be connecting to from your media player. Use for example, 8080.
  • In the Destination field, type for example, localhost:8000.

2. Now with Putty's SSH port forwarding configured, SSH to your FreeBSD/Linux account.

3. Now we need to forward the netradio data to the port what is being forwarded to the Windows machine. For that, I'm using wget and netcat. So in the Linux/FreeBSD account, command
 wget -qO-  http://relay5.slayradio.org:8000 | nc -l 8000
The above is redirecting wget's output to stdout and that is then piped to netcat that is listening to local port 8000. That was the port that is being forwarded. Note that in some version of nc, you may need to add the -p switch for it to work, e.g. "nc -l -p 8000".

4. Now, the netradio data is available from port 8080 from the Windows computer. You may now connect to http://localhost:8080/ using your favorite media player and start listening.