From 5e2505653292170e6a089d581e115056716dc921 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sat, 20 Jan 2024 05:56:01 -0800 Subject: [PATCH 1/9] Add 2000/natori/try.alt.sh + improve try.sh The try.alt.sh script is slightly different from try.sh in that the order is reversed. The try.sh script now at the end always starts out in a sequence of northern hemisphere then southern hemisphere so that one can guarantee to get that form. The try.alt.sh does the same but starts out with the southern hemisphere first. --- 2000/natori/README.md | 15 ++++ 2000/natori/try.alt.sh | 162 +++++++++++++++++++++++++++++++++++++++++ 2000/natori/try.sh | 11 +++ thanks-for-help.md | 8 +- 4 files changed, 194 insertions(+), 2 deletions(-) create mode 100755 2000/natori/try.alt.sh diff --git a/2000/natori/README.md b/2000/natori/README.md index 0c0cc7e7c..ab66de871 100644 --- a/2000/natori/README.md +++ b/2000/natori/README.md @@ -22,6 +22,9 @@ version](#alternate-code) below. ./try.sh ``` +Try running this on different days, say a few days apart, and each time run it +several times in a row (or several times in a day). + Also try modifying the code so that it will show another Moon phase based on input or else just by the code itself. Bonus points if you can make it show all~ @@ -47,6 +50,9 @@ make alt ./natori.alt ``` +Try running this on different days, say a few days apart, and each time run it +several times in a row (or several times in a day). + What happens if you run it in the northern hemisphere? Are there any differences? @@ -54,6 +60,15 @@ Can you identify any Moon phases that result in the same output of both versions? Or are there any? +### Alternate try: + +```sh +./try.alt.sh +``` + +Like with [try.sh](try.sh), try using this multiple times. + + ## Judges' remarks: Here is a nice compact program that changes with the phase of the Moon. diff --git a/2000/natori/try.alt.sh b/2000/natori/try.alt.sh new file mode 100755 index 000000000..f5590e189 --- /dev/null +++ b/2000/natori/try.alt.sh @@ -0,0 +1,162 @@ +#!/usr/bin/env bash +# +# try.alt.sh - demonstrate IOCCC winner 2000/natori alt code +# + +# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it +# this way allows us to have the user specify a different compiler in an easy +# way. +if [[ -z "$CC" ]]; then + CC="cc" +fi + +make CC="$CC" everything >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + +NATORI="natori" +moon() +{ + read -r -n 1 -p "Press any key to randomly show the northern/southern hemisphere Moon: " + echo 1>&2 + for ((i=0;i<=10;i++)); do + RAND=$((RANDOM % 1000)) + if [[ "$RAND" -le 500 ]]; then + ./"$NATORI".alt + echo 1>&2 + else + ./"$NATORI" + echo 1>&2 + fi + done + + echo 1>&2 + RAND=$((RANDOM % 1000)) + if [[ "$RAND" -gt 500 ]]; then + read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: " + echo 1>&2 + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + else + read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: " + echo 1>&2 + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + fi + + echo 1>&2 + echo "We will now reverse the order." 1>&2 + echo 1>&2 + + if [[ "$RAND" -le 499 ]]; then + read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: " + echo 1>&2 + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + else + read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: " + echo 1>&2 + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + fi + + echo 1>&2 + echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2 + echo "We recommend that you try holding space down." 1>&2 + echo 1>&2 + RAND=$((RANDOM % 1000)) + if [[ "$RAND" -gt 500 ]]; then + read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI.alt"; ./"$NATORI" ; ./"$NATORI.alt" ; ./"$NATORI"; \ + ./"$NATORI.alt"; ./"$NATORI" ) | less -rEXF + else + read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI"; ./"$NATORI.alt" ; ./"$NATORI" ; ./"$NATORI.alt"; \ + ./"$NATORI"; ./"$NATORI.alt" ) | less -rEXF + fi + + echo 1>&2 + echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2 + echo "We now recommend that you try holding enter down." 1>&2 + echo 1>&2 + if [[ "$RAND" -gt 500 ]]; then + read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI.alt"; ./"$NATORI" ; ./"$NATORI.alt" ; ./"$NATORI"; \ + ./"$NATORI.alt"; ./"$NATORI" ) | less -rEXF + else + read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI"; ./"$NATORI.alt" ; ./"$NATORI" ; ./"$NATORI.alt"; \ + ./"$NATORI"; ./"$NATORI.alt" ) | less -rEXF + fi + echo 1>&2 + + echo "We will now reverse the order." 1>&2 + echo 1>&2 + echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2 + echo "We recommend that you try holding space down." 1>&2 + echo 1>&2 + if [[ "$RAND" -le 499 ]]; then + read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI.alt"; ./"$NATORI" ; ./"$NATORI.alt" ; ./"$NATORI"; \ + ./"$NATORI.alt"; ./"$NATORI" ) | less -rEXF + else + read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI"; ./"$NATORI.alt" ; ./"$NATORI" ; ./"$NATORI.alt"; \ + ./"$NATORI"; ./"$NATORI.alt" ) | less -rEXF + fi + + echo 1>&2 + echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2 + echo "We now recommend that you try holding enter down." 1>&2 + echo 1>&2 + if [[ "$RAND" -le 499 ]]; then + read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI.alt"; ./"$NATORI" ; ./"$NATORI.alt" ; ./"$NATORI"; \ + ./"$NATORI.alt"; ./"$NATORI" ) | less -rEXF + else + read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI"; ./"$NATORI.alt" ; ./"$NATORI" ; ./"$NATORI.alt"; \ + ./"$NATORI"; ./"$NATORI.alt" ) | less -rEXF + fi + echo 1>&2 + + # Finally, for the try.alt.sh (alt code, southern hemisphere), force + # starting with southern hemisphere. + echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2 + echo "We now recommend that you try holding enter down." 1>&2 + read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI.alt"; ./"$NATORI" ; ./"$NATORI.alt" ; ./"$NATORI"; \ + ./"$NATORI.alt"; ./"$NATORI" ) | less -rEXF + + echo 1>&2 + +} + +# show the Moon phase in artistic ways! +moon diff --git a/2000/natori/try.sh b/2000/natori/try.sh index e3536cc23..e5b58237c 100755 --- a/2000/natori/try.sh +++ b/2000/natori/try.sh @@ -144,6 +144,17 @@ moon() ./"$NATORI.alt"; ./"$NATORI" ) | less -rEXF fi echo 1>&2 + + # Finally, for the try.sh (original entry, northern hemisphere), force + # starting with northern hemisphere. + echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2 + echo "We now recommend that you try holding enter down." 1>&2 + read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI"; ./"$NATORI.alt" ; ./"$NATORI" ; ./"$NATORI.alt"; \ + ./"$NATORI"; ./"$NATORI.alt" ) | less -rEXF + + echo 1>&2 } # show the Moon phase in artistic ways! diff --git a/thanks-for-help.md b/thanks-for-help.md index 149d21e13..d0543f890 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -2534,8 +2534,12 @@ segfault when run or not compile at all (gcc and clang respectively). Cody also provided alternate code that supports the southern hemisphere. -Cody also provided the [try.sh](/2000/natori/try.sh) script that shows the Moon -phase in artistic ways. +Cody also provided the [try.sh](/2000/natori/try.sh) and +[try.alt.sh](/2000/natori/try.alt.sh) scripts that show the Moon phase in +artistic ways. It is recommended one try both a number of times in a row on +different days (that is run `./try.sh` several times in a row a few days apart, +until you see all the Moon phases, and run `./try.alt.sh` a few times in a row a +few days apart, until you see all the Moon phases). Later on Cody restored the `#include`s in the source code which had been changed by us to make it a one-liner again but this was an error as it was not a From 9c43c0c90a61e060008148b98425a1a7366d7f7a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sat, 20 Jan 2024 06:21:54 -0800 Subject: [PATCH 2/9] Add 1998/bas1/bas1.sh This simplifies the running of the program as the command lines (different options) can be long and more complicated to type, especially the last one. The script is menu driven. Initially I made it a loop so one can run the command once to try multiple modes but this seems unnecessary and created some display problems (depending on how invocations were done). --- 1998/bas1/README.md | 16 +--------------- 1998/bas1/bas1.sh | 36 ++++++++++++++++++++++++++++++++++++ thanks-for-help.md | 3 +++ 3 files changed, 40 insertions(+), 15 deletions(-) create mode 100755 1998/bas1/bas1.sh diff --git a/1998/bas1/README.md b/1998/bas1/README.md index a5593639c..edc15f82a 100644 --- a/1998/bas1/README.md +++ b/1998/bas1/README.md @@ -7,22 +7,8 @@ make all ## To use: -If `lpr` on your system can print PostScript: - ```sh -./bemazing | gunzip | lpr -``` - -else, while in X Window System, - -```sh -./bemazing | gunzip | gv - -``` - -or: - -```sh -./bemazing | gunzip | gs -sDEVICE=pgmraw -sOutputFile='|xv -' - +./bas1.sh ``` diff --git a/1998/bas1/bas1.sh b/1998/bas1/bas1.sh new file mode 100755 index 000000000..a00ada507 --- /dev/null +++ b/1998/bas1/bas1.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# bas1.sh - run IOCCC winner 1998/bas1 +# + +# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it +# this way allows us to have the user specify a different compiler in an easy +# way. +if [[ -z "$CC" ]]; then + CC="cc" +fi + +make CC="$CC" all >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + +echo "** Bemazing Modes ** + +(0) Use lpr (if lpr(1) can print PostScript) +(1) Use X11 (with gv(1)) +(2) Use X11 (with gs(1) and xv(1)) +" + +read -rp "Make a selection (0 - 2 or any other key to exit): " mode +echo 1>&2 + +case "${mode}" in + 0) ./bemazing | gunzip | lpr + ;; + 1) ./bemazing | gunzip | gv - + ;; + 2) ./bemazing | gunzip | gs -sDEVICE=pgmraw -sOutputFile='|xv -' - + ;; + *) exit 0 +esac diff --git a/thanks-for-help.md b/thanks-for-help.md index d0543f890..f3c0185bf 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -2247,6 +2247,9 @@ appears that they do allow 1 but for instance 4 is not allowed. However as it's quite possible they will 'fix' this defect it would be better to have this not be a problem at such a time. +Cody also added the [bas1.sh](/1998/bas1/bas1.sh) script to simplify running the +program. + ## [1998/bas2](/1998/bas2/bas2.c) ([README.md](/1998/bas2/README.md])) From 789397e415b6b4d54b532c397681187b38be6863 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sat, 20 Jan 2024 06:30:05 -0800 Subject: [PATCH 3/9] Fix typo (bad filename) in 2004/arachnid I had renamed the arachnid.info to arachnid.txt as it's not really an informative file but I forgot to update the command in the README.md file. I was tempted to rename it to arachnid.maz as it's a maze file but I kept it as a text file so that (some?) browsers know what to do with it (though I'm not sure how strictly necessary that is it doesn't hurt to have it as .txt either). --- 2004/arachnid/README.md | 2 +- thanks-for-help.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/2004/arachnid/README.md b/2004/arachnid/README.md index d38a3ff2e..0696fefed 100644 --- a/2004/arachnid/README.md +++ b/2004/arachnid/README.md @@ -19,7 +19,7 @@ code](#alternate-code) below. ## Try: ```sh -./arachnid arachnid.info +./arachnid arachnid.txt ``` and then try: diff --git a/thanks-for-help.md b/thanks-for-help.md index f3c0185bf..5e5e4c9c1 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -2930,6 +2930,11 @@ allows those like himself used to `h`, `j`, `k` and `l` movement keys to not get lost. Non rogue players, vi users and Dvorak typists are invited to get lost (or use the original version)! :-) +Cody also renamed the `arachnid.info` file to +[arachnid.txt](/2004/arachnid/arachnid.txt) as it's not really an informative +file but a maze file. The extension `.maz` was not chosen to help with (some?) +browsers knowing what to do with it. + ## [2004/burley](/2004/burley/burley.c) ([README.md](/2004/burley/README.md])) From 8bcf460db4225c83341467bba7db63950b6c3791 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sat, 20 Jan 2024 07:19:35 -0800 Subject: [PATCH 4/9] Improve to use/try for 2004/gavare --- 2004/gavare/README.md | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/2004/gavare/README.md b/2004/gavare/README.md index 022e9bf89..9bd4a2f16 100644 --- a/2004/gavare/README.md +++ b/2004/gavare/README.md @@ -10,21 +10,34 @@ for more details. ## To use: -```sh -./gavare -``` - - -## Try: - ```sh ./gavare > ioccc_ray.ppm ``` +Open `ioccc_ray.ppm` with a viewer capable of viewing PPM files. Alternatively, +if you have ImageMagick installed, you can convert it to a jpeg: + +```sh +convert ioccc_ray.ppm ioccc_ray.jpg +``` + +and then view `ioccc_ray.jpg` in a graphics viewer, editor or web browser. + + +### Try: + +If you have `xv(1)` you can do: + +```sh +./gavare | xv - +``` + +to not worry about writing it to a file and just viewing the image it creates. + ## Alternate code: -The alt code, [gavare.alt.c](gavare.alt.c), allows you to change the size of the +The alt code [gavare.alt.c](gavare.alt.c) allows you to change the size of the image as well as the anti-alias setting, when compiling. The author also provided [on their web page for the @@ -32,7 +45,7 @@ entry](https://gavare.se/ioccc/ioccc_gavare.c.html) an unobfuscated version that was used during development, which we have included in the file [gavare.r3.c](gavare.r3.c). -Finally, there's a version, [gavare.alt2.c](gavare.alt2.c) that sets binary mode +Finally, the file [gavare.alt2.c](gavare.alt2.c) sets binary mode on `stdout` which theoretically should work in Windows. @@ -56,6 +69,9 @@ You might also wish to change the anti-alias setting: make clobber AA=2 alt ``` +You may of course combine the above two commands and give any combination you +wish. + This is not possible with the author's version but it is with the alt versions (Windows - see below - and otherwise). @@ -97,7 +113,7 @@ entry contains no reserved words (I don't count `main` as a reserved word, although the compiler gives it special meaning) and no preprocessor directives. -The program is a small +This program is a small [ray-tracer](https://en.wikipedia.org/wiki/Ray_tracing_(graphics)). The first line of the source code may be modified if you want the resulting image to be of some other resolution than the predefined. The `A` value is an anti-alias From 73512d2e81e5fd7c1e0485bba6387e8178ef6056 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sat, 20 Jan 2024 09:20:55 -0800 Subject: [PATCH 5/9] Fix 2004/hibachi/src/localhost/index.html Many links no longer worked, had changed or are https enabled now. In at least two cases the Internet Wayback Machine was required but most were just changed to https. The link to cygwin had changed entirely. The link to lynx(1) had changed too. Typo fixes in src/localhost/test0.sh. Minor updates to README.md. --- 2004/hibachi/README.md | 17 ++--- 2004/hibachi/src/localhost/index.html | 62 ++++++++++--------- .../hibachi/src/localhost/test/shell/test0.sh | 4 +- thanks-for-help.md | 8 +++ 4 files changed, 49 insertions(+), 42 deletions(-) diff --git a/2004/hibachi/README.md b/2004/hibachi/README.md index 3653889a6..ef534561c 100644 --- a/2004/hibachi/README.md +++ b/2004/hibachi/README.md @@ -11,18 +11,11 @@ make cd build; ./hibachi-start.sh & ``` - -## Try: - -```sh -cd build; ./hibachi-start.sh & -``` - Then use your web browser to visit `http://localhost:8008/`. When you're finished make sure to kill `hibachi`. -NOTE: you must be in the `build` directory when running `hibachi` for this to -work. +NOTE: you must be in the `build` directory when running `hibachi-start.sh` for +this to work right. ## Judges' remarks: @@ -45,9 +38,9 @@ so the file does not exist here. `Hibachi` is a simple, small, and (probably) very secure web server. -There is a `hibachi.tgz` file that unpacks several support -files and a subdirectory tree containing the documentation and -examples. It can be viewed by: +There is a `hibachi.tgz` file (NOTE: this file was removed by the judges after +extraction) that unpacks several support files and a subdirectory tree +containing the documentation and examples. It can be viewed by: ```sh tar -zxf hibachi.tgz diff --git a/2004/hibachi/src/localhost/index.html b/2004/hibachi/src/localhost/index.html index 87113b225..d2d6a724e 100644 --- a/2004/hibachi/src/localhost/index.html +++ b/2004/hibachi/src/localhost/index.html @@ -49,7 +49,7 @@ Snert . Com - Software - Hibachi they're completely portable.

- - + epicurious.com food dictionary

@@ -60,20 +60,20 @@ Snert . Com - Software - Hibachi

HIBACHI is a simple, small, and secure web server with virtual host and CGI support. It is a limited implementation of RFC 2616 -and the CGI/1.1 Specification. +and the CGI/1.1 Specification. HIBACHI was written as an entry for the International Obfuscated C Code Contest and works -for any Unix variant including the Cygwin +for any Unix variant including the Cygwin environment for Windows.

HIBACHI supports dynamic web content through the use of the -Common Gateway Interface (CGI) specification. +Common Gateway Interface (CGI) specification. Just about any scripting or programming language can be used, such as a POSIX shell, -Perl, -PHP, -Python, and/or -Ruby. +Perl, +PHP, +Python, and/or +Ruby. Existing CGI scripts can be used with little or no modification. Hibachi executes all CGI scripts as though they were "nph" prefixed, which is to say that it is the script's responsibility to send the HTTP status line and necessary headers direct to the client. @@ -97,9 +97,10 @@ document tree is rooted at /usr/local/share/hibachi, then:

HIBACHI is ideal for special floppy-Linux distributions, like -Leka, which can be used for rescue, firewall, +Leka, which can be used for rescue, firewall, demo, or dedicated servers. In theory, with some modifications, -HIBACHI and a script interpreter, like PHP, could also be +HIBACHI and a script interpreter, like PHP, could also be bundled with CDROMS that require a means of presenting dynamic web pages.

@@ -109,22 +110,26 @@ bundled with CDROMS that require a means of presenting dynamic web pages. @@ -212,7 +217,7 @@ you should be able to access the server from the Internet using an IP or host na

-http://64.81.251.233:8008/
+https://185.199.111.153
 https://www.ioccc.org:8008/
 
@@ -241,21 +246,21 @@ These CGI scripts perform some basic tests on the handling of GET and POST reque cookies, and the passing of environment variables to CGI scripts. These CGI scripts assume that /bin/sh is a POSIX compliant shell and the standard set of POSIX utilities are available. Should work for all Unix variants -and Cygwin. +and Cygwin.
Perl Example
-Powered by Perl +Powered by Perl This example queries the Yahoo web site for a stock quote to insert into a web page. This example requires a browser with JavaScript support and -should work for all Unix variants and Cygwin, when Perl is installed. +should work for all Unix variants and Cygwin, when Perl is installed.
PHP Example
-Powered by PHP +Powered by PHP This PHP example generates a calendar complete with ISO 8601:2000 week numbers. The following commands were used to build: @@ -311,7 +316,7 @@ Click here to display the PHP Info configuration
Ruby Example
This example validates and/or generates Luhn check-digits. -Should work for all Unix variants and Cygwin, +Should work for all Unix variants and Cygwin, when Ruby is installed.
@@ -323,7 +328,7 @@ when Ruby is installed.
- FreeBSD + FreeBSD     @@ -340,7 +345,7 @@ when Ruby is installed.
- Sun Microsystems Logo + Sun Microsystems Logo 5.8 @@ -348,12 +353,13 @@ when Ruby is installed.
-Cygwin Unix Emulation +Cygwin Unix Emulation Microsoft Windows Windows 2000 SP4, Windows XP Pro SP1 -
with Cygwin, gcc 2.95.3-5 +
with Cygwin, gcc 2.95.3-5
@@ -371,7 +377,7 @@ this is an original work and placed in the public domain.