Literally A Single Page App

Inspired by a few talks I saw at CodeMash, I wanted to perform some experiments with React. I just wanted to focus on the React code, not set up build pipelines, so I wanted a single page app which was literally a single page (except for the Javascript requirements, of course). Below is the template I used for my experiments. It is super simple, all it does is source react.development.js, react-dom.development.js, and babel-core from CDNs. I just wanted to document it so that I don’t have to look it up in the future. At the bottom of the page is a larger example which includes some actual React code.

<html>
<head>
  <script crossorigin
    src="https://unpkg.com/react@16/umd/react.development.js">
  </script>
  <script crossorigin
    src="https://unpkg.com/react-dom@16/umd/react-dom.development.js">
  </script>
  <script crossorigin
    src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.min.js">
  </script>
  <script type="text/babel">
    // React code goes here
  </script>
</head>
<body>
  <div id="root"></div>
</body>
</html>

You would not want to use the in-browser babel script for production code.


Open Sourcing My iOS Apps

Markascore
Redactor
Squared
MarkShown

A few months ago I let my individual Apple Developer Program membership expire. I have been working on other projects and have not given enough attention to my iOS apps, and though they still worked, I had not updated them in a very long time. The apps were starting to look dated, and were certainly not taking advantage of the latest development frameworks. So, I decided to stop paying Apple for the privilege of keeping outdated free apps in their store.

Rather than just letting my apps disappear, I decided to open source the code so that other people might be able to use it. The apps are written in Objective-C and C, so that may limit interest in it. But, someone may be interested enough in the seam carving algorithms to deal with the archaic languages.


Colorado

Rocky Mountain National Park
Rocky Mountain National Park

A poem for Veterans Day (née Armistice Day)

Vorm Sterben mache ich noch mein Gedicht.
Still, Kameraden, stört mich nicht.
(Prior to death my poem still is to be.)
(Quiet, my comrades, do not disturb me.)

Wir ziehn zum Krieg. Der Tod ist unser Kitt.
O, heulte mir doch die Geliebte nit.
(We are off to war, where death is our tie.)
(Oh that my sweetheart would no longer cry.)

Was liegt an mir. Ich gehe gerne ein.
Die Mutter weint. Man muss aus Eisen sein.
(I will happily go, what is it to me.)
(Mothers cry, so of iron one must be.)

Die Sonne fällt zum Horizont hinab.
Bald wirft man mich ins milde Massengrab.
(The sun crashes down on the horizon like a wave.)
(I soon will be tossed, in a peaceful mass grave.)

Am Himmel brennt das brave Abendrot.
Vielleicht bin ich in dreizehn Tagen tot.
(The heavens are burning a valorous red.)
(In thirteen days I will likely be dead.)

– Alfred Lichtenstein (interpreted by Christopher Stoll)


Python Min/Max Methods Compared

I wanted to know if it would be more efficient, when searching for both a minimum and a maximum value in a list, to perform both tests in a single loop rather than making calls to both the min function and the the max function. The basis for this question was that if the min and max functions ran in O(n) time then, all else being equal, combining them into a single step should cut processing time in half. Apparently, all else is not equal; running both the min and max functions is faster than looping over all of the values once. The detailed results are listed below.


Test then Deploy an Ember App from Jenkins

Here is a quick example of how to configure Jenkins to test an Ember application and then deploy it to AWS S3 if all of the tests pass.

Testing

The first step is to create a project within Jenkins to test the app. To execute the tests the following shell commands will be executed:

npm install > test_results_npm.txt
bower cache clean > test_results_bower.txt
rm -rf bower_components >> test_results_bower.txt
bower install >> test_results_bower.txt
ember test | tee test_results.tap

The important part it to build other projects, but only if this build is stable (i.e. the tests pass).

Here is the Jenkins configuration for the test project:


Ncurses based System Performance Monitor for Mac

Simple-12 CPU

Nmond is a Ncurses based system performance monitor for Darwin (Mac OS X terminal) written in pure C. It was “forked” from nmon. The original nmon gathered system statistics by looking at /proc, which is not available on Darwin, so system calls had to be implemented for all the statistics. The original program was monolithic and used global state a lot; it was modularized during the rewrite. It’s still a work in progress.


Simple Microprocessor Design

Simple-12 CPU This details the hardware design for a simple 12-bit microporcessor. I created it for an undergraduate class which I took a few years ago. It is not really usefull for anything besides learning how computer hardware works, but I still think that it is pretty cool. I found the documentation for it on my hard drive and remebered how proud I was to have actually completed it; I am a computer scientist, not a computer engineer. Simple logic gates are used as the basis for the creation of more complex digital electronic circuits; those circuits, including a control unit, are in turn connected via a datapath to form a completed processor. The processor datapath is designed to implement the Simple-12 instruction set.


Battleship AI Algorithm Using Dynamic Programming


(image via Wikimedia)

My boys and I enjoy playing a mobile version of the classic battleship game when we are waiting our turn at the barbershop. However, the artificial intelligence algorithm this specific game uses is so feeble that even my youngest son can consistently beat the computer player. So, I started thinking about improving the algorithm. I searched the web to see if there was already an established, dominant algorithm. Although I found several clever implementations, including one that used probabilities and another based upon a checkerboard pattern, I did not find one that I particularly enjoyed. After thinking about the problem further I came to the conclusion that this problem would be well suited for a dynamic programming algorithm.

From my perspective, the best approach to take when searching for the opponent’s ship is to target a square that is in the center of the longest line of unmarked squares. It would be even better to find a target which is at the intersection of two long lines of unchecked squares. To me, this is an effective divide and conquer approach similar in spirit to the concept of binary trees, the problem is finding an efficient algorithm. The problem seems to lend itself perfectly to the dynamic programming approach.


The Ballpoint Pen

Although their use is slowly fading due to society’s increased reliance upon computers, the ballpoint pen is still used on a daily basis by most people in the United States. What is now an inescapable piece of disposable technology began its life as nothing more than an expensive and seemingly short-lived fad. Popular media accounts from the mid-1940s track the ballpoint pen’s rapid initial increase in popularity followed by its similarly precipitous drop. After this initial popularity spike the media chronicled the ballpoint pen’s gradual rise from novelty to ubiquity.

On a trip to Argentina in the summer of 1945 a businessman from Chicago named Milton Reynolds discovered a fascinating pen that he was certain could be a commercial success in the United States. Reynolds brought some of the pens back to the United States with him, and within a few months they were being mass produced by his newly formed company.