Home
My Resume
Code
Stu's Speedbump .9

Code I've written

Most of these are just me dinking around with date math. I started with C in the 90s, migrated to PERL in the 00s and am gradually switching to Python.

Most don't have comments since I was lazy. :)

CGI

  1. Run the Compound Interest Calculator or Download the code
  2. The ever-present environment checker: here.
  3. Show how many types of days; i.e. Sun, Mon, Tue; are between 2 dates: Number of Types or Download the code. The Calendar javascript came from OpenJS.

Perl

  1. Time Left - display a countdown clock, it requires month, day, hour and minute and takes an optional year
  2. Time Left - display a countdown clock but in a GUI window. Hardcoded time since I was using it to teach myself PERL TK for another project.
  3. XKCD Passwords - Inspired by the Password Strength XKCD comic. It should work on any Unix-like OS that has a dictionary installed.
  4. New Passwords - Generate a password based on a word in the dictionary and then change it to Leet Speak. It should work on any Unix-like OS that has a dictionary installed.

Python

  1. Time Left - display a countdown clock, it requires month, day, hour and minute and takes an optional year
  2. Add Days - Add days to today or another date

C

  1. Between tells you the number of work days, weekend days and total days between 2 dates.
  2. Time Left tells you how much time you have left in your day, it defaults to 4:30 pm since that was my shift at the time.
  3. Work Year tells you how many days of work, i.e. Monday - Friday, in the current year.
  4. Pay Days gives a listing of the pay day dates in a year. I used it to automate updating my calendar.
  5. Remember the rumor that shows up every few years that a month with 5 Fridays, 5 Saturdays and 5 Sundays or 5 Saturdays/Sundays/Mondays only happens every 800+ years? Five_Fss is code that show you months that it happens in the current year or a year that's passed in

Number formatting in the perl code came from the University of Winnipeg's CPAN repository .

The C code was written for GCC on Linux but I've compiled it using compilers on Solaris, AIX and HP-UX as well.

Creative Commons License
Stuart's Code by Stuart Jaskowiak is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

$UniqueFileID

"; # Then we'll make a unique hash... $UniqueHash=bin2hex(md5($UniqueFileID)); #print "

$Unique_Hash
"; # now we'll lock the file. $FilePointer=fopen($CounterFile,"r+"); flock($FilePointer,LOCK_EX); # Now we'll read in the values in the counter file. while ($FileCount = fscanf ($FilePointer, "%s\t%s\n")) { list($HashID,$Count)=$FileCount; $CountHash[$HashID]=$Count; } # New we'll increment the number of accesses to the counter file. $CountHash[$UniqueHash]=$CountHash[$UniqueHash]+1; # now we'll rewind to the beginning of the file rewind($FilePointer); # now we'll go through each element of the hash and write it to the file. # How? By dropping all the hashes into an array. $CountKeys=array_keys($CountHash); # The stepping through that array to write them to the file. foreach($CountKeys as $TheKey) { fwrite($FilePointer,"$TheKey {$CountHash[$TheKey]}\n"); } # now we unlock and close the file. flock($FilePointer,LOCK_UN); fclose($FilePointer); # and print out the result. #echo getcwd() . "\n"; print "

This page has been accessed {$CountHash[$UniqueHash]} times.
"; # # Some other time we can do this with pretty graphic numbers, but I wanted to keep # it simple for now. ?>