HackerTrans
TopNewTrendsCommentsPastAskShowJobs

andipodean

no profile record

Submissions

Valentino Braitenberg's Vehicles

braitenberg.world
3 points·by andipodean·há 2 anos·1 comments

comments

andipodean
·há 2 anos·discuss
Perhaps the most horrible JavaScript I ever wrote did something like this, and has been very useful for over a decade and still going strong.

It's a log file that starts with a header: just a script tag with some JS, followed by a special string (I used a special HTML comment as a boundary indicator). The server then appends its logging to this file in a web hosted directory.

The JS periodically does an XHR of it's own location.href, polling itself. It then splits on the special boundary string, thus collecting the latest log data, parses it to generate pretty/coloured/linked HTML, and updates the current page according (and controls scrolling if required).

This gives you a log file that's continuously being appended to, but can be visited in the browser using any static file serving and automatically updates as it's populated.
andipodean
·há 2 anos·discuss
I built this today for Valentin(o)e's day. I've always loved these little guys since I came across them in an AI lecture. More about them: https://en.wikipedia.org/wiki/Braitenberg_vehicle