Alois Mahdal 7e5274a3dc Do not catch generic exception (catch it above) 11 yıl önce
bin Fixed typo in direction tag 11 yıl önce
cgi-bin Return text/plain (not text/javascript) 11 yıl önce
lib Do not catch generic exception (catch it above) 11 yıl önce
t Added basic helper::dmup tests 11 yıl önce
.gitignore Ignore dumps 11 yıl önce
COPYING License first!!! 12 yıl önce
COPYING.LESSER License first!!! 12 yıl önce
README.md Fixed typo 11 yıl önce
TODO.md Added TODO: create htquery 11 yıl önce

README.md

minions

My favorite tiny scripts for development and testing.

bin - UNIX scripts

autotest.pl

Script to make it easier to start developing your new Perl module under pressure of unit tests written in Test::More and the likes.

Suggested use is to have it sit on the other monitor, run all .t files around and around and be annoying about the fact that they fail. Then the rule of thumb goes without saying: "no green, no commit".

bd.pl

Binary dump. Reads STDIN, 4 bytes at a time and displays it in similar way as hexdump(1) does with -C option (Canonical hex+ASCII display)

Example:

$ echo "Hello world" | ./bd.pl
00000000  01001000 01100101 01101100 01101100  |Hell|
00000004  01101111 00100000 01110111 01101111  |o wo|
00000008  01110010 01101100 01100100 00001010  |rld.|
$

dissect_url

Split URLs into components and arguments. Output is useful to see more easily what is or is not in the URL and/or compare URls using standard tools like diff.

$ dissect_url "proto://srv:port/a/query?par1=foo&par2=bar#joe&mary"
proto://srv:port
    /a/query
    ?
        par1=foo&
        par2=bar
    #
        joe

Note that by removing all whitespace from the dissected URL you should get the original URL.

To enter multiple URLs, simply omit the argument; script will go into filter mode, where you can enter URLs one per line. Quit this mode by entering EOF (Ctrl+D) or an empty line. From this mode, output will be separated like this:

$ dissect_url < two_urls
=== url 01 =============================================
url1

=== url 02 =============================================
url2

mkexec.pl

Make executable script for you and heat up vim. Accepts filename as parameter.

  1. try to guess type from name (e.g. .pl -> perl)
  2. if filename does not exist, create it with shebang (based on which call)
  3. chmod it to 0755 (yeah, hardcoded 0755, no smartness here whatsoever)
  4. try to heat up vim or editor for you.

timestamp.pl

Script to measure how long does one second take. For those that know how long one second takes, it can serve as a snippet for Perl &stamp().

se

Translate to and from Czech. Especially sweet if you need to concentrate on the work, i.e. avoid all the blinking flashing smiling Internets looks. This guy only tells you the woords.

se [options] word

Throw a word at it and by default, it will throw you back few Czech translations of it, one pair per line. Sweet. Also supports other languages (about 10 in total).

Most useful options are --lines (default is 25) and --direction which supports direction keyword in form "LNcz.cz" or "LNcz.LN", where LN is 2-letter code (not ISO) of the other language.

Uses www.slovnik.cz, so an Internet connection and LWP::Simple are needed.

Has POD doc (se --man or se --help) worth looking at.

watchdump.pl

Trivial utility that prints a text file, clears the screen and pauses for 2s over and over.

Designed mainly for use with helper::dmup(); to enable you to see changes in your dumped data structure continuously, but obviously you can use it for any text file that will fit your screen.

For improved visual feedack, it will pre-pend the file contents with the file path and an "animation". Display of the header can be controlled by options, see --usage.

pl2yml.pl, yml2pl.pl

Simple scripts to read YAML/Perl data structure from a file and dump it in the other format to STDIN. Uses YAML::Tiny for YAML jobs.

cgi-bin - CGI scripts

hello_host.cgi

Prints overview of TCP connection details (IP addresses, ports, server user@host, time); 7 lines of plain text.

htlog.cgi

Collects GET requests with parameters msg, tag and i and logs them into single text file.

  • msg is actual message body. It can be used to contain parseable data like name=john;age=32;state=il
  • tag can be used to identify related messages like those from one test
  • use i if you tend to write tags like test01-012 .. test01-013 to store the iteration number, you'll be better off with this parameter as it won't break your ability to use tags

randomfile.pl

Send a 7-bit plain-text file via HTTP. One of these is sent:

  • random content of random length given by parameters min and max

  • EICAR test virus file

Chance to receive EICAR is given by parameter eicar (0-100).

lib - modules/libraries

helper.pm

Container module for some utility methods for Perl. Probably only dmup() is interesting—it bears a nice quick and dirty way for dumping Perl data.

htlogger.pm

API to make usage of htlog.cgi in Perl scripts even easier

use htlogr;

my $logger = htlogr::new('http://192.168.1.1/cgi-bin/htlog.cgi');

# we don't need tag nor iteration number, but it can be useful
my $tag = "synopsis_test";

$logger->log("Commencing synopsis test", $tag);

my $data = {
    foo => 1,
    bar => "Hello world"
};

foreach my $i (1..1000) {

    # log normal messages--with I!
    $logger->log("next 10 done!", $tag, $i) unless ($num % 100);

    # or a simple one-level data structures
    $logger->data(
        my_func_returning_hashref($data),
        $tag,
        $i
    );

}