Natural Sort

Why doesn’t every programming language have “Natural Sorting” built in, out of the box? Natural sorting is the way humans sort, where number substrings are sorted numerically, everything else alphabetically:

Sorted “Asciibetically” (normal computer sort) Sorted “Naturally” (what humans prefer)

Notice how 10 comes before 2 in asciibetical “normal computer sorting” ? Haven’t we all seen user interfaces that like that? Its just plain wrong. 🙁

Dave Koelle’s Alphanum Algorithm sorts naturally, but instead of analyzing each array element O(log(N)) times, I present a modified Perl version that allows for Schwartzian transforms, yielding huge performance improvements.

Continue reading Natural Sort

Refresh your browser automatically during web development

Did you ever find that while editing files for the web (e.g. HTML, Javascript, Java/Flash/Ruby, whatever) that it would be cool to have your browser reflect any changes as soon as you hit Save in your IDE without having to Alt-Tab to the browser and hit refresh (Ctrl-R)? That way, you could stay entirely in your browser and just move your eyes to the browser as it refreshes automatically showing you the results of your newest changes.

Well, now you can! I’ve developed a pair of tools for that allow this when used in concert. Both are Open Source, of course.

Continue reading Refresh your browser automatically during web development

Forwarding SNMP ports over SSH using socat

Here is an example of the problem we need to solve: We have SSH access to a network, but want to access an SNMP agent in that network from a local client. We use SNMP here in this example, but it could be any other protocol that uses UDP, such as DNS or TFTP.

We’ll forward the SNMP traffic in a TCP port like this, with “socat” doing the UDP-in-TCP tunneling:

Continue reading Forwarding SNMP ports over SSH using socat