I’m a big fan of the dc calculator - what could be clearer than typing
25sc1p1p[dSa+pLarlc1-dsc0<x]sxlxx to print the first 25 fibbonacci numbers?
There are more online calculators than anyone would care to count, but I couldn’t find a dc one, so I put one online yesterday evening.
I’ve also made an instance available as a socket - connect to dc.pr0.uk, port 1312.
If you are interested in how I set it up, please read on, otherwise, please feel free to play around.
I have a small vm, on which dc is installed. That’s the starting point. To expose this to the world, I first installed xinetd, and set it up to serve dc on port 1312. This happens to be an Ubuntu box, so the command is:
Here is the entry for dc which lives at
I’ve created a user ‘dc’, with no dangerous permissions, and created a wrapper script in
This script changes carriage returns as sent via telnet into line feeds as would be send by a terminal. Without this, dc complains about not understanding the carriage return characters. I also print out the version info for dc as a banner when you first connect.
To get the web version running, we need two more steps - a service which exposes a websocket and translates between that and a normal socket, and a page which is served to clients and connects to the websocket.
I have taken both of these from websockify. To start the websockify server on port 1313, run something like this:
I used the wstelnet.html page from the websockify package, but changed the host and port to be hard coded to point to my dc server.
Finally, open the ports to the world - something like this:
And dc online is now live.