From c306944d3f69a0e529683e4c110eff35c586981a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 5 Dec 2023 11:23:32 -0800 Subject: [PATCH 1/2] Add try.sh to 2014/endoh2 + formatting/typo checks --- 2014/endoh2/.gitignore | 4 ++++ 2014/endoh2/README.md | 11 +++++---- 2014/endoh2/try.sh | 52 ++++++++++++++++++++++++++++++++++++++++++ thanks-for-fixes.md | 5 ++++ 4 files changed, 68 insertions(+), 4 deletions(-) create mode 100755 2014/endoh2/try.sh diff --git a/2014/endoh2/.gitignore b/2014/endoh2/.gitignore index a1e7bc695..6846e3735 100644 --- a/2014/endoh2/.gitignore +++ b/2014/endoh2/.gitignore @@ -1,2 +1,6 @@ prog prog.orig +hello.c +hello +ioccc.c +ioccc diff --git a/2014/endoh2/README.md b/2014/endoh2/README.md index b92a86994..02a783f0d 100644 --- a/2014/endoh2/README.md +++ b/2014/endoh2/README.md @@ -32,6 +32,7 @@ in the DNA code of the code? Perhaps there are 23 reasons? :-) ## Author's remarks: + ### Remarks This chromosome program synthesizes a double helix. @@ -39,14 +40,16 @@ The helix can also be compiled as a C program. Enjoy DNA programming! -### For more information / backgroud reading: + +### For more information / background reading: * This program was inspired by Acme::DoubleHelix: - http://search.cpan.org/~xern/Acme-DoubleHelix-0.01/ + * The synthesized helix just includes the original program at the head. - Do you see how `prog.c` determines whether it was invoked as a standalone program or included as a header file? - Note that it does not use any gcc extension such as `__INCLUDE_LEVEL__`. + Do you see how [prog.c](prog.c) determines whether it was invoked as a + standalone program or included as a header file? Note that it does not use any + gcc extension such as `__INCLUDE_LEVEL__`. * The synthesized helix of course follows the base-pairing rules for DNA: A is bonding only to T, and C is bonding only to G. diff --git a/2014/endoh2/try.sh b/2014/endoh2/try.sh new file mode 100755 index 000000000..0fbfd5a61 --- /dev/null +++ b/2014/endoh2/try.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2014/endoh2 +# + +# 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 + +read -r -n 1 -p "Press any key to run: echo Hello | ./prog: " +echo 1>&2 +echo Hello | ./prog +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo IOCCC | ./prog: " +echo 1>&2 +echo IOCCC | ./prog +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo Hello | ./prog > hello.c: " +echo 1>&2 +echo Hello | ./prog > hello.c +echo 1>&2 + +read -r -n 1 -p "Press any key to compile hello.c: " +echo 1>&2 +make hello >/dev/null +echo 1>&2 +read -r -n 1 -p "Press any key to run: ./hello: " +./hello +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo IOCCC | ./prog > ioccc.c: " +echo 1>&2 +echo IOCCC | ./prog > ioccc.c +echo 1>&2 + +read -r -n 1 -p "Press any key to compile ioccc.c: " +echo 1>&2 +make ioccc >/dev/null +echo 1>&2 +read -r -n 1 -p "Press any key to run: ./ioccc: " +echo 1>&2 +./ioccc diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index fc2dbae05..cdafd46cd 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -3705,6 +3705,11 @@ file to [spoilers.md](2014/endoh1/spoilers.md) to be clearer in its purpose as it is a file with spoilers (and too close to README.md?). +## [2014/endoh2](2014/endoh2/prog.c) ([README.md](2014/endoh2/README.md])) + +[Cody](#cody) added the [try.sh](2014/endoh2/try.sh) script. + + ## [2014/maffiodo1](2014/maffiodo1/prog.c) ([README.md](2014/maffiodo1/README.md])) [Cody](#cody) fixed the build for this entry: it does not require From c93dc6e9f6b02528cee8810a30916b0b6c37b4a2 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 5 Dec 2023 11:28:37 -0800 Subject: [PATCH 2/2] Format/typo check 2014/vik --- 2014/vik/README.md | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/2014/vik/README.md b/2014/vik/README.md index 089b53106..e43fca031 100644 --- a/2014/vik/README.md +++ b/2014/vik/README.md @@ -4,6 +4,10 @@ make ``` +There is an alternate version that will theoretically work with Windows +compilers (if anything in Windows works :-) ). See the [Alternate +code](#alternate-code) section below. + ### Bugs and (Mis)features: @@ -22,10 +26,6 @@ For more detailed information see [2014 vik in bugs.md](/bugs.md#2014-vik). ./prog > foo.c ``` -There is an alternate version that will theoretically work with Windows -compilers (if anything in Windows works :-) ). See the [Alternate -code](#alternate-code) section below. - ### Try: @@ -39,13 +39,19 @@ echo 'No. I want chocolate!' | ./prog | mplayer -demuxer rawaudio - ## Alternate code: The alternate code, [prog.alt.c](prog.alt.c), is based on the author's -instructions on how to get it to work with Windows. This has not been tested but -in order to use it you can do: +instructions on how to get it to work with Windows. + + +### Alternate build: + ```sh make alt ``` + +### Alternate use: + Use `prog.alt` as you would `prog` above as well as below. @@ -70,15 +76,16 @@ might help? :-) ## Author's remarks: + ### Remarks -This program converts ascii text to Morse audio file and vice versa. As far as +This program converts ASCII text to Morse audio file and vice versa. As far as I can tell, there are at least six chocolate references in this program. This program can convert text to Morse to a raw 44.1kHz stereo audio file. -Via streaming to mplayer, you can listen to the Morse audio. +Via streaming to `mplayer(1)`, you can listen to the Morse audio. -Don't forget the last '`-`' as it makes mplayer read from stdin. +Don't forget the last '`-`' as it makes `mplayer(1)` read from `stdin`. ## Convert audio file with Morse signals to text @@ -92,14 +99,15 @@ or alternatively pass a .wav file as input. The preferred input format 44.1kHz stereo, but it does a decent job on mono input and different frequencies as well. + ### Portability The program is portable to most platforms. The only system dependency is that -the program relies on writing binary data to stdout. +the program relies on writing binary data to `stdout`. Microsoft compilers add a carriage return to newlines, and to compile the -program with this platform, the following line can be added after the main -declaration in order for the program to run correctly: +program with this platform, the following line can be added to `main()` before +any code in order for the program to run correctly: ```c _setmode(_fileno(stdout), 0x8000); @@ -107,6 +115,7 @@ _setmode(_fileno(stdout), 0x8000); NOTE: see the [alternate code](prog.alt.c) for this. + ### Known Issues The program uses a quite simple algorithm for detecting tone on and off events