Well, aside from documenting your code, as we all know is a sure sign of failure, the practice of doing really bizarre things in an effort to save CPU and disk cycles.. Observe a bit of internal notes for my currently-in-progress project (This one’s in PHP, so don’t sneer too loudly; you might hurt my feelings):
// CONFUSING PARTS:
//————————-
// ‘myid’ is a struct in the database that is an ‘auto increment’ field for the entry.
// ‘localid’ is the ID assigned to the array at the time of loading into memory.
// The whole system is based around the concept of the dynamic ‘localid’,
// except when editing or removing entries, as it will have to talk directly to
// the database, unless placed into the queue for later removal; in this
// case, it will be written into the ‘later’ queue, and processed at the time specified.
// All subroutines may be called with either data for ‘localid’, or the ‘myid’
// system; myid variables are implictly passed, where ‘localid’ are indrect
// references, except in the case of reusable functions, such as imported
// functions DB, HTTP, encryption, display, which don’t need access to
// this information in the first place!
// INTERESTING PARTS:
//————————-
// $gl – Global Variable Array
// $var – Local Variables Array
// $db – All DB related variables here; NEVER expose!
//————————-
// $gl[‘data’] contains the database as read into memory.
// $gl[‘count’] contains the count of how many records are in the database.
// SPECIAL NOTES (OR BUGS):
//————————-
// Uses the new OOP version of my DB shim, which I’ve only rewritten for
// mysqli() and mysql() support; sqlite and postgres have not
// been re-implemented, yet, so don’t try to use them; it will fail.
// Admin interface is raw; has caused outbreak of giardia; do not eat.
If you’ve read thus far, here’s some fun things: It has a fully internal captcha system that only requires libgd w/ jpeg support; uses it’s own dictionary and encryption methods (which are self referencing and 7 bit compatible for bridging over any protocol you might want (XML, XML-RPC, HTTP, uh.. carrier pigeon?), despite any state of initial data), has a non-AJAX/BUZZWORD self-referential link system where it can (will) do many things within a single process (sorry, I still require you to click a submit button; it’s just my way), and contains it’s own socket code and HTTP/1.1 compliant POST/GET retrieval system for use explicitly with url fopen purposely disabled. (However, there’s not much I can do if you don’t have the ability to create, or connect to a socket.)
Oh, yeah, the whole project is under 30k right now, including the abstraction layers – BUT, I’m currently rewriting the admin interface. After prototyping, I decided I needed something better.
Telephone still has one of the best sequences I can think of. I spent I don’t know how much time decoding MOD15 and later, MOD31 formats.. and here, 20 years after your creation, I’m still enjoying them. If not for you, Mr. Obarski, I’d probably would have spent far less time on computers.
I ran a free image hosting service in 1997. 1997, when the internet was still young, and, well, anyone who wanted to have a website ponied up the $35/yr for the privilege of the domain, and another $10-$100/month to host it. It was written in Perl, and was an unholy mess. I probably could have fudged it in a Bourne script.
These days, people don’t want to bother logging into their free hosting to share a cute picture they just found when browsing MySpace.
I’m guilty of this, too. If it takes more than an extra 5 seconds, is it really worth sharing? Sometimes.
Enter ImagePup. It doesn’t have the ton of obnoxious ads that ImageShack is now toting, and since it’s mine, I don’t have to worry about it being gone tomorrow – unless, well, I want it to be gone.
Featuring the joys of HTML 3.2 markup (Hey, Netscape 4 and Lynx still deserve SOME love..) with JavaScript supported AdSense ads (What? Hosting still isn’t all free!), two clicks, and one copy/paste, and you’re done. No intrusive popups, popunders, or the unholy flash ad.
I will be tweaking the design slightly, so it’s not quite so combersome giving you the multitude of options for displaying, sharing, or consuming your image of choice: Just another little way of turning back the clock, and giving back, while hoping to have it sustain itself.
I was looking through my cupboards, and in the mood for a sweet snack. I ended up making these; They’re pretty good, and quite easy to make!
What you’ll need:
4 tablespoons (half stick) butter or margarine
3/4 cup Karo (corn syrup) – I use the light stuff
1/2 cup sugar
1/2 cup peanut butter (creamy works best)
2-1/2 cups rolled oats
How to prepare:
Mix syrup, sugar, and butter in a saucepan. Mix/blend over medium heat until it begins to bubble. Let it cook for two minutes longer. Fold peanut butter into mix, stir until entire mixture is liquidy. Slowly stir in oats; it should get quite difficult towards the end, with barely enough peanut butter mix to seep through. Immediately spoon onto aluminum foil. Let cool, or chill in fridge.
Makes about 2 dozen small (teaspoon) or 1.5 dozen large cookies.
I know it's been forever since I've written anything; I've moved on to 'Real Life' - and it's been a wonderful replacement.
I write this merely as a useful hint to folks who might have a use for this. Several of my new projects are colocated on another system, of which I do not have root access, and do not want to localize installation of GNU utilities, only to have them. One of these being GNU date.
GNU date is much easier to use than BSD date, because, say, if I wanted now - but the month and day of exactly a week ago, I could just say:
date --day="seven days ago" " +%Y.%m.%d"
Not so in BSD. BSD's command line DATE utility will output the time in several formats - one of them being the epoch (%s), but will not allow you to feed it the date in this format, so, for my purposes, it's useless.
I ended up making this throwaway little perl script, which I call *lastweek.pl* (Originally I localized my $time with ARGV[0] to feed it the epoch and have it spit out the date, but honestly, I have no need for that, and this will make things just a touch faster in a few million years of use.)
#!/usr/bin/perl
use warnings;
use strict;
my ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst) = localtime(time() - 604800); # 604800 is 7 days in seconds.
$year += 1900;
$month += 1;
printf("%04d.%02d.%02d\n", $year, $month, $day);
What this script does is print out the year.month.day, in the same format which I store the local date (today) in my shell script. Today's date is obtained:
TODAY=`date +%Y.%m.%d`
So, to use this:
LASTWEEK=`/usr/bin/perl $HOME/bin/lastweek.pl`
Now, for the (horrible, horrible) script. Many of these things aren't commented, because they're a waste of resources (using 'tr' to print the domain in uppercase, an abuse of pipes, etc). However, my goal was to make a script that will work anywhere that has tar, gzip and the most basic system tools. (Perl is a requirement for the old file removal process, but virtually all systems have Perl 5 by now):
#!/bin/sh
PATH=/usr/local/bin:/usr/bin:/bin:/sbin
DESTDIR=$HOME/backup
FAILED=`false`
DATE=`date +%Y.%m.%d`
LASTWEEK=`/usr/bin/perl $HOME/bin/lastweek.pl`
SITES=`for n in $HOME/hosted/www.*.com; do echo $n; done` #Dumb, but gives us a space delimited array, no globbing required, and no thrashing with find.
echo "Backing up hosted sites on $DATE, "`date +%H:%M`"."
echo ""
for HOST in $SITES; do
DOMAIN=`basename $HOST | sed s,'www.','',g`
echo -n '>> '`echo $DOMAIN | tr '[a-z]' '[A-Z]'`': '
tar cPf - $HOST : gzip -9 > "$DESTDIR/$DOMAIN-$DATE.tar.gz"
if [ $? != 0 ]; then
echo "FAILED!"
FAILED=`true`
else
echo -n "done."
if [ -f "$DESTDIR/$DOMAIN-$LASTWEEK.tar.gz" ]; then
rm -r "$DESTDIR/$DOMAIN-$LASTWEEK.tar.gz2"
echo -n " Removed last week's backup."
fi
echo ""
fi
done
echo ""
if [ $FAILED == `true` ]; then
exit 1
fi
So, yeah... That's it! If you need something simple that cleans up after itself - you can either install GNU's date for your shell needs, or do as I did, and abuse Perl. ;)