Category Archives: Uncategorized

Conway’s Life in 387 bytes of C

$ cat life.c
main(){char z[2][24][80],*a,*b,*c,*d,*e;int q,p=-1,x,y,i,k;srand(time(0));while
(1){for(strcpy(d=z[b=e=z[q=p][22],a=b-80,c=z[p],p=!p][y=23]," life.c (c) 1999 \ \033[H");y--;c=b,b=a,a=y-1?a-80:e)for((d-=80)[x=79]=10;x--;)i
=x?x-1:78,k=x-78?x+1:0,d[x]=" *\n"[q<0?rand()>>8&1:(k=a[i]+a[x]+a[k]+b[i]+b[k]+

ctry – try/catch/finally macros for C

This library supports basic try/catch/finally blocks in C. It’s pthread-safe. And the syntax is simple:

#include "ctry.h"
static FILE* open_file(const char *path, const char *mode)
  FILE *f;
  if ( ! (f = fopen(path, mode)) ) {
    ctry_raise(errno, 2, path, mode);
  return f;
static int do_it()
  ctry_BEGIN {
    ctry_BODY {
      FILE *f = open_file("non-existent.txt", "r");
      char buf[1024] = { 0 };
      fread(buf, sizeof(buf[0]), sizeof(buf) - 1, f);
    ctry_CATCH_ANY {
      ctry_exc_t *exc = ctry_exc();
      fprintf(stderr, "Error: %s (%d): %s(\"%s\", \"%s\")\n",
              strerror(exc->code), exc->code, exc->cntx.func, exc->data[0], exc->data[1]);
  } ctry_END;
  return 0;
int main(int argc, char **argv)
  assert(do_it() == 1);
  return 0;

Useful Key Performance Indicators

I’ve seen a lot of business statistic graphs over the years and many of them are useless for communicating trends.  Key Performance Indicators (KPIs) should be ubiquitous and understandable to everyone in a business.

Rules to follow

  • Absolute numbers (e.g. page views per day, widgets sold per day) tell us how a business is doing.
  • Ratios of X/unit tell us how systems are doing.
  • Ratios of Units/Profit tell us how much they cost and bridge the gap between Biz metrics and Tech metrics.
  • Simple KPIs with concrete units are easy understand. KPIs without well-understood units require too much explanation.
  • KPI plots must have the actual units specified in the legends.
  • KPI plots with the same numerator should be in the same graphic.
  • Plot Y axies should be appropriately scaled and must have a 0-origin.
  • The collection of the KPI data does not need to be exact, it must only be agreed upon.
  • KPIs must be versioned; if a KPI collection method is changed, the KPI must have a new version.


The KPIs below are relatively easy to compute and simple enough for anyone to craft given access to basic operational data.

Assume we are selling Widgets, for each Application and collectively for all Applications, sampled for each day:

Biz Metrics

  1. W = number of new widgets sold
  2. P = total money in-flow – out-flow (gross profit)
  3. WP = projected new widgets gross profit (estimated)

Applications (internal and externally facing)

  1. P = page views
  2. PE = page errors
  3. PEP = PE / P = errors / pages
  4. PT = total page time
  5. PTP = PT / P = page time / pages
  6. PW = P / W = pages / new widget sold
  7. PTW = PT / W = page time / new widgets sold
  8. PTWP = PT / WP = page time / new widgets sold gross profit

Offline Processing – Batches

  1. B = batch items
  2. BE = batch item errors
  3. BEB = BE / B = errors / items
  4. BT = total batch item time
  5. BTB = BT / B = item time / item
  6. BTP = BT / P = item time / gross profit

The Unreasonable Effectiveness of Computing

In 1960, the physicist Eugene Wigner published an article titled The Unreasonable Effectiveness of Mathematics in the Natural Sciences, arguing that the way in which the mathematical structure of a physical theory often points the way to further advances in that theory and even to empirical predictions, is not a coincidence but must reflect some larger and deeper truth about both mathematics and physics.

Is computing the deeper “truth” about mathematics and physics and reality in general? Is the true nature of reality computational? — The universe as cellular automation operating on simple rules at very small discrete scales giving rise to emergent properties at larger scales.

Front cover of Wired issue 16.07 – “The End of Science” contends that “The quest for knowledge used to begin with grand theories. Now it begins with massive amounts of data.”

John Horgan’s 1996 book – The End of Science: Facing the Limit of Knowledge in the Twilight of the Scientific Age covers perception of the slowing down of science: “Has all the knowledge worth pursuing become known?”

Scientific American: The Self-Organizing Quantum Universe describes a discrete, self-organizing, fractal, computational model of space-time: “Causal Dynamical Triangulations.” At smaller scales the model is discrete, at larger scales classical and quantum properties of space-time emerge.

Is a computational theory of reality the future of science? Are we at a threshold of science where theory is irrelevant or at least unverifiable without computing? Does the increasing use of computational modeling of the physical world point towards the inevitability of a “computational theory of everything”?

Is computing the new “Queen of the Sciences”?