Software
Sometimes I write Perl and PHP code. Not a lot of it, and no big projects,
but just little applications that get a particular job done when I
need it. The following scripts I wrote primarily with exactly that in
mind, so they're not industry-quality code. They just work for me.
I wrote them on a Linux box, so they're written to work on these. Being
Perl, they might just as well work on any other operating system, but I
don't have the time or knowledge to adapt them. If somebody feels the need
to do so, go ahead; it's absolutely fine with me.
All scripts come packaged as a ZIP file with a copy of the GNU General Public License attached. Just take the *.pl script, stick it somewhere in your $PATH and you should be done. No fancy installers.
insert_headline
Using non-free fonts as Web fonts is an infringement of copyright. For short headlines, this problem can be circumvented with the following PHP function. It uses ImageMagick to render a specified text in an arbitrary font (the .ttf file being placed outside the web root) as a bitmap, and deposits it into a specified folder. ImageMagick is only being called when content has been updated.
Arguments:
$content | Text to be typeset |
$style | An integer. Array index in $fontstyles |
$link | A boolean, determining if the text should be made into a link to a PHP page of the same name, in the same folder. Useful for creating menus. |
Globals:
$fontstyles | An array of arrays. Every inner array has the form (fontfile, size_in_px, textcolor, bgcolor). Colors are given in HTML hex notation. |
$CONVERT | /path/to/convert |
$fontsdir | Directory outside of webroot where the ttf files live. |
$imagedir | Directory inside of webroot where the finished images should be deposited. |
$imagerel | Relative path to be used inside the <img> tag that displays the image. |
function insert_headline($content, $style, $link) { global $fontstyles, $CONVERT, $fontsdir, $imagedir, $imagerel; if (!preg_match('/^\d+$/', $style) && $style<0 && $style>=count($fontstyles)) { echo "<b>ERROR:</b> No such style! <br>\n"; } else { $filename=preg_replace('/[^a-zA-Z0-9]/', '', $content); $rval=0; if (!file_exists("$imagedir/$filename.png")) { $cmd="$CONVERT -background \"".$fontstyles[$style][3]. "\" -fill \"".$fontstyles[$style][2]. "\" -font \"$fontsdir/".$fontstyles[$style][0]. "\" -pointsize \"".$fontstyles[$style][1]. "\" -trim +repage -transparent \"". $fontstyles[$style][3]. "\" label:'$content' $imagedir/$filename-$style.png 2>&1"; exec($cmd, $output, $rval); } if ($rval) { echo "<b>ERROR:</b> Image creation failed!<br>\n"; exec("rm $imagedir/$filename-$style.png"); } else { if ($link) { echo "<a href=\"$filename.php\"><img ". "src=\"$imagerel/$filename-$style.png\" ". "alt=\"$content\"></a>"; } else { echo "<img src=\"$imagerel/$filename-$style.png\" ". "alt=\"$content\">"; } } } }
Sudoku Solver
A little text-mode program doing exactly what it says, and keeping you posted about the logic it employs. Configuring the script is not necessary. No dependencies, either.
Wordsmith
A rhyming dictionary with a GUI, written in Perl/Tk. Consequentially, you need to have Tk installed, but nothing else. In order to work, this program requires a phonetic word list. For the English language, such a word list is available in the Moby project, and can be retrieved from here. Use "Moby Pronunciator", mobypron.tar.Z. Once unpacked, load mobypron.unc into WordSmith.