Wednesday, February 17, 2010

Opening a Server at the next available free port

And also getting the port number back!
server = TCPServer.new '127.0.0.1', 0
port = server.addr[1]


(courtesy of stackoverflow / Aaron Hinni).

Matlab simultaneous assignment through deal

% Same as a = x, b = y, c = z:
[a, b, c] = deal(x, y, z);

Make any page editable with one line of code

Enter this in the browser address bar after opening the
page on which you want to test this:

javascript:document.body.contentEditable='true'; document.designMode='on'; void 0

Latex One liner to mark an error in the text

Here it is. I got it from Jacob Mattingley's website
at the Stanford University.

\newcommand{\err}[1]{\textcolor{red}{#1}}