My source code archive, visualized and analyzed
On this page, I've used the GodBolt Compiler Explorer and various emulators to visualize and analyze some of my earliest published programs, old homework assignments and exercises from when I first started studying software engineering.
The GodBolt compiler explorer shows original source code on the left, with the compiled representation on the right. In the case of C code the compiled representation will be assembly for the x86-64 architecture, for Java and Ruby it will be for their respective virtual machines.
Beeperd, C, 1999
I created beeperd (Beeper Daemon) in 1999, my first C program. It pings an IP address and triggers a phone call using a modem to pager if the connection goes down. Beeperd on GitHub
Analysis
- Accepts IP address an argument, and passes it to ping.
- Uses dip in DIALOUT mode.
- Forks to run as a Unix-style daemon (background) process.
- Use snprintf() for safety and consider writing logs using fprintf() instead of system("echo ...").
- Use execlp("ping", "ping", "-c", "1", IP_address, NULL); instead of system() to avoid shell execution.
-
More correct daemonization:
```c if (fork() > 0) exit(0); // Parent exits setsid(); // Create new session chdir("/"); // Change to safe directory close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); ```
Exercises from Practical C
Exercises from the book
Practical C
Calculator, Java Applet, 2001
This was written for a Java class, which focused exclusively on the now-deprecated "applets" technology. This page uses the venerable applet tag, along with the CheerpJ Applet Runner to run this in a modern browser.
Gravity demo, Java Applet, 2001
This was written for a Java class, which focused exclusively on the now-deprecated "applets" technology. This page uses the venerable applet tag, along with the CheerpJ Applet Runner to run this in a modern browser.