Small scripts

The scripts I'm most proud of - Simple XHTML minifier

It reads from stdin and writes to stdout. The reason I wrote this script was that the other HTML minifiers I used were over-optimizing the HTML, causing validation errors.

I don't use this script any more, as my new design is based on static XHTML5 being served. (Lighttpd can compress static resources but not the output streams from CGI scripts.)

killbom - Eliminate UTF-8 Byte Order Marks

This script removes all UTF-8 BOMs from all specified files. Even BOMs, that somehow got somewhere else than in the beginning of the file, are also removed.

This script SHOULD NOT be run on binary files due to its very literal operation.

Usage: killbom [file] ...
killbom removes all UTF-8 BOM marks from files.

WARNING: It really removes all sequences of '\0xEF\0xBB\0xBF'.

WARNING: It accepts no options. All arguments are treated as filenames.
shrink-disavow - Minify Google Webmaster Tools / Search Console

It converts multiple complete URLs on the same domain to the domain: syntax.

Usage: script_name {infile} {outfile} [num_of_links]

num_of_links is the number of URLs from the same domain that will are
required for replacing all those URLs with a single 'domain:'.

The default value is two.
mkhtml - The key of my new design

The old design was based on fancy Python scripts generating the content. I made it too automated for too specific types of content.

The objectives for the new design were:

  • Autogenerate the navigation. The only thing I needed to be done automagically.
  • Work like a macro expander.
  • Generate (mostly) static content, but work for scripts too.
  • Be ran from a Makefile.

It still has some downsides:

  • A bit terribly implemented.
  • A bit limited in certain cases.
  • Quite ad-hoc.
  • Weird macro syntax.

Other scripts - Single-user authentication for webUIs.
  • Multiple keys
  • Potential attackers will have a hard time waiting for a key that they know the value of
  • Being locked out for a few minutes if authorization fails
  • Can't fool the module to accept a value for a key that has not recently been requested or that has already been used
  • It should be quite easy to hack this to accept multiple users. (Using the username as the secret directory.)

Script for downloading homework and messages from Wilma. Students living in other countries than Finland, probably have to deal with some other piece of shit.

See also:
Fail2ban, ps aux | grep ..., °C, loadavg ...

Repeatedly run top(1) and kill ssh(1) clients that are ran by "unauthorized" users.

This will prevent anyone from ssh(1)ing into your server to use you as a proxy to do malicious things.