Scriptology

Té Rowan's picture

Enclosed is a rather simplistic A/B test script cribbed from stuff on the web and held together with shell-o-tape. It is run on a hacked-on-a-lot asmutils 0.18 httpd, hence the crude CGI interface.

It, and all other scripts attached, are licensed under the WTFPL. In short, you may do Whatever The F* you want to with them.

AttachmentSize
ABtest.cgi_.txt2.27 KB
hks2css.sh_.txt1.41 KB
rehint.sh_.txt447 bytes
Té Rowan's picture

Another small script posted in hope it'll be of use to someone...

hks2css turns a small internal database into a CSS stylesheet. I think it will work in any well-equipped shell environment.

Karl Stange's picture

I wish I could tell you I had the faintest idea what to do with these, maybe one day... Thanks for uploading them though!

John Hudson's picture

I'm glad I'm not the only one who hasn't got a clue what these scripts are for, Karl.

Karl Stange's picture

No, John not alone, but I would very much like to know. Reynir, any insight into their possible application would be appreciated!

Theunis de Jong's picture

Those are Bash shell scripts, right? Copy into a plain text editor and save under an appropriate name (end it with .sh). Then run from Mac OS X's Terminal and see what happens :-)

(Do not attempt on a Windows machine, it's Useless. Linux may or may not work.)

From mere eye-balling the scripts, and interpolating between the flaky bits of knowledge I have:

The first one creates a HTML file with the test characters and fonts in the top halve (it's clearly a CSS file). The http header makes me think this might get fed right into a compatible web browser.
The second one creates a HTML file with the color codes of the hex color list at its bottom, in their respective color.

... How am I doing so far, Té? :-)

I would need to encounter a specific scenario where this kind of command-chaining is useful, but then again when I do I'll make sure to look these up and see how to adjust to taste. It could be priceless stuff, and just what you are looking for -- under the right circumstances.

Karl Stange's picture

Thanks for the insight, Theunis.

Michel Boyer's picture

The second script generates a css file with lines like this

.fg_hks1 { color: #FBEF81; } .bg_hks1 { background-color: #FBEF81; }
.fg_hks2 { color: #EEEE00; } .bg_hks2 { background-color: #EEEE00; }
.fg_hks3 { color: #FFFF00; } .bg_hks3 { background-color: #FFFF00; }

I could find those HKS codes at the url
http://pbcs.dyndns.org/dcounter/journal/digitalkameraformate.htm
but my knowledge of German is too minimal to take advantage of the information contained therein.

riccard0's picture

HKS Colour System: http://en.wikipedia.org/wiki/HKS_(colour_system)

Michel Boyer's picture

I probably made a typo when searching the Wiki because nothing came out. Thanks.

Té Rowan's picture

Forgot to mention, but I got the HKS numbers in hks2css from tabelle.info. The scripts were written on a Linux box on which /bin/sh is ash, the Almquist shell, though my login shell is Bash. I think the scripts will work with BSD.

The CGI script must be adapted to amyone else's system, but it takes two font names and two file names. The file names are expanded to CSS files with @font-face declarations for the two fonts named. It returns HTML with some embedded CSS that sets up a basic comparison between the two fonts as subhead/text as well as a side-by-side comparison of some characters so you can judge their match for yourself. Can't remember off the top of my head where on the web I found this test. I merely CGIfied it.

You can use the latter script of a Windows machine, if you have a suitable port of various Unix utilities installed and working. Cygwin and mingw ought to bring them in as a matter of course, but GnuWin should suffice.

The latter script can also serve as a sample of the use of printf(1), here-documents and passwd-style databases. Any C coder should know the first already. A here-document is a document embedded in a script. Here, it's the stuff from '<<_E_O_F_' up to the '_E_O_F_' at the end.

A passwd-style database is a text file with the fields separated by semicolons. Setting IFS=: lets you read them with the usual shell commands.

There's a whole bunch of Bash tutorials out there that will explain this, and hopefully much better than I did.

Té Rowan's picture

rehint – one way of applying ttfautohint to a bunch of fonts. Also shows use of getopt, case and while. You'll almost certainly have to change the shabang from /bin/ash to /bin/sh. On my system, /bin/ash is compiled static with dietlibc to lessen startup time and memory requirements.

Hmm... gotta check how well my scripts work with the Heirloom shell and utilities.

Karl Stange's picture

Thanks, Reynir. I certainly feel enlightened if possibly no closer to (currently) having a use to which I can put them.

Syndicate content Syndicate content