This page is under construction. The programs mentioned will be added as time permits and I get cleaned versions ready

Here I will attempt to put short programs I make from time to time others may find useful. This is of course provided that people that are interested in using them are familar with linux and know enough to make use of what is here. In general all this code is provided as is, with no warranty whatsoever under the terms of the GPL, unless otherwise specified. If you find something useful feel free to let me know. If there is interest, I might expand something here or do something here or create something else. Provided I'm not busy with something else, I would also consider doing programming work for compensation.

Finally, the code I put here, is in some ways here just to have a record of it I can go back to. No guarantee of quality or usefullness is made for anything here. Some of it may be the result of something I needed once or twice and as such may not have been extensively polished, since it had already done its job.

Coding Resources

These sites have nothing to do with me. I just thought a list of sites that I found useful when looking up things might be useful to others.

Programs

phptext.php

This is a program I wrote that takes a Latex like document and directly generates something from it. Now that is a bit of a generic explanation, but then the key part of the program is the recursive command parser with everything else just being simple php coding. For instance assume that you had a command like:

\textbf{An example of bold and \textit{italics}}

You could then write a couple of simple php functions like

function textbf{&$out,$arg}{$out.="<b>$arg</b>";}
function textit{&$out,$arg}{$out.="<i>$arg</i>";}

and then the output would be '<b>An example of bold and <i>italics</i></b>.' As you might have noticed this is along the lines of html2latex, but the work is done in php, because, I'm more familiar with that language, and unlike what your stuck with in latex you can pretty much make a document do whatever you want it to do then. Of course, this does not pretend to replace the other, at least not without a vast amount of additional work, but I spent some time making it, and I do find it useful. Right now the code that is developed is limited to something that someone might find useful when composing stories and something for building resumes, but with some imagination can be extended.

Additionally functions exist that remove comments starting with % as well as attempting to remove uneeded extra lines in the output. It should be noted that the second depends on being aware that \r and \n are possible newline characters.

txt2pdf.sh

This is just a quick way to convert a txt file like a story into a pdf so you can print it. It does not make any special attempt to create chapters and such, as with a generic file it would be difcult to predict how to parse it. You need linux, Latex, and acrobat to make it work. Do note the line that uses sed to handle some special characters Latex might choke on. If you run into others feel free to send me an email, or just edit the script as needed. Finally, as to quickly making chapters and such, well, you could edit this script so it doesn't delete the .tex file, and then go in and do some editing in kile or such. It shouldn't be too hard to handle quotes correctly as well, but the most obvious ways to do so would be to parse it in php and then reset the guess on which way the curly quotes go at the end of each sentence.

txt2pdf.sh
#!/bin/bash
BFILE="tmpFileForPrinting"
FILE=$BFILE".tex"
rm $FILE
#Note:  not using shell echo, but rather specific echo to get proper operation.
ECHO="/bin/echo"
$ECHO '\documentclass[landscape,twocolumn,letterpaper,oneside,12pt]{article}' > $FILE
$ECHO '\usepackage[landscape,pdftex]{geometry}' >> $FILE
$ECHO '\setlength{\oddsidemargin}{-0.5in}' >> $FILE
$ECHO '\setlength{\evensidemargin}{-0.5in}' >> $FILE
$ECHO '\setlength{\textwidth}{10in}' >> $FILE
$ECHO '\setlength{\columnsep}{0.5in}' >> $FILE
$ECHO '\setlength{\columnseprule}{0pt}% default=0pt (no line)' >> $FILE
$ECHO '\setlength{\textheight}{7.5in}' >> $FILE
$ECHO '\setlength{\topmargin}{-0.6in}' >> $FILE
$ECHO '\setlength{\headsep}{0in}' >> $FILE
$ECHO '\setlength{\parskip}{1.2ex}' >> $FILE
$ECHO '\setlength{\parindent}{0mm}' >> $FILE
$ECHO '%\title{}\author{}\date{}' >> $FILE
$ECHO '\begin{document}' >> $FILE
$ECHO '%\maketitle' >> $FILE
#This just changes all _ to \_ so latex doesn't choke on them...
sed 's/\\/ZSLASHZ/g' $* | tr '#' '_' |tr '&' '_' | sed 's/_/\\_/g' | sed 's/\$/\\$/g' | sed 's/\^/\\verb1\^1/g' | sed 's/ZSLASHZ/$\\backslash$/g'>> $FILE
$ECHO "\end{document}" >> $FILE
pdflatex $FILE
kpdf $BFILE.pdf
rm $BFILE.*

html2pdf

(This is planned, but currently unfinished.) I've actually done this from time to time, but I decided to put one up here at some point. Note that this is not like phptex which may indeed generate a pdf version of a story, eventually anyway. The idea behind this is to take a single html document and fix it so it creates a decent looking pdf for printing. This does not mean that everything will be right in the final output, but, in general, some attemp to automagically prepare the input for good quality pdf output will be made. For both cases, it is likely that two column output in landscape mode will be the most readable.

For plain text, all that is really needed is to have a premade latex document and some scripts that includes the result that is first processed through php to handle any special cases latex might choke on.

For html, one needs to

  1. Reverse the standard tags into their LaTeX equivalents
  2. Change any heading tags into the roughly analogous chapter, section / etc tags.
  3. Don't forget to try to parse a title out of it, creating the option to specify one one the command line wouldn't hurt as well.
  4. Remove excessive line spacing.
  5. As appropriate create headers and footers

video capture code

One example I worked out some time ago was how it would be possible to automatically have the output from a video camera uploaded onto a web page where it could be viewed from whereever. This is a simple way of doing it, and it could be fancied up, if needed, but its ultimate purpose was not to be pretty, but to be useful.

The idea is to check to see if some program like Motion has put some new files to disk. This can be done with a cron or something like Monit and a simple script. Once a change is noticed, the changes can be rsynced to a web server via an encrypted vpn connection. On the web server a php script sorts through the files and creates a web page. Furthermore the php script takes an inline argument to the url to specify a trivial password to discourage unauthorized viewing of the page

The advantage of such an approach is it doesn't require that you pay for any particular service, provided of course you have a linux web server someplace else. Additionally, even if the worst would happen to the property being monitored, the continuous updates make it very likely that the relevant snapshots are stored someplace safe, and thus could be used as needed.