278
votes
\$\begingroup\$

Often, I find myself running a script or query that will take a significant amount of time to run. I can leave that script open and enjoy some guilt-free procrastination.

Now, what if I could write a script that seems to be one of the above scripts to any onlookers, but in looks only? I could put it up on a screen and enjoy days of kitten livestreams before anyone realised that all the complicated rigmarole on the screen didn't have anything to do with my actual job.

Your challenge is to write this script for me (yes, I'm that lazy).

A good answer will:

  • Make something appear on the screen that looks like a script is doing work. "Screen" can be terminal, browser, etc.
  • Be fairly original (yes, we've all seen the neverending progress bar programs)
  • Survive cursory examination by a technical person

A bad answer will:

  • Get me fired
  • Rehash something we all were forwarded in the 90's

A stellar answer might:

  • Transcend one of the bad bullet points above (for instance)
  • Survive critical examination
  • *gasp* actually do something that's useful or aids in my work shirking

Acceptance will be based on votes, with bonus from real-life results. I will actually run these scripts (Linux Mint 16) at work when my screen is visible (meetings and the like) to determine detection. If anyone notices that it's faking, you're out of the running. If someone comments on how hard I'm working, +5 bonus upvotes for you.

"Useful" in this case can apply to any coder, but if you're looking for that extra shine on your teacher-bound apple, I'm a full-stack webdev who works in code roughly according to my tags.

Question partially inspired by this.

Results

Disappointingly, I didn't get any comments either way on these entries. They're all awesome, so you're all winners in my heart. However, Loktar has the most votes by a long shot, so he gets the +15 from the accept. Congrats!

\$\endgroup\$
29
  • 6
    \$\begingroup\$ What's the winning criteria, popularity-contest? \$\endgroup\$
    – Kyle Kanos
    Jun 7, 2014 at 1:37
  • 36
    \$\begingroup\$ So... what happens if you test an answer and it actually does get you fired? \$\endgroup\$
    – Bob
    Jun 7, 2014 at 11:28
  • 54
    \$\begingroup\$ This gives me an idea for another code golf question. "Make it look like my question shouldn't be put on hold" \$\endgroup\$
    – twiz
    Jun 7, 2014 at 13:26
  • 9
    \$\begingroup\$ Just write one of these programs, and compile! \$\endgroup\$
    – ugoren
    Jun 8, 2014 at 19:15
  • 13
    \$\begingroup\$ I saw a really good remake of the Tron Legacy boardroom on Github the other day: github.com/arscan/encom-boardroom \$\endgroup\$ Jun 9, 2014 at 4:40

33 Answers 33

289
votes
\$\begingroup\$

JavaScript

So I went a little crazy with this. I did it between breaks from working on my GUI to track IP's using Visual Basic.

You can access it by going to the super serious domain I made for it tonight as well so you can look busy anywhere Gui Hacker and fork and create your own from the following sources

Basically, if you have this running no one will bother you because they know you are doing some serious stuff.

var canvas = document.querySelector(".hacker-3d-shiz"),
  ctx = canvas.getContext("2d"),
  canvasBars = document.querySelector(".bars-and-stuff"),
  ctxBars = canvasBars.getContext("2d"),
  outputConsole = document.querySelector(".output-console");

canvas.width = (window.innerWidth / 3) * 2;
canvas.height = window.innerHeight / 3;

canvasBars.width = window.innerWidth / 3;
canvasBars.height = canvas.height;

outputConsole.style.height = (window.innerHeight / 3) * 2 + 'px';
outputConsole.style.top = window.innerHeight / 3 + 'px'


/* Graphics stuff */
function Square(z) {
  this.width = canvas.width / 2;
  this.height = canvas.height;
  z = z || 0;

  this.points = [
    new Point({
      x: (canvas.width / 2) - this.width,
      y: (canvas.height / 2) - this.height,
      z: z
    }),
    new Point({
      x: (canvas.width / 2) + this.width,
      y: (canvas.height / 2) - this.height,
      z: z
    }),
    new Point({
      x: (canvas.width / 2) + this.width,
      y: (canvas.height / 2) + this.height,
      z: z
    }),
    new Point({
      x: (canvas.width / 2) - this.width,
      y: (canvas.height / 2) + this.height,
      z: z
    })
  ];
  this.dist = 0;
}

Square.prototype.update = function() {
  for (var p = 0; p < this.points.length; p++) {
    this.points[p].rotateZ(0.001);
    this.points[p].z -= 3;
    if (this.points[p].z < -300) {
      this.points[p].z = 2700;
    }
    this.points[p].map2D();
  }
}

Square.prototype.render = function() {
  ctx.beginPath();
  ctx.moveTo(this.points[0].xPos, this.points[0].yPos);
  for (var p = 1; p < this.points.length; p++) {
    if (this.points[p].z > -(focal - 50)) {
      ctx.lineTo(this.points[p].xPos, this.points[p].yPos);
    }
  }

  ctx.closePath();
  ctx.stroke();

  this.dist = this.points[this.points.length - 1].z;

};

function Point(pos) {
  this.x = pos.x - canvas.width / 2 || 0;
  this.y = pos.y - canvas.height / 2 || 0;
  this.z = pos.z || 0;

  this.cX = 0;
  this.cY = 0;
  this.cZ = 0;

  this.xPos = 0;
  this.yPos = 0;
  this.map2D();
}

Point.prototype.rotateZ = function(angleZ) {
  var cosZ = Math.cos(angleZ),
    sinZ = Math.sin(angleZ),
    x1 = this.x * cosZ - this.y * sinZ,
    y1 = this.y * cosZ + this.x * sinZ;

  this.x = x1;
  this.y = y1;
}

Point.prototype.map2D = function() {
  var scaleX = focal / (focal + this.z + this.cZ),
    scaleY = focal / (focal + this.z + this.cZ);

  this.xPos = vpx + (this.cX + this.x) * scaleX;
  this.yPos = vpy + (this.cY + this.y) * scaleY;
};

// Init graphics stuff
var squares = [],
  focal = canvas.width / 2,
  vpx = canvas.width / 2,
  vpy = canvas.height / 2,
  barVals = [],
  sineVal = 0;

for (var i = 0; i < 15; i++) {
  squares.push(new Square(-300 + (i * 200)));
}

//ctx.lineWidth = 2;
ctx.strokeStyle = ctxBars.strokeStyle = ctxBars.fillStyle = '#00FF00';

/* fake console stuff */
var commandStart = ['Performing DNS Lookups for',
    'Searching ',
    'Analyzing ',
    'Estimating Approximate Location of ',
    'Compressing ',
    'Requesting Authorization From : ',
    'wget -a -t ',
    'tar -xzf ',
    'Entering Location ',
    'Compilation Started of ',
    'Downloading '
  ],
  commandParts = ['Data Structure',
    'http://wwjd.com?au&2',
    'Texture',
    'TPS Reports',
    ' .... Searching ... ',
    'http://zanb.se/?23&88&far=2',
    'http://ab.ret45-33/?timing=1ww'
  ],
  commandResponses = ['Authorizing ',
    'Authorized...',
    'Access Granted..',
    'Going Deeper....',
    'Compression Complete.',
    'Compilation of Data Structures Complete..',
    'Entering Security Console...',
    'Encryption Unsuccesful Attempting Retry...',
    'Waiting for response...',
    '....Searching...',
    'Calculating Space Requirements '
  ],
  isProcessing = false,
  processTime = 0,
  lastProcess = 0;


function render() {
  ctx.clearRect(0, 0, canvas.width, canvas.height);

  squares.sort(function(a, b) {
    return b.dist - a.dist;
  });
  for (var i = 0, len = squares.length; i < len; i++) {
    squares[i].update();
    squares[i].render();
  }

  ctxBars.clearRect(0, 0, canvasBars.width, canvasBars.height);

  ctxBars.beginPath();
  var y = canvasBars.height / 6;
  ctxBars.moveTo(0, y);

  for (i = 0; i < canvasBars.width; i++) {
    var ran = (Math.random() * 20) - 10;
    if (Math.random() > 0.98) {
      ran = (Math.random() * 50) - 25
    }
    ctxBars.lineTo(i, y + ran);
  }

  ctxBars.stroke();

  for (i = 0; i < canvasBars.width; i += 20) {
    if (!barVals[i]) {
      barVals[i] = {
        val: Math.random() * (canvasBars.height / 2),
        freq: 0.1,
        sineVal: Math.random() * 100
      };
    }

    barVals[i].sineVal += barVals[i].freq;
    barVals[i].val += Math.sin(barVals[i].sineVal * Math.PI / 2) * 5;
    ctxBars.fillRect(i + 5, canvasBars.height, 15, -barVals[i].val);
  }

  requestAnimationFrame(render);
}

function consoleOutput() {
  var textEl = document.createElement('p');

  if (isProcessing) {
    textEl = document.createElement('span');
    textEl.textContent += Math.random() + " ";
    if (Date.now() > lastProcess + processTime) {
      isProcessing = false;
    }
  } else {
    var commandType = ~~(Math.random() * 4);
    switch (commandType) {
      case 0:
        textEl.textContent = commandStart[~~(Math.random() * commandStart.length)] + commandParts[~~(Math.random() * commandParts.length)];
        break;
      case 3:
        isProcessing = true;
        processTime = ~~(Math.random() * 5000);
        lastProcess = Date.now();
      default:
        textEl.textContent = commandResponses[~~(Math.random() * commandResponses.length)];
        break;
    }
  }

  outputConsole.scrollTop = outputConsole.scrollHeight;
  outputConsole.appendChild(textEl);

  if (outputConsole.scrollHeight > window.innerHeight) {
    var removeNodes = outputConsole.querySelectorAll('*');
    for (var n = 0; n < ~~(removeNodes.length / 3); n++) {
      outputConsole.removeChild(removeNodes[n]);
    }
  }

  setTimeout(consoleOutput, ~~(Math.random() * 200));
}

render();
consoleOutput();

window.addEventListener('resize', function() {
  canvas.width = (window.innerWidth / 3) * 2;
  canvas.height = window.innerHeight / 3;

  canvasBars.width = window.innerWidth / 3;
  canvasBars.height = canvas.height;

  outputConsole.style.height = (window.innerHeight / 3) * 2 + 'px';
  outputConsole.style.top = window.innerHeight / 3 + 'px';

  focal = canvas.width / 2;
  vpx = canvas.width / 2;
  vpy = canvas.height / 2;
  ctx.strokeStyle = ctxBars.strokeStyle = ctxBars.fillStyle = '#00FF00';
});
@font-face {
  font-family: 'Source Code Pro';
  font-style: normal;
  font-weight: 400;
  src: local('Source Code Pro'), local('SourceCodePro-Regular'), url(http://themes.googleusercontent.com/static/fonts/sourcecodepro/v4/mrl8jkM18OlOQN8JLgasDxM0YzuT7MdOe03otPbuUS0.woff) format('woff');
}
body {
  font-family: 'Source Code Pro';
  background: #000;
  color: #00FF00;
  margin: 0;
  font-size: 13px;
}
canvas {
  position: absolute;
  top: 0;
  left: 0;
}
.bars-and-stuff {
  left: 66.6%;
}
.output-console {
  position: fixed;
  overflow: hidden;
}
p {
  margin: 0
}
<canvas class='hacker-3d-shiz'></canvas>
<canvas class='bars-and-stuff'></canvas>
<div class="output-console"></div>

\$\endgroup\$
42
  • 47
    \$\begingroup\$ The painting/maintenance guys realized that i'm a programmer and not just some guy listening to music!! I wonder if this would survive some examination by a tech guy :P \$\endgroup\$ Jun 7, 2014 at 6:34
  • 17
    \$\begingroup\$ I want it as my new screensaver!! In fact, how would you do that in ubuntu? \$\endgroup\$
    – user9206
    Jun 7, 2014 at 19:36
  • 33
    \$\begingroup\$ I sat in the Toronto Public Library with this open and I noticed people behind me looking at my screen. This looks pretty 'scary' to a nontech guy. Can you can make guihacker.com allow us 2 change the title of the page to whatever we'd like, and if we can add in our own lines which will appear in the green text? I was thinking about making the title of the page 'Toronto Public Library Internet Access' and making the green lines say 'Accessing Toronto Public Library Security Database..' 'Accessing usernames and passwords...' 'Access Granted..' This may get me in some trouble but it will be fun. \$\endgroup\$ Jun 9, 2014 at 20:39
  • 37
    \$\begingroup\$ Had this running for all of 30 seconds before my fellow developers came over to ask what I was hacking into. I think that counts as a success, so +1 \$\endgroup\$ Jun 10, 2014 at 20:43
  • 10
    \$\begingroup\$ "TPS Reports"...brilliant. \$\endgroup\$
    – Dennis
    Jun 11, 2014 at 0:11
111
votes
\$\begingroup\$

Bash / coreutils

Introducing the first ever... compilation emulator. With this program, you can have epic office chair sword battles any time you like, without even writing any code!

#!/bin/bash
collect()
{
    while read line;do
        if [ -d "$line" ];then
            (for i in "$line"/*;do echo $i;done)|sort -R|collect
            echo $line
        elif [[ "$line" == *".h" ]];then
            echo $line
        fi
    done
}

sse="$(awk '/flags/{print;exit}' </proc/cpuinfo|grep -o 'sse\S*'|sed 's/^/-m/'|xargs)"

flags=""
pd="\\"

while true;do
    collect <<< /usr/include|cut -d/ -f4-|
    (
        while read line;do
            if [ "$(dirname "$line")" != "$pd" ];then
                x=$((RANDOM%8-3))
                if [[ "$x" != "-"* ]];then
                    ssef="$(sed 's/\( *\S\S*\)\{'"$x,$x"'\}$//' <<< "$sse")"
                fi
                pd="$(dirname "$line")"
                opt="-O$((RANDOM%4))"
                if [[ "$((RANDOM%2))" == 0 ]];then
                    pipe=-pipe
                fi
                case $((RANDOM%4)) in
                    0) arch=-m32;;
                    1) arch="";;
                    *) arch=-m64;;
                esac
                if [[ "$((RANDOM%3))" == 0 ]];then
                    gnu="-D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L "
                fi
                flags="gcc -w $(xargs -n1 <<< "opt pipe gnu ssef arch"|sort -R|(while read line;do eval echo \$$line;done))"
            fi
            if [ -d "/usr/include/$line" ];then
                echo $flags -shared $(for i in /usr/include/$line/*.h;do cut -d/ -f4- <<< "$i"|sed 's/h$/o/';done) -o "$line"".so"
                sleep $((RANDOM%2+1))
            else
                line=$(sed 's/h$//' <<< "$line")
                echo $flags -c $line"c" -o $line"o"
                sleep 0.$((RANDOM%4))
            fi
        done
    )
done

It uses data from /usr/include to create a realistic-looking compilation log. I was too lazy to throw random warnings in, so there's just a -w flag.

Random sample:

gcc -w -m64 -pipe -msse -msse2 -msse3 -O1 -c libiptc/xtcshared.c -o libiptc/xtcshared.o
gcc -w -m64 -pipe -msse -msse2 -msse3 -O1 -c libiptc/libip6tc.c -o libiptc/libip6tc.o
gcc -w -m64 -pipe -msse -msse2 -msse3 -O1 -c libiptc/libxtc.c -o libiptc/libxtc.o
gcc -w -m64 -pipe -msse -msse2 -msse3 -O1 -c libiptc/ipt_kernel_headers.c -o libiptc/ipt_kernel_headers.o
gcc -w -m64 -pipe -msse -msse2 -msse3 -O1 -c libiptc/libiptc.c -o libiptc/libiptc.o
gcc -w -O2 -m64 -pipe -msse -msse2 -msse3 -msse4_1 -msse4_2 -shared libiptc/ipt_kernel_headers.o libiptc/libip6tc.o libiptc/libiptc.o libiptc/libxtc.o libiptc/xtcshared.o -o libiptc.so
gcc -w -m64 -pipe -O0 -msse -msse2 -msse3 -msse4_1 -c e2p/e2p.c -o e2p/e2p.o
gcc -w -msse -msse2 -msse3 -msse4_1 -m64 -pipe -O1 -shared e2p/e2p.o -o e2p.so
gcc -w -pipe -O0 -msse -msse2 -m64 -c spice-client-gtk-2.0/spice-widget-enums.c -o spice-client-gtk-2.0/spice-widget-enums.o
gcc -w -pipe -O0 -msse -msse2 -m64 -c spice-client-gtk-2.0/spice-grabsequence.c -o spice-client-gtk-2.0/spice-grabsequence.o
gcc -w -pipe -O0 -msse -msse2 -m64 -c spice-client-gtk-2.0/spice-gtk-session.c -o spice-client-gtk-2.0/spice-gtk-session.o
gcc -w -pipe -O0 -msse -msse2 -m64 -c spice-client-gtk-2.0/spice-widget.c -o spice-client-gtk-2.0/spice-widget.o
gcc -w -pipe -O0 -msse -msse2 -m64 -c spice-client-gtk-2.0/usb-device-widget.c -o spice-client-gtk-2.0/usb-device-widget.o
gcc -w -pipe -m64 -msse -msse2 -O1 -shared spice-client-gtk-2.0/spice-grabsequence.o spice-client-gtk-2.0/spice-gtk-session.o spice-client-gtk-2.0/spice-widget-enums.o spice-client-gtk-2.0/spice-widget.o spice-client-gtk-2.0/usb-device-widget.o -o spice-client-gtk-2.0.so
gcc -w -pipe -m64 -msse -msse2 -O1 -c search.c -o search.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/path.c -o cairomm-1.0/cairomm/path.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/scaledfont.c -o cairomm-1.0/cairomm/scaledfont.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/fontface.c -o cairomm-1.0/cairomm/fontface.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/quartz_font.c -o cairomm-1.0/cairomm/quartz_font.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/win32_font.c -o cairomm-1.0/cairomm/win32_font.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/refptr.c -o cairomm-1.0/cairomm/refptr.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/cairomm.c -o cairomm-1.0/cairomm/cairomm.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/context.c -o cairomm-1.0/cairomm/context.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/enums.c -o cairomm-1.0/cairomm/enums.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/win32_surface.c -o cairomm-1.0/cairomm/win32_surface.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/pattern.c -o cairomm-1.0/cairomm/pattern.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/types.c -o cairomm-1.0/cairomm/types.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/matrix.c -o cairomm-1.0/cairomm/matrix.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/quartz_surface.c -o cairomm-1.0/cairomm/quartz_surface.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/exception.c -o cairomm-1.0/cairomm/exception.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/device.c -o cairomm-1.0/cairomm/device.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/surface.c -o cairomm-1.0/cairomm/surface.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/xlib_surface.c -o cairomm-1.0/cairomm/xlib_surface.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/fontoptions.c -o cairomm-1.0/cairomm/fontoptions.o
gcc -w -O0 -pipe -m64 -msse -msse2 -msse3 -msse4_1 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -c cairomm-1.0/cairomm/region.c -o cairomm-1.0/cairomm/region.o
gcc -w -O0 -pipe -m64 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -msse -msse2 -msse3 -msse4_1 -shared cairomm-1.0/cairomm/cairomm.o cairomm-1.0/cairomm/context.o cairomm-1.0/cairomm/device.o cairomm-1.0/cairomm/enums.o cairomm-1.0/cairomm/exception.o cairomm-1.0/cairomm/fontface.o cairomm-1.0/cairomm/fontoptions.o cairomm-1.0/cairomm/matrix.o cairomm-1.0/cairomm/path.o cairomm-1.0/cairomm/pattern.o cairomm-1.0/cairomm/quartz_font.o cairomm-1.0/cairomm/quartz_surface.o cairomm-1.0/cairomm/refptr.o cairomm-1.0/cairomm/region.o cairomm-1.0/cairomm/scaledfont.o cairomm-1.0/cairomm/surface.o cairomm-1.0/cairomm/types.o cairomm-1.0/cairomm/win32_font.o cairomm-1.0/cairomm/win32_surface.o cairomm-1.0/cairomm/xlib_surface.o -o cairomm-1.0/cairomm.so
gcc -w -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -m64 -msse -O1 -pipe -shared cairomm-1.0/*.o -o cairomm-1.0.so
gcc -w -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -m64 -msse -O1 -pipe -c ulockmgr.c -o ulockmgr.o
gcc -w -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -m64 -msse -O1 -pipe -c gshadow.c -o gshadow.o
gcc -w -O2 -msse -msse2 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -m64 -pipe -c dpkg/string.c -o dpkg/string.o
gcc -w -O2 -msse -msse2 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -m64 -pipe -c dpkg/fdio.c -o dpkg/fdio.o
gcc -w -O2 -msse -msse2 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -m64 -pipe -c dpkg/namevalue.c -o dpkg/namevalue.o
gcc -w -O2 -msse -msse2 -D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L -m64 -pipe -c dpkg/macros.c -o dpkg/macros.o
\$\endgroup\$
14
  • 4
    \$\begingroup\$ Not bad at all! Something doesn't feel quite right about this (is it that the HD keeps completely quiet?) but to the unknowing viewer it's very unlikely to raise suspicions. Although... what, it's compiling libdrm? And sys/wait.o?? What the... \$\endgroup\$ Jun 8, 2014 at 21:37
  • 27
    \$\begingroup\$ @leftaroundabout Say that you have an SSD. \$\endgroup\$
    – mniip
    Jun 8, 2014 at 22:11
  • 36
    \$\begingroup\$ To make it more authentic you should output fake compiler warnings several times per gcc line. :) \$\endgroup\$
    – monocell
    Jun 10, 2014 at 9:07
  • 3
    \$\begingroup\$ You could probably use pkg-config to come up with more realistic fake gcc flags. \$\endgroup\$ Jun 10, 2014 at 19:10
  • 3
    \$\begingroup\$ @WChargin that would not activate the HD. \$\endgroup\$ Jun 12, 2014 at 13:41
105
votes
\$\begingroup\$

Bash

Infinitely displays random hexadecimal values, with some of them highlighted to make it feel like you are performing a complicated search in raw data.

while true; do head -c200 /dev/urandom | od -An -w50 -x | grep -E --color "([[:alpha:]][[:digit:]]){2}"; sleep 0.5; done

enter image description here

\$\endgroup\$
11
  • 6
    \$\begingroup\$ Oooh, I like this one! \$\endgroup\$ Jun 9, 2014 at 21:41
  • 4
    \$\begingroup\$ (Bear with me, new to bash) but when running this line, (mac osx, terminal) I get this output on a loop: od: illegal option -- w usage: od [-aBbcDdeFfHhIiLlOosvXx] [-A base] [-j skip] [-N length] [-t type] [[+]offset[.][Bb]] [file ...] \$\endgroup\$ Jun 9, 2014 at 21:55
  • 2
    \$\begingroup\$ It seems that your version of od does not support the -w option. You can drop this option, it's here just to show more columns of data, to fill the screen a bit more. \$\endgroup\$
    – barjak
    Jun 9, 2014 at 23:45
  • 8
    \$\begingroup\$ Personally, I prefer this with sleep 0.5 changed to sleep.$[$RANDOM % 10]. It makes it a bit jerkier, and more like a real search. I do like it, though! \$\endgroup\$ Jun 10, 2014 at 17:38
  • 4
    \$\begingroup\$ Reminds me of the never ending search for "ca fe": cat /dev/random | hexdump | grep "ca fe" \$\endgroup\$
    – daviewales
    Jun 11, 2014 at 8:00
101
votes
\$\begingroup\$

A very long build:

emerge openoffice
\$\endgroup\$
8
  • 48
    \$\begingroup\$ ;_;​​​​​​​​​​​​ \$\endgroup\$
    – mniip
    Jun 7, 2014 at 8:26
  • 3
    \$\begingroup\$ Longer than Chromium? \$\endgroup\$ Jun 7, 2014 at 9:05
  • 6
    \$\begingroup\$ The problem with compiling a real project it that it will stop if an error occurs. Probably we should put this in an infinite loop. \$\endgroup\$ Jun 11, 2014 at 15:03
  • 3
    \$\begingroup\$ Do we have emerge in Linux Mint? \$\endgroup\$ Jun 11, 2014 at 15:04
  • 3
    \$\begingroup\$ On .deb systems like Ubuntu and Mint, you want sudo apt-get build-dep libreoffice; apt-get source libreoffice; cd libreoffice*; while :; do nice dpkg-buildpackage -rfakeroot; done (You will have to babysit it on its first run, at least until the real compilation starts. Subsequent runs only need the while loop.) \$\endgroup\$
    – Adam Katz
    Aug 15, 2015 at 7:39
55
votes
\$\begingroup\$

Ruby

This one will:

  1. Get a random code from this site. code review (for more readable, well written code)
  2. Make it look like you are typing this code.
require 'open-uri'
require 'nokogiri'
site = "http://codereview.stackexchange.com/"
system 'cls'
system("color 0a")
5.times do
    begin
        id = rand(1..6000)
        url = "#{site}/a/#{id}"
        page = Nokogiri::HTML(open(url))
        code = page.css('code')[0].text
    end until code
    
    code.each_char  do |char|
        print char
        sleep rand(10) / 30.0
    end
end

Here is this script based on a code taken from here:

require 'open-uri'
code = open("http://hackertyper.com/code.txt")
system 'cls'
system("color 0a")

code.each_char  do |char|
    print char
    sleep rand(10) / 30.0
 end

Here is how it looks: Code

\$\endgroup\$
9
  • 11
    \$\begingroup\$ What if the code that it gets is in Brainf**k , Golfscript or J. That will raise some suspicion. \$\endgroup\$
    – user80551
    Jun 9, 2014 at 19:28
  • 39
    \$\begingroup\$ Finally my carefully placed answers that add backdoors all around pay out \$\endgroup\$
    – PlasmaHH
    Jun 10, 2014 at 10:04
  • 1
    \$\begingroup\$ Maybe stackoverflow would be better? \$\endgroup\$ Jun 11, 2014 at 15:41
  • 3
    \$\begingroup\$ The typing speed of each one looks more realistic if I randomize the speed (and make it faster) by changing the sleep line to sleep rand(10).to_f / 30. \$\endgroup\$ Jun 12, 2014 at 6:24
  • 3
    \$\begingroup\$ I think using Code Review code on Code Golf is perfect. I've always thought of Code Golf as the evil twin of Code Review, and I love both... \$\endgroup\$ Jul 25, 2014 at 11:52
52
votes
\$\begingroup\$

Lets go with a simple bash script that makes you look hackerish by printing the contents of every file identified as text in /var/log/ line by line, with random delays to make it look like intensive things are happening. Depending on the files it hits, it can give some rather interesting output.

#/bin/bash
# this script helps you do hackerish stuff

if [ "$EUID" -ne 0 ]
then
  echo "Please run as root to be hackerish."
  exit
fi

# turn off globbing
set -f
# split on newlines only for for loops
IFS='
'
for log in $(find /var/log -type f); do
  # only use the log if it's a text file; we _will_ encounter some archived logs
  if [ `file $log | grep -e text | wc -l` -ne 0 ]
  then
    echo $log
    for line in $(cat $log); do
      echo $line
      # sleep for a random duration between 0 and 1/4 seconds to indicate hard hackerish work
      bc -l <<< $(bc <<< "$RANDOM % 10")" / 40" | xargs sleep
    done
  fi
done

Be sure your terminal theme looks hackerish. Here are some badass examples (no idea what any of this means, but it looks hackerish):

image image

\$\endgroup\$
6
  • 3
    \$\begingroup\$ Nicely done. Example screenshot is great \$\endgroup\$ Jun 9, 2014 at 23:52
  • 37
    \$\begingroup\$ Are you aware that your private keys are on these screenshots? \$\endgroup\$
    – Hubert OG
    Jun 14, 2014 at 18:33
  • 27
    \$\begingroup\$ Haha, gotcha! ;-) \$\endgroup\$
    – Hubert OG
    Jun 14, 2014 at 22:00
  • 4
    \$\begingroup\$ (But seriously, I didn't read those screenshots so I don't know what's actually there.) \$\endgroup\$
    – Hubert OG
    Jun 14, 2014 at 22:00
  • 3
    \$\begingroup\$ @HubertOG Wow, you almost gave me a heart attack... ;P I didn't see that anywhere so I thought i was going insane :O \$\endgroup\$
    – Jwosty
    Jun 14, 2014 at 22:09
49
votes
\$\begingroup\$

Bash : The endless git commit

A problem with computers today is that they are quite fast, so even compilation tasks eventually finish. Also, given a script that runs for a long time you might argue that it's actually possible to continue to work on something else while the script runs.

To solve this we have the following program. Just learn to type 'y' or 'n' randomly every now and then.

Of course you need a git repo with some new content but assuming you occasionally do actual work that should not be a problem.

#!/bin/bash

while [ 1 ]; do
  git add -p
  git reset
done
\$\endgroup\$
1
  • 12
    \$\begingroup\$ I feel most severely disturbed by this CG entry... It's either +1 or -1, but I still don't know which one! \$\endgroup\$
    – user18967
    Jun 8, 2014 at 16:43
37
votes
\$\begingroup\$

Bash

#!/bin/bash
function lazy {
    sudo apt-get update
    lazy
    }
lazy

This will just keep updating your repos. If some one notices, just say that you added a new repo for a new program, and you are testing different ones. It isn't really like faking a script, but a command.

NOTE: I do not condone being unproductive at work, but I do like experiments. Therefore I recommend this app to be used to be secretly productive.

\$\endgroup\$
7
  • 5
    \$\begingroup\$ Good, but watch out for that recursive function. \$\endgroup\$ Jun 7, 2014 at 4:34
  • 1
    \$\begingroup\$ looks like fork bomb!! \$\endgroup\$
    – Avinash R
    Jun 8, 2014 at 20:14
  • 2
    \$\begingroup\$ @AvinashR Not quite, no fork. \$\endgroup\$ Jun 8, 2014 at 21:13
  • 43
    \$\begingroup\$ Mirror hosts hate you now. \$\endgroup\$
    – Caleb
    Jun 12, 2014 at 5:38
  • 9
    \$\begingroup\$ "Not quite, no fork." So you say, only bomb? :-) \$\endgroup\$
    – celtschk
    Jun 15, 2014 at 14:25
28
votes
\$\begingroup\$

C++ Neural Network

EDIT

Sadly I optimized this code:( made it 2000x faster... The legacy code is still perfect for wasting time though!

Original

I actually started a project in convolutional neural networks perfect for this! The source code and documentation is on github. The first step is to create a new network.

std::vector<int> numNeurons = { 500, 500, 2000, 10 };
std::vector<int> numMaps = { 1, 1, 1, 1 };

ConvolutionalNeuralNetwork neuralNetwork(numNeurons, numMaps, numNeurons, 
    std::vector<std::vector<int>>(), std::vector<std::vector<int>>());

Now that we have a network with 300 neurons and 1,250,000 synapses, lets save it to a file to make sure we don't lose any progress we make with the network.

neuralNetwork.SaveToFile("test2.cnn");

That generated a 68MB text file and more than a few hours of relaxed work. Now, let's have some fun doing things with it! I'll create a random input and start to discriminate it.

std::vector<std::vector<float>> input;
for (int i = 0; i < 2; ++i)
    input.push_back(std::vector<float>{});

for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 3; ++j)
        input[i].push_back(rand() % 100);
neuralNetwork.SetInput(input);

That was a pretty small input for an image, but we're only proving the network can do something. Next step is to discriminate with it!

Layer output = neuralNetwork.Discriminate();

This hasn't even finished yet for me, and it's been running for over 2 days! Then once we get that output, let's run it through again in reverse just for fun.

Layer generatedOutput = neuralNetwork.Generate(output);

This is all just to prove that the API works, no plans for it yet. This step hasn't been run for me yet, and I've been waiting a while. Good 2+ days burned, and that is a rough estimate off my current testing. This is pretty complicated, and you'll work hard for a day or two making it, but after that you may never have to work again!

Note: If you never, ever wanna work again, try to train the network

neuralNetwork.LearnCurrentInput();

I don't even have the time to waste for this one!

If you want to show off all the data that's happening, add some calls in the functions just to display what's happening

New constructor

ConvolutionalNeuralNetwork::ConvolutionalNeuralNetwork(std::vector<int> neuronCountPerLayer, std::vector<int> featureMapsPerLayer, std::vector<int> featureMapDimensions, std::vector<std::vector<int>> featureMapConnections, std::vector<std::vector<int>> featureMapStartIndex)
{
std::map<SimpleNeuron, std::vector<Synapse>> childrenOf;
for (unsigned int i = 0; i < neuronCountPerLayer.size() - 1; ++i)
{
    Layer currentLayer;

    for (int j = 0; j < neuronCountPerLayer[i]; ++j)
    {
        std::vector<Synapse> parentOf;

        if (featureMapsPerLayer[i] == 1)
        {
            for (int n = 0; n < neuronCountPerLayer[i + 1]; ++n)
            {
                std::cout << "Adding new synapse, data: " << std::endl;

                SimpleNeuron current = SimpleNeuron(i + 1, j + 1);
                SimpleNeuron destination = SimpleNeuron(i + 2, n + 1);

                std::cout << "Origin: " << i + 1 << ", " << j + 1 << "; Destination: " << i + 2 << ", " << n + 1 << std::endl;

                Synapse currentParentSynapse = Synapse(current, current);
                Synapse currentChildSynapse = Synapse(destination, destination);

                currentChildSynapse.SetWeightDiscriminate(currentParentSynapse.GetWeightDiscriminate());
                currentChildSynapse.SetWeightGenerative(currentParentSynapse.GetWeightGenerative());

                std::cout << "Weights: Discriminative: " << currentChildSynapse.GetWeightDiscriminate() << "; Generative: " << currentChildSynapse.GetWeightGenerative() << std::endl;

                parentOf.push_back(currentParentSynapse);

                if (childrenOf.find(destination) != childrenOf.end())
                    childrenOf.at(destination).push_back(currentChildSynapse);
                else
                    childrenOf.insert(std::pair<SimpleNeuron, std::vector<Synapse>>(destination,
                    std::vector<Synapse>{ currentChildSynapse }));
            }
        }

        else
        {
            int featureMapsUp = featureMapsPerLayer[i + 1];
            int inFeatureMap = featureMapsPerLayer[i] / j;
            int connections = featureMapConnections[i][inFeatureMap];
            int startIndex = (neuronCountPerLayer[i + 1] / featureMapsUp) * featureMapStartIndex[i][inFeatureMap];
            int destinationIndex = startIndex + (neuronCountPerLayer[i + 1] / featureMapsUp) * connections;

            for (int n = startIndex; n < destinationIndex; ++n)
            {
                SimpleNeuron current = SimpleNeuron(i + 1, j + 1);
                SimpleNeuron destination = SimpleNeuron(i + 2, n + 1);

                std::cout << "Origin: " << i + 1 << ", " << j + 1 << "; Destination: " << i + 2 << ", " << n + 1 << std::endl;

                Synapse currentParentSynapse = Synapse(current, current);
                Synapse currentChildSynapse = Synapse(destination, destination);

                currentChildSynapse.SetWeightDiscriminate(currentParentSynapse.GetWeightDiscriminate());
                currentChildSynapse.SetWeightGenerative(currentParentSynapse.GetWeightGenerative());

                std::cout << "Weights: Discriminative: " << currentChildSynapse.GetWeightDiscriminate() << "; Generative: " << currentChildSynapse.GetWeightGenerative() << std::endl;

                parentOf.push_back(currentParentSynapse);

                if (childrenOf.find(destination) != childrenOf.end())
                    childrenOf.at(destination).push_back(currentChildSynapse);
                else
                    childrenOf.insert(std::pair<SimpleNeuron, std::vector<Synapse>>(destination,
                    std::vector<Synapse>{ currentChildSynapse }));
            }
        }

        std::cout << "Adding neuron" << std::endl << std::endl;

        if (childrenOf.find(SimpleNeuron(i + 1, j + 1)) != childrenOf.end())
            currentLayer.AddNeuron(Neuron(parentOf, childrenOf.at(SimpleNeuron(i + 1, j + 1))));
        else
            currentLayer.AddNeuron(Neuron(parentOf, std::vector<Synapse>{}));
    }

    std::cout << "Adding layer" << std::endl << std::endl << std::endl;

    AddLayer(currentLayer);
}

Layer output;

std::cout << "Adding final layer" << std::endl;

for (int i = 0; i < neuronCountPerLayer[neuronCountPerLayer.size() - 1]; ++i)
    output.AddNeuron(Neuron(std::vector<Synapse>(), childrenOf.at(SimpleNeuron(neuronCountPerLayer.size(), i + 1))));
AddLayer(output);
}

New FireSynapse

float Neuron::FireSynapse()
{
float sum = 0.0f;

std::cout << "Firing Synapse!" << std::endl;

for (std::vector<Synapse>::iterator it = m_ChildOfSynapses.begin(); it != m_ChildOfSynapses.end(); ++it)
    sum += ((*it).GetWeightDiscriminate() * (*it).GetParent().GetValue());

std::cout << "Total sum: " << sum << std::endl;

float probability = (1 / (1 + pow(e, -sum)));

std::cout << "Probably of firing: " << probability << std::endl;

if (probability > 0.9f)
    return 1.0f;

else if (probability < 0.1f)
    return 0.0f;

else
{
    std::cout << "Using stochastic processing to determine firing" << std::endl;
    float random = ((rand() % 100) / 100);
    if (random <= probability)
        return 1.0f;
    else
        return 0.0f;
}
}

You will get plenty of output on your console now.

\$\endgroup\$
2
  • 4
    \$\begingroup\$ +1 for the real life context as well. Interesting :) \$\endgroup\$
    – George
    Jun 11, 2014 at 20:08
  • 1
    \$\begingroup\$ Hahahaha the initials spell "CNN" \$\endgroup\$
    – anon
    Apr 12, 2016 at 18:48
26
votes
\$\begingroup\$

Python 3

#!/usr/bin/python3

import random
import time

first_level_dirs = ['main', 'home', 'usr', 'root', 'html', 'assets', 'files']
title_descs = ['page', 'script', 'interface', 'popup']
id_names = ['container', 'main', 'textbox', 'popup']
tag_names = ['div', 'textarea', 'span', 'strong', 'article', 'summary', 'blockquote', 'b']
autoclosing_tags = ['br', 'input']

def random_js_line():
    return random.choice([
        '      $("#%s").html("<b>" + $("#%s").text() + "</b>");' % (random.choice(id_names), random.choice(id_names)),
        '      $.get("t_%i.txt", function(resp) {\n        callback(resp);\n      });' % (int(random.random() * 50)),
        '      $("%s>%s").css({width: %i + "px", height: %i + "px"});' % (random.choice(tag_names), random.choice(tag_names), int(random.random() * 75), int(random.random() * 75)),
        '      for (var i = 0; i < count; i++) {\n        $("<div>").appendTo("#%s");\n      }' % (random.choice(id_names))
    ])

def random_js_lines():
    lines = [random_js_line() for _ in range(int(random.random() * 14) + 1)]
    return '\n'.join(lines)

def random_html_line():
    tag_name = random.choice(tag_names)
    return random.choice([
        '    <%s>id: %i</%s>' % (tag_name, int(random.random() * 1000), tag_name),
        '    <%s class="%s">\n      <%s/>\n    </%s>' % (tag_name, random.choice(first_level_dirs), random.choice(autoclosing_tags), tag_name),
        '    <div id="%s"></div>' % (random.choice(first_level_dirs))
    ])

def random_html_lines():
    lines = [random_html_line() for _ in range(int(random.random() * 9) + 1)]
    return '\n'.join(lines)

while True:
    print('creating /%s/%i.html' % (random.choice(first_level_dirs), int(random.random() * 1000)))
    time.sleep(random.random())
    lines = [
        '<!DOCTYPE html>',
        '<html lang="en">',
        '  <head>',
        '    <title>%s #%i</title>' % (random.choice(title_descs), int(random.random() * 100)),
        '    <script type="text/javascript" src="/js/assets/jquery.min.js"></script>',
        '    <script type="text/javascript">',
        random_js_lines(),
        '    </script>',
        '  </head>',
        '  <body>',
        random_html_lines(),
        '  </body>',
        '</html>'
    ]
    lines = [single_line for linegroup in lines for single_line in linegroup.split('\n')]
    for line in lines:
        print(line)
        time.sleep(random.random() / 10)
    print()
    time.sleep(random.random() / 2)

It outputs a bunch of lines of fake JS and HTML, with fake "loading" times (delays) to make it seem more realistic.

This can and will be expanded upon greatly! (the basic program is there; I just have to add more content now)


Here's a sample "page" it generates (this is actually from an old version of the code; I'll update it with the new code when I'm finished):

creating /assets/809.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>script #32</title>
    <script type="text/javascript" src="/js/assets/jquery.min.js"></script>
    <script type="text/javascript">
      $("#main").html("<b>" + $("#main").text() + "</b>");
      $("#textbox").html("<b>" + $("#container").text() + "</b>");
      $("#popup").html("<b>" + $("#textbox").text() + "</b>");
      $("#container").html("<b>" + $("#textbox").text() + "</b>");
      $.get("t_11.txt", function(resp) {
        callback(resp);
      });
      $("#main").html("<b>" + $("#textbox").text() + "</b>");
      $.get("t_14.txt", function(resp) {
        callback(resp);
      });
      $.get("t_1.txt", function(resp) {
        callback(resp);
      });
      $.get("t_34.txt", function(resp) {
        callback(resp);
      });
    </script>
  </head>
  <body>
    <span>id: 462</span>
    <textarea>id: 117</textarea>
  </body>
</html>
\$\endgroup\$
4
  • 3
    \$\begingroup\$ Awesome, can't wait to see what you add to it! \$\endgroup\$ Jun 7, 2014 at 6:11
  • \$\begingroup\$ heh yeah this one is pretty kick ass. My mind runs wild with cool things you could do with the generations \$\endgroup\$
    – Loktar
    Jun 7, 2014 at 6:36
  • \$\begingroup\$ Not just python3, 2.7 is ok too \$\endgroup\$ Jun 7, 2014 at 9:16
  • 1
    \$\begingroup\$ Great job. Looks pretty realistic. \$\endgroup\$
    – qwr
    Jun 8, 2014 at 19:08
24
votes
\$\begingroup\$

Node.js + BDD

Looks like an endless stream of BDD-style tests running. Nobody can blame you for running tests!

    "use strict"
var colors = require("colors"),
    features = ["User", "Request", "Response", "Cache", "Preference", "Token", "Profile", "Application", "Security"],
    patterns = ["Factory", "Observer", "Manager", "Repository", "Impl", "Dao", "Service", "Delegate", "Activity"],
    requirements = ["return HTTP 403 to unauthorized users",
                    "accept UTF-8 input",
                    "return HTTP 400 for invalid input",
                    "correctly escape SQL",
                    "validate redirects",
                    "provide online documentation",
                    "select internationalized strings, based on locale",
                    "support localized date formats",
                    "work in IE6",
                    "pass W3C validation",
                    "produce valid JSON",
                    "work with screen readers",
                    "use HTML5 canvas where available",
                    "blink"],
    minTimeout = 100,
    maxTimeout = 1000,
    minRequirements = 2,
    maxRequirements = 6,
    skipThreshold = 0.1,
    failThreshold = 0.2


function randBetween(l, u) {
  return Math.floor(Math.random() * (u - l) + l) 
}

function choose(l) {
  return l[randBetween(0, l.length)]
}

function timeout() {
  return randBetween(minTimeout, maxTimeout)
}

function printFeature() {
  console.log("")
  var feature = choose(features) + choose(patterns)
  var article = /^[AEIOU]/.test(feature) ? "An " : "A "
  console.log(article + feature + " should")
  setTimeout(function() {
    var reqs = randBetween(minRequirements, maxRequirements)
    printRequirements(reqs)
  }, timeout())
}

function printRequirements(i) {
  if (i > 0) {
    var skipFailOrPass = Math.random()
    if (skipFailOrPass < skipThreshold) {
      console.log(("- " + choose(requirements) + " (SKIPPED)").cyan)
    } else if (skipFailOrPass < failThreshold) {
      console.log(("x " + choose(requirements) + " (FAILED)").red)
      console.log(("  - Given I am on the " + choose(features) + " page").green)
      console.log(("  - When I click on the " + choose(features) + " link").green)
      console.log(("  x Then the Log Out link should be visible in the top right hand corner").red)
    } else {
      console.log(("+ " + choose(requirements)).green)
    }
    setTimeout(function() {printRequirements(i - 1)}, timeout())
  } else {
    printFeature()
  }
}

printFeature()

Update

It occurred to me that it would look suspicious if all your tests passed, so I've updated it to include some failing tests - complete with Given-When-Thens.

And yes, I know that all the failures have the same message. You really need to fix that logout link!

enter image description here

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Very clever, I get bonus points for ensuring that my code is tested! Cant be too careful \$\endgroup\$ Jun 10, 2014 at 16:53
23
votes
\$\begingroup\$

C# (Windows)

I present to you, the brand new Memtest86 Simulator 2014! (Because running Memtest86 under Windows makes total sense)

Complete with working progress bars and pattern indicator!

This code extensively uses the Console class, which as far as I know, it's only available on Windows. Also, I couldn't find a way to show the real processor name/frequency and available memory, so those are hardcoded.

Screenshot: enter image description here

EDIT

To retrieve the processor information, you can use the Microsoft.Win32 namespace and RegistryKey class.

 // Processor information, add 'using Microsoft.Win32';
string processor = "";
RegistryKey processor_name = Registry.LocalMachine.OpenSubKey(@"Hardware\Description\System\CentralProcessor\0", RegistryKeyPermissionCheck.ReadSubTree);
        if (processor_name != null)
        {
            if (processor_name.GetValue("ProcessorNameString") != null)
            {
                processor = (string)processor_name.GetValue("ProcessorNameString");
            }
        }

Code (ugly, I know):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

class MemTestSim
{
    static void Main(string[] args)
    {
        Random r = new Random();
        int seconds = 0;
        int pass = 0;
        int test = 0;
        int testNumber = 0;

        string[] testNames = { "Address test, own Adress", "Moving inversions, ones & zeros", "Moving inversions, 8 bit pattern" };
        string[] pattern = { "80808080", "7f7f7f7f", "40404040", "bfbfbfbf", "20202020", "dfdfdfdf", "10101010", "efefefef", "08080808", "f7f7f7f7", "8f8f8f8f" };

        // Trick to stop the console from scrolling
        Console.SetWindowSize(80, 40);

        Console.Title = "Memtest86+ v2.11";
        Console.CursorVisible = false;

        // Dark Blue Background Color
        Console.BackgroundColor = ConsoleColor.DarkBlue;
        Console.Clear();

        // Green Title Text
        Console.BackgroundColor = ConsoleColor.DarkGreen;
        Console.ForegroundColor = ConsoleColor.Black;
        Console.Write("      Memtest86+ v2.11     ");

        // Gray on Blue Text and main window structure
        Console.BackgroundColor = ConsoleColor.DarkBlue;
        Console.ForegroundColor = ConsoleColor.Gray;
        Console.Write("| Pass " + pass + "%\n");
        Console.WriteLine("Intel Core i5 2290 MHz     | Test ");
        Console.WriteLine("L1 Cache:  128K   1058MB/s | Test #" + testNumber + "  [" + testNames[0] + "]");
        Console.WriteLine("L2 Cache:  512K   1112MB/s | Testing:  132K - 8192M  8192M");
        Console.WriteLine("L3 Cache: 3072K   1034MB/s | Pattern: ");
        Console.WriteLine("Memory  : 8192M            |---------------------------------------------------");
        Console.WriteLine("Chipset :  Intel i440FX");
        Console.WriteLine();
        Console.WriteLine();
        Console.WriteLine(" WallTime   Cached  RsvdMem   MemMap   Cache  ECC  Test  Pass  Errors  ECC Errs");
        Console.WriteLine(" ---------  ------  -------  --------  -----  ---  ----  ----  ------  --------");
        Console.WriteLine("   0:00:26   8192M      64K  e820-Std    on   off   Std     0       0");

        // Bottom Bar
        Console.SetCursorPosition(0, 24);
        Console.BackgroundColor = ConsoleColor.Gray;
        Console.ForegroundColor = ConsoleColor.DarkBlue;
        Console.WriteLine("(ESC)Reboot  (c)configuration  (SP)scroll_lock  (CR)scroll_unlock               ");


        Console.SetWindowSize(80, 25);

        // Reset text color
        Console.BackgroundColor = ConsoleColor.DarkBlue;
        Console.ForegroundColor = ConsoleColor.Gray;

        // FOREVER
        while (true)
        {
            TimeSpan time = TimeSpan.FromSeconds(seconds);

            // Running Time (WallTime)
            Console.SetCursorPosition(3, 11);
            string min = (time.Minutes < 10 ? "0" + time.Minutes : "" + time.Minutes);
            string sec = (time.Seconds < 10 ? "0" + time.Seconds : "" + time.Seconds);
            Console.Write(time.Hours + ":" + min + ":" + sec);

            // Test percentage
            Console.SetCursorPosition(34, 1);
            Console.Write((int)test + "%");

            // Test Progress Bar
            Console.SetCursorPosition(38, 1);
            for (int i = 0; i < test / 3; i++)
                Console.Write("#");

            Console.SetCursorPosition(38, 0);
            for (int i = 0; i < pass / 3; i++)
                Console.Write("#");

            // Test Number
            Console.SetCursorPosition(35, 2);
            Console.Write(testNumber + "  [" + testNames[testNumber] + "]        ");

            if (testNumber != 0)
            {
                Console.SetCursorPosition(38, 4);
                Console.Write(pattern[test / 10]);
            }
            else
            {
                Console.SetCursorPosition(38, 4);
                Console.Write("         ");
            }

            if (test >= 100)
            {
                test = 0;

                Console.SetCursorPosition(34, 0);
                Console.Write(pass + "%");

                Console.SetCursorPosition(34, 1);
                Console.Write("                                      ");
                testNumber++;
                pass += 2;

                if (testNumber == 2)
                    testNumber = 0;
            }

            Thread.Sleep(1000);
            test += r.Next(0, 3);
            seconds++;
        }
    }
}
\$\endgroup\$
6
  • 7
    \$\begingroup\$ Why not just run Memtest86? "I think I have some hardware problems here, I guess I'll just have to goof off until it's done" \$\endgroup\$
    – MadTux
    Jun 10, 2014 at 16:00
  • 20
    \$\begingroup\$ @MadTux 'Cos you've gotta boot into Memtest, which means no cat pictures. \$\endgroup\$
    – Schilcote
    Jun 10, 2014 at 21:45
  • 1
    \$\begingroup\$ System.Console Works on Mono, I think you just have to tune the code for arbitrary console window size \$\endgroup\$ Jun 10, 2014 at 23:33
  • 8
    \$\begingroup\$ Couldn't you run Memtest86 in a VM? \$\endgroup\$
    – Cole Tobin
    Jun 12, 2014 at 0:21
  • 3
    \$\begingroup\$ I LOVE the Memtest in a VM idea. \$\endgroup\$
    – John
    Jun 13, 2014 at 23:25
22
votes
\$\begingroup\$

Python, 36 characters

print("Opening Internet Explorer...")

Python, 21 characters

print("Opening IE...")

Trying to be funny. :P

\$\endgroup\$
2
14
votes
\$\begingroup\$

AHK

You pretend to type while the script generates a bunch of accessors and mutators in JavaScript. Make sure an IDE (I tested this on Notepad++) is the active window.

Specify the list of variables and class name if you want. I just used what was already in window.location.

Press esc to exit.

Press 0 on your numberpad to pause when someone tries to talk to you.

Press ctrl+w (w stands for work) to start

^w::
    loop{
        variable_names  :=  "hash|host|hostname|href|origin|pathname|port|protocol|search"
        class_name  :=  "location"

        StringSplit, variable_names_array, variable_names, "|"

        loop, %variable_names_array0%{
            Random, delay, 80, 120
            SetKeyDelay, %delay%
            current :=  variable_names_array%a_index%
            Send, %class_name%.prototype.
            Random, r, 800, 1300
            Sleep, %r%
            Send, get_
            Random, r, 800, 1300
            Sleep, %r%
            Send, %current%
            Random, r, 800, 1300
            Sleep, %r%
            Send, {space}={space}
            Random, r, 800, 1300
            Sleep, %r%
            Send, function(){{}{enter}
            Random, r, 800, 1300
            Sleep, %r%
            Send, {tab}
            Random, r, 800, 1300
            Sleep, %r%
            Send, return this.
            Random, r, 800, 1300
            Sleep, %r%
            Send, %current%;{enter}
            Random, r, 800, 1300
            Sleep, %r%
            Send, {BackSpace}{}}
            Random, r, 800, 1300
            Sleep, %r%
            Send, {enter}{enter}
            Random, r, 800, 1300
            Sleep, %r%

            Send, %class_name%.prototype.
            Random, r, 800, 1300
            Sleep, %r%
            Send, set_
            Random, r, 800, 1300
            Sleep, %r%
            Send, %current%
            Random, r, 800, 1300
            Sleep, %r%
            Send, {space}={space}
            Random, r, 800, 1300
            Sleep, %r%
            Send, function(%current%){{}{enter}
            Random, r, 800, 1300
            Sleep, %r%
            Send, {tab}
            Random, r, 800, 1300
            Sleep, %r%
            Send, this.
            Random, r, 800, 1300
            Sleep, %r%
            Send, %current% ={space}
            Random, r, 800, 1300
            Sleep, %r%
            Send, %current%;{enter}
            Random, r, 800, 1300
            Sleep, %r%
            Send, return this;{enter}
            Random, r, 800, 1300
            Sleep, %r%
            Send, {BackSpace}{}}
            Random, r, 800, 1300
            Sleep, %r%
            Send, {enter}{enter}
            Random, r, 800, 1300
            Sleep, %r%
        }
    }
return

esc::
    ExitApp
    return

numpad0::
    Pause, toggle
    return
\$\endgroup\$
14
votes
\$\begingroup\$

Bash

Dumps a random block of physical memory and looks at the contents. Going to need to be root for this. Only the first 1MB of memory is available by default. dd default block size is 512 bytes, that can be changed with option ibs=bytes but keep in mind the other option skip=$offset which picks a block at random. Output from dd is sent through tr to remove non ASCII characters; only unique results 2 characters or longer are evaluated.

Each string found is compared to a dictionary. If no matches are found, it attempts to decode as base64. Finally, all the strings evaluated are returned.

There are several other platform dependent options to be aware of, such as location of dictionary file (/usr/share/dict/words), whether sleep accepts floating point inputs, and if base64 is available.

Also, be aware that dd outputs stats on the operation performed to stderr, which is piped to /dev/null. If something were to go horribly wrong (you are accessing /dev/mem ...) the stderr output won't be visible.

Overall, not very useful, but I learned a bit about linux memory and writing this script turned out to be fun.

#!/bin/bash

offset=`expr $RANDOM % 512`
mem=`dd if=/dev/mem skip=$offset count=1 2>/dev/null| tr '[\000-\040]' '\n' | tr '[\177-\377'] '\n' | sort -u | grep '.\{2,\}'`

results=""

for line in $mem
do
    echo "Evaluating $line"
    greps=`grep "^$line" /usr/share/dict/words | head`

    if [ -n "$greps" ]
    then
        echo "Found matches."
        echo $greps
    else
        #echo "No matches in dictionary. Attempting to decode."
        decode=`echo "$line" | base64 -d 2>/dev/null`
        if [ $? -ne 1 ]
        then
            echo "Decode is good: $decode"
        #else
            #echo "Not a valid base64 encoded string."
        fi
    fi

    results+=" $line"

    # make it look like this takes a while to process
    sleep 0.5

done 

if (( ${#results} > 1 ))
then
    echo "Done processing input at block $offset: $results"
fi

Sometimes there's no interesting output (all zeroes). Sometimes there are only a few strings:

codegolf/work# ./s 
Evaluating @~
Evaluating 0~
Evaluating ne
Found matches.
ne nea neal neallotype neanic neanthropic neap neaped nearable nearabout
Done processing input at block 319:  @~ 0~ ne

Sometimes there is actually something human readable in memory (before I was logging block offset):

codegolf/work# ./s 
Evaluating grub_memset
Evaluating grub_millisleep
Evaluating grub_mm_base
Evaluating grub_modbase
Evaluating grub_named_list_find
Evaluating grub_net_open
Evaluating grub_net_poll_cards_idle
Evaluating grub_parser_cmdline_state
Evaluating grub_parser_split_cmdline
Evaluating grub_partition_get_name
Evaluating grub_partition_iterate
Evaluating grub_partition_map_list
Evaluating grub_partition_probe
Evaluating grub_pc_net_config
Evaluating grub_pit_wait
Evaluating grub_print_error
Evaluating grub_printf
Evaluating grub_printf_
Evaluating grub_puts_
Evaluating grub_pxe_call
Evaluating grub_real_dprintf
Evaluating grub_realidt
Evaluating grub_realloc
Evaluating grub_refresh
Evaluating grub_register_command_prio
Evaluating grub_register_variable_hook
Evaluating grub_snprintf
Evaluating grub_st
Evaluating grub_strchr
Evaluating _memmove
Done processing input:  grub_memset grub_millisleep grub_mm_base 
    grub_modbase grub_named_list_find grub_net_open grub_net_poll_cards_idle
    grub_parser_cmdline_state grub_parser_split_cmdline 
    grub_partition_get_name grub_partition_iterate grub_partition_map_list 
    grub_partition_probe grub_pc_net_config grub_pit_wait grub_print_error 
    grub_printf grub_printf_ grub_puts_ grub_pxe_call grub_real_dprintf 
    grub_realidt grub_realloc grub_refresh grub_register_command_prio 
    grub_register_variable_hook grub_snprintf grub_st grub_strchr _memmove

And one last sample run showing malformed grep input, dictionary hits, and a successful base64 decode (before logging block offset again):

codegolf/work# ./s 
Evaluating <!
Evaluating !(
Evaluating @)
Evaluating @@
Evaluating $;
Evaluating '0@
Evaluating `1
Evaluating 1P$#4
Evaluating )$2
Evaluating -3
Evaluating 3HA
Evaluating 3N
Evaluating @@9
Evaluating 9@
Evaluating 9Jh
Evaluating \9UK
grep: Invalid back reference
Evaluating a#
Evaluating CX
Evaluating ?F
Evaluating !H(
Evaluating +%I
Evaluating Io
Found matches.
Io Iodamoeba Ione Ioni Ionian Ionic Ionicism Ionicization Ionicize Ionidium
Evaluating Kj
Found matches.
Kjeldahl
Evaluating l#
Evaluating L6qh
Decode is good: /��
Evaluating O%
Evaluating OX
Evaluating PR
Evaluating .Q
Evaluating Q4!
Evaluating qQ
Evaluating )u
Evaluating Ua
Found matches.
Uaraycu Uarekena Uaupe
Evaluating $v
Evaluating )V
Evaluating V8
Evaluating V,B~
Evaluating wIH
Evaluating xU
Evaluating y@
Evaluating @z
Evaluating Z0
Evaluating zI
Evaluating Z@!QK
Done processing input:  <! !( @) @@ $; '0@ `1 1P$#4 )$2 -3 3HA 3N
    @@9 9@ 9Jh \9UK a# CX ?F !H( +%I Io Kj l# L6qh O% OX PR .Q Q4!
    qQ )u Ua $v )V V8 V,B~ wIH xU y@ @z Z0 zI Z@!QK
\$\endgroup\$
4
  • \$\begingroup\$ How do you run this? I dumped it into script.sh, did a chmod +x on it, but it just exits. sudo doesn't help, either. \$\endgroup\$ Jun 8, 2014 at 16:03
  • \$\begingroup\$ Sounds like the mem= line isn't returning anything. You'll have to check and make sure that each part of the command between pipes is actually returning something. \$\endgroup\$
    – user21677
    Jun 8, 2014 at 17:14
  • \$\begingroup\$ Okay, I'll do that. \$\endgroup\$ Jun 9, 2014 at 1:49
  • \$\begingroup\$ This only ran for like 5 seconds the first time and printed like 12 lines, then like 0.1 seconds every subsequent time with no output. \$\endgroup\$
    – Mike
    Aug 13, 2015 at 23:54
13
votes
\$\begingroup\$

Windows Batch

@echo off

set /p hax="How much haxx0rz: " %=%
set /p haxx="How quick haxx0rz (seconds): " %=%

FOR /L %%I IN (1, 1, %hax%) DO (
START cmd /k "COLOR A&&tree C:\"
timeout %haxx%
)

This is a joke script that I've kept with me for years to make it look like something out of a 90's hacker movie. I usually use it while remotely connected to a computer to freak people out.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ He's downloading a virus onto the whole system! \$\endgroup\$
    – qwr
    Jun 14, 2014 at 1:16
12
votes
\$\begingroup\$

Bash

The never ending search for cafes.

I found this on the web a long time ago:

cat /dev/urandom | hexdump | grep "ca fe"
\$\endgroup\$
5
  • \$\begingroup\$ Try using urandom instead. \$\endgroup\$
    – Alice Ryhl
    Jun 11, 2014 at 9:48
  • \$\begingroup\$ Ah... I tested it on a Mac, and Macs have both random and urandom. \$\endgroup\$
    – daviewales
    Jun 11, 2014 at 13:52
  • 5
    \$\begingroup\$ /dev/random exists, but it's intended to be more secure than /dev/urandom by only generating numbers if there's available entropy. Once you run out, it stops. /dev/urandom doesn't do that, and won't ever just stop outputting. \$\endgroup\$ Jun 12, 2014 at 4:20
  • \$\begingroup\$ Why is it never ending? I feel stupid, the second time today. \$\endgroup\$
    – Daniel W.
    Jun 17, 2014 at 13:57
  • 1
    \$\begingroup\$ /dev/urandom is a 'file' which continuously feeds random numbers to cat. cat then pipes these to hexdump, etc. \$\endgroup\$
    – daviewales
    Jun 17, 2014 at 16:57
11
votes
\$\begingroup\$

Python 2.7

The Endless Test Suite

"Runs" a set of "Unit Tests" on all the files in your directory tree. Traverses all subdirectories. Starts over when it gets to the end.

Prints a running status:

============================= entering . =============================
------------------------ test_line_numbers.py ------------------------
Ran 18 tests in 3.23707662572 seconds, 0 errors
---------------------------- test_main.c ----------------------------
Ran 26 tests in 1.3365194929 seconds, 0 errors
--------------------------- test_parser.c ---------------------------
Ran 8 tests in 1.61633904378 seconds, 0 errors
--------------------------- test_README.c ---------------------------
Ran 12 tests in 2.27466813182 seconds, 0 errors
4 modules OK (0 failed)
=========================== entering ./lib ===========================

...

Features that make it more complex than needed, and hopefully more realistic:

  • The number of tests and test time is proportional to the file size.
  • Turns non source code file extensions into known ones. Modify CodeExtensions to add more known types.
    • Selects new extension based on frequency of actual language files seen, so you won't be seen testing Python code if your hard drive is full of Ruby.
  • Skips files with leading . No giveaways like "test_.bashrc.js"
import os,random,time,collections

CodeExtensions = ('.py', '.c','.cpp','.rb','.js','.pl','.cs','.el')
last_exts = collections.deque(CodeExtensions[:1],100)
maxlen=0

def maketestname(filename):
    root,ext = os.path.splitext(filename)
    if ext in CodeExtensions:
        last_exts.append(ext)
    else:
        ext = random.choice(last_exts)
    return 'test_'+root+ext

def banner(char,text,width=70):
    bar = char*((width-len(text)-2)/2)
    return "{} {} {}".format(bar,text,bar)

def scaledrand(scale,offset):
    return random.random()*scale+random.randrange(offset)

while True:
    for dirname, subdirs, files in os.walk('.'):
        print banner('=',"entering {}".format(dirname))
        skipped = 0
        for filename in files:
            if filename[0] is not '.':
                testfilename = maketestname(filename)
                print banner('-',testfilename)
                filelen = os.path.getsize(os.path.join(dirname,filename))
                maxlen = max(maxlen,filelen)
                ntests = int(scaledrand(20*filelen/maxlen,10))
            testtime = scaledrand(ntests/5.0,2)
            time.sleep(testtime)                
            else:
                skipped+=1
                continue

            print "Ran {} tests in {} seconds, {} errors".format(ntests,testtime,0)
        print "{} modules OK ({} failed)\n".format(len(files)-skipped,0)
\$\endgroup\$
4
  • 1
    \$\begingroup\$ You could also just run the Python regression tests, which are bundled with most Python installs. \$\endgroup\$
    – nneonneo
    Jun 11, 2014 at 19:42
  • \$\begingroup\$ But those finish eventually. \$\endgroup\$
    – AShelly
    Jun 11, 2014 at 20:10
  • 2
    \$\begingroup\$ then you could run them...in a loop! \$\endgroup\$
    – nneonneo
    Jun 12, 2014 at 0:17
  • 1
    \$\begingroup\$ I'm also thinking it's less suspicious to test files with names related to your projects than to test the Python source. I'm guessing most of us don't professionally maintain Python... \$\endgroup\$
    – AShelly
    Jun 12, 2014 at 14:22
11
votes
\$\begingroup\$

Java + Guava 16 (Guava isn't super necessary, but it made some things a little less annoying to write).

Alright, you're supposed to be working? How about a program that actually writes real Java code, that actually compiles (though it doesn't do much).

It's difficult to demonstrate the animation, but this program writes a Java program using either the default dictionary (250 common English words) or a newline delimited file (taken as a command line argument), and types it to the console one character at a time at human seeming speeds. Make sure to run it yourself because this post doesn't do it justice. When it finishes, it waits 1 minute, then prints a lot of blank lines to the console, and starts over again. I tried to write it to make various parameters reasonably tweakable.

Also, normally I would put this into more than one file, but to make it easier to run I smushed all the classes together.

package org.stackoverflow.ppcg;

import java.io.*;
import java.util.*;

import com.google.common.base.CaseFormat;
import com.google.common.base.Converter;
import com.google.common.collect.Lists;

public class CodeGenerator {
    public static final Converter<String, String> TOUPPER =
            CaseFormat.LOWER_CAMEL.converterTo(CaseFormat.UPPER_CAMEL);
    public static final Converter<String, String> TOLOWER =
            CaseFormat.UPPER_CAMEL.converterTo(CaseFormat.LOWER_CAMEL);
    
    public static final String[] TYPES = new String[]{
        "int", "long", "double", "String"
    };
    
    public static final List<String> DEFAULT_LIST = Arrays.asList(new String[]{
            "the", "and", "for", "you", "say", "but", "his", "not", "she", "can",
            "who", "get", "her", "all", "one", "out", "see", "him", "now", "how",
            "its", "our", "two", "way", "new", "day", "use", "man", "one", "her",
            "any", "may", "try", "ask", "too", "own", "out", "put", "old", "why",
            "let", "big", "few", "run", "off", "all", "lot", "eye", "job", "far",
            "have", "that", "with", "this", "they", "from", "that", "what", "make", "know",
            "will", "time", "year", "when", "them", "some", "take", "into", "just", "your",
            "come", "than", "like", "then", "more", "want", "look", "also", "more", "find",
            "here", "give", "many", "well", "only", "tell", "very", "even", "back", "good",
            "life", "work", "down", "call", "over", "last", "need", "feel", "when", "high",
            "their", "would", "about", "there", "think", "which", "could", "other", "these", "first",
            "thing", "those", "woman", "child", "there", "after", "world", "still", "three", "state",
            "never", "leave", "while", "great", "group", "begin", "where", "every", "start", "might",
            "about", "place", "again", "where", "right", "small", "night", "point", "today", "bring",
            "large", "under", "water", "write", "money", "story", "young", "month", "right", "study",
            "people", "should", "school", "become", "really", "family", "system", "during", "number", "always",
            "happen", "before", "mother", "though", "little", "around", "friend", "father", "member", "almost",
            "change", "minute", "social", "follow", "around", "parent", "create", "others", "office", "health",
            "person", "within", "result", "change", "reason", "before", "moment", "enough", "across", "second",
            "toward", "policy", "appear", "market", "expect", "nation", "course", "behind", "remain", "effect",
            "because", "through", "between", "another", "student", "country", "problem", "against", "company", "program",
            "believe", "without", "million", "provide", "service", "however", "include", "several", "nothing", "whether",
            "already", "history", "morning", "himself", "teacher", "process", "college", "someone", "suggest", "control",
            "perhaps", "require", "finally", "explain", "develop", "federal", "receive", "society", "because", "special",
            "support", "project", "produce", "picture", "product", "patient", "certain", "support", "century", "culture"
    });
    
    private static final int CLASS_NAME_LENGTH = 2;
    
    private final WordList wordList;
    private final Appendable out;
    private final Random r = new Random();
    
    private CodeGenerator(WordList wordList, Appendable out) {
        this.wordList = wordList;
        this.out = out;
    }

    public static void main(String... args) throws Exception {
        List<?> wordSource = getWords(args);
        WordList list = new WordList(wordSource);
        SleepingAppendable out = new SleepingAppendable(System.out);
        CodeGenerator generator = new CodeGenerator(list, out);
        while(!Thread.interrupted()) {
            generator.generate();
            try {
                Thread.sleep(60000);
            } catch (InterruptedException e) {
                break;
            }
            out.setSleeping(false);
            for(int i = 0; i < 100; i++) {
                out.append(System.lineSeparator());
            }
            out.setSleeping(true);
        }
    }

    private static List<?> getWords(String[] args) {
        if(args.length > 0) {
            try {
                return getListFromFile(args[0]);
            } catch(IOException e) { }
        }
        return DEFAULT_LIST;
    }

    private static List<Object> getListFromFile(String string) throws IOException {
        List<Object> newList = Lists.newArrayList();
        
        File f = new File(string);
        Scanner s = new Scanner(f);
        
        while(s.hasNext()) {
            newList.add(s.nextLine());
        }
        
        return newList;
    }

    private void generate() throws IOException {
        String className = beginClass();
        List<Field> finalFields = generateFields(true);
        printFields(finalFields);
        out.append(System.lineSeparator());
        List<Field> mutableFields = generateFields(false);
        printFields(mutableFields);
        out.append(System.lineSeparator());
        printConstructor(className, finalFields);
        printGetters(finalFields);
        printGetters(mutableFields);
        printSetters(mutableFields);
        endClass();
    }

    private void printGetters(List<Field> fields) throws IOException {
        for(Field f : fields) {
            out.append(System.lineSeparator());
            f.printGetter(out);
        }
    }
    
    private void printSetters(List<Field> fields) throws IOException {
        for(Field f : fields) {
            out.append(System.lineSeparator());
            f.printSetter(out);
        }
    }

    private void printConstructor(String className, List<Field> finalFields) throws IOException {
        out.append("\tpublic ").append(className).append('(');
        printArgs(finalFields);
        out.append(") {").append(System.lineSeparator());
        for(Field f : finalFields) {
            f.printAssignment(out);
        }
        out.append("\t}").append(System.lineSeparator());
    }

    private void printArgs(List<Field> finalFields) throws IOException {
        if(finalFields.size() == 0) return;
        
        Iterator<Field> iter = finalFields.iterator();
        
        while(true) {
            Field next = iter.next();
            next.printTypeAndName(out);
            if(!iter.hasNext()) break;
            out.append(", ");
        }
    }

    private List<Field> generateFields(boolean isfinal) {
        int numFields = r.nextInt(3) + 2;
        List<Field> newFields = Lists.newArrayListWithCapacity(numFields);
        for(int i = 0; i < numFields; i++) {
            String type = TYPES[r.nextInt(4)];
            newFields.add(new Field(type, wordList.makeLower(r.nextInt(2) + 1), isfinal));
        }
        return newFields;
    }
    
    private void printFields(List<Field> finalFields) throws IOException {
        for(Field f : finalFields) {
            f.printFieldDeclaration(out);
        }
    }

    private String beginClass() throws IOException {
        out.append("public class ");
        String className = wordList.nextClassName(CLASS_NAME_LENGTH);
        out.append(className).append(" {").append(System.lineSeparator());
        
        return className;
    }
    
    private void endClass() throws IOException {
        out.append("}");
    }
    
    private static class WordList {
        private final Random r = new Random();

        private final List<?> source;
        
        private WordList(List<?> source) {
            this.source = source;
        }
        
        private String makeUpper(int length) {
            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < length; i++) {
                sb.append(randomWord());
            }
            return sb.toString();
        }
        
        private String makeLower(int length) {
            return TOLOWER.convert(makeUpper(length));
        }
        
        private String randomWord() {
            int sourceIndex = r.nextInt(source.size());
            return TOUPPER.convert(source.get(sourceIndex).toString().toLowerCase());
        }
        
        public String nextClassName(int length) {
            return makeUpper(length);
        }
    }
    
    private static class Field {
        private final String type;
        private final String fieldName;
        private final boolean isfinal;
        
        Field(String type, String fieldName, boolean isfinal) {
            this.type = type;
            this.fieldName = fieldName;
            this.isfinal = isfinal;
        }
        
        void printFieldDeclaration(Appendable appendable) throws IOException {
            appendable.append("\tprivate ");
            if(isfinal) appendable.append("final ");
            printTypeAndName(appendable);
            appendable.append(';').append(System.lineSeparator());
        }

        void printTypeAndName(Appendable appendable) throws IOException {
            appendable.append(type).append(' ').append(fieldName);
        }
        
        void printGetter(Appendable appendable) throws IOException {
            appendable.append("\tpublic ");
            appendable.append(type).append(" get").append(TOUPPER.convert(fieldName));
            appendable.append("() {").append(System.lineSeparator());
            appendable.append("\t\treturn ").append(fieldName).append(';');
            appendable.append(System.lineSeparator()).append("\t}").append(System.lineSeparator());
        }
        
        void printSetter(Appendable appendable) throws IOException {
            appendable.append("\tpublic void set");
            appendable.append(TOUPPER.convert(fieldName));
            appendable.append("(").append(type).append(' ').append(fieldName);
            appendable.append(") {").append(System.lineSeparator());
            printAssignment(appendable);
            appendable.append("\t}").append(System.lineSeparator());            
        }
        
        void printAssignment(Appendable appendable) throws IOException {
            appendable.append("\t\tthis.").append(fieldName).append(" = ").append(fieldName);
            appendable.append(';').append(System.lineSeparator());
        }
    }
    
    private static class SleepingAppendable implements Appendable {
        private Random r = new Random();
        private Appendable backing;
        
        private boolean sleeping = true;
        
        public SleepingAppendable(Appendable backing) {
            this.backing = backing;
        }
        
        @Override
        public Appendable append(CharSequence csq) throws IOException {
            return append(csq, 0, csq.length());
        }

        @Override
        public Appendable append(CharSequence csq, int start, int end)
                throws IOException {
            for(int i = start; i < end; i++) {
                append(csq.charAt(i));
            }
            
            sleep(100, 300);
            
            return this;
        }

        @Override
        public Appendable append(char c) throws IOException {
            sleep(170, 80);
            
            backing.append(c);
            
            return this;
        }

        
        private void sleep(int base, int variation) {
            if(!sleeping) return;
            try {
                Thread.sleep((long) (r.nextInt(80) + 70));
            } catch (InterruptedException e) {
            }
        }

        public boolean isSleeping() {
            return sleeping;
        }

        public void setSleeping(boolean sleeping) {
            this.sleeping = sleeping;
        }
    }
}

Sample program output (just one program)

public class GetGroup {
    private final double thoughRight;
    private final double socialYear;
    private final double manOne;
    private final int appear;

    private double man;
    private double comeHis;
    private double certain;

    public GetGroup(double thoughRight, double socialYear, double manOne, int appear) {
        this.thoughRight = thoughRight;
        this.socialYear = socialYear;
        this.manOne = manOne;
        this.appear = appear;
    }

    public double getThoughRight() {
        return thoughRight;
    }

    public double getSocialYear() {
        return socialYear;
    }

    public double getManOne() {
        return manOne;
    }

    public int getAppear() {
        return appear;
    }

    public double getMan() {
        return man;
    }

    public double getComeHis() {
        return comeHis;
    }

    public double getCertain() {
        return certain;
    }

    public void setMan(double man) {
        this.man = man;
    }

    public void setComeHis(double comeHis) {
        this.comeHis = comeHis;
    }

    public void setCertain(double certain) {
        this.certain = certain;
    }
}

Another sample output:

public class TryControl {
    private final int over;
    private final double thatState;
    private final long jobInto;
    private final long canPut;

    private int policy;
    private int neverWhile;

    public TryControl(int over, double thatState, long jobInto, long canPut) {
        this.over = over;
        this.thatState = thatState;
        this.jobInto = jobInto;
        this.canPut = canPut;
    }

    public int getOver() {
        return over;
    }

    public double getThatState() {
        return thatState;
    }

    public long getJobInto() {
        return jobInto;
    }

    public long getCanPut() {
        return canPut;
    }

    public int getPolicy() {
        return policy;
    }

    public int getNeverWhile() {
        return neverWhile;
    }

    public void setPolicy(int policy) {
        this.policy = policy;
    }

    public void setNeverWhile(int neverWhile) {
        this.neverWhile = neverWhile;
    }
}
\$\endgroup\$
1
  • 9
    \$\begingroup\$ You've made a fully-automatic money printing machine for anyone still paid by lines-of-code - great job! \$\endgroup\$
    – Philipp
    Jun 14, 2014 at 21:03
9
votes
\$\begingroup\$

bash

Output some comments from random source files at random intervals, followed by a randomly generated do-nothing progress bar.

#!/bin/bash

# The directory to extract source comments from
srcdir=~/src/php-src/

# Generate a status bar that lasts a random amount of time.
# The actual amount of time is somewhere between 1.5 and 30
# seconds... I think. I fudged this around so much it's hard to tell.
function randstatus() {
    bsize=4096
    r_rate=$(echo "$RANDOM/32767 * $bsize * 1.5 + $bsize / 4" | bc -l | sed 's/\..*$//')
    r_min=3
    r_max=15
    r_val=$(($r_min + $RANDOM % $(($r_max - $r_min)) ))
    i=0
    dd if=/dev/urandom bs=$bsize count=$r_val 2> /dev/null | pv -L $bsize -s $(($r_val * bsize)) > /dev/null
}

# Picks a random .c file from the given directory, parses
# out one-line comments, and outputs them one by one with a
# random delay between each line.
function randout() {
    r_file=$(find $1 -name '*.c' | sort -R | head -n 1)
    echo "# $r_file"
    grep '^\s*/\*.*\*/\s*$' $r_file | sed 's:[/\*]::g' | sed -e 's:^\s\+::' -e 's:\s\+$::' | sed -e 's:^\W\+::' | grep -v '^$' | while read line; do
        echo $line
        sleep $(printf "%0.2f" $(echo "$((($RANDOM%4)+1))/4" | bc -l))
    done
}

while true; do
    randout $srcdir
    randstatus
    # sleep here to make it easier to break out of the 'while read' loop
    sleep 2
done

Output:

# /home/jerkface/src/php-src/sapi/fpm/fpm/fpm_shm.c
Id: fpm_shm.c,v 1.3 20080524 17:38:47 anight Exp $
c) 2007,2008 Andrei Nigmatulin, Jerome Loyet
MAP_ANON is deprecated, but not in macosx
  32kB 0:00:08 [3.97kB/s] [====================================================================>] 100%
# /home/jerkface/src/php-src/ext/mbstring/mb_gpc.c
Id$
includes
mbfl_no_encoding _php_mb_encoding_handler_ex()
split and decode the query
initialize converter
auto detect
convert encoding
we need val to be emalloc()ed
add variable to symbol table
SAPI_POST_HANDLER_FUNC(php_mb_post_handler)
  12kB 0:00:03 [4.02kB/s] [===============>                                                      ] 24% ETA 0:00:09
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Clever! It's a little late to receive more attention, but take a high five from me. \$\endgroup\$ Jun 20, 2014 at 23:05
  • \$\begingroup\$ @SomeKittens The real genius of this script is that working on it looks even more like real work. ;D \$\endgroup\$
    – Sammitch
    Jun 20, 2014 at 23:20
7
votes
\$\begingroup\$

Rsync form BASH

 rsync -n -avrIc --verbose  ~ ~ | sed s/"(DRY RUN)"/""/g    
# Note the space at the beginning of the above line,

rsync - a fast, versatile, remote (and local) file-copying tool... that with -n performs a dry run, only try to do, do not really do, and shows what happens.
In this case try to check if to update all file of your home directory (and sub-folders).
If you have the root access of course you can run it on a bigger part of your filesystem.

Notes:

  1. If HISTCONTROL=ignoreboth or at least HISTCONTROL=ignorespace in your bash session your bash history will not remember that command if you write it with a space before. (You cannot push up and see it on the screen, neither in the history log).
  2. | sed s/"(DRY RUN)"/""/g will pipe the output through sed that will erase the (DRY RUN) text at the end of the rsync output. If an expert check you can say you really doing that, not only testing.
  3. -avrIc you can change those options, check on man rsync, but never remove the -n, else you should have serious problem, even more if you run as root... 8-O!
\$\endgroup\$
6
votes
\$\begingroup\$

Maven under bash

Maven is just perfect for this kind of task ;-)

while true;
do mvn -X archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false;
done
\$\endgroup\$
6
votes
\$\begingroup\$

Cobra

This opens a console window that loops through various fake objects and assorted things, incrementing in passes and progress for each pass. It waits for a small random time each increment, to simulate actual computation delays.

class Does_Nothing_Useful
    var _rng as Random = Random()
    var _hash
    var _pass
    var _names as String[] = @['Vector', 'Object', 'File', 'Index', 'Report', 'Library', 'Entry', 'Log', 'Resource', 'Directory']
    def main
        while true
            .refresh
            name as String = _names[_rng.next(_names.length)] + ' ' + _hash.toString
            for i in _pass
                progress as decimal = 0
                while progress < 100000
                    progress += _rng.next(1000)
                    print name + '; pass', i, ' : ', progress/1000
                    wait as int = 0
                    for n in _rng.next(50), wait += _rng.next(1,100)
                    System.Threading.Thread.sleep(wait)
                print name + '; pass', i, '--FINISHED--'
                print ''
                System.Threading.Thread.sleep(_rng.next(1000,17500))
            print name, '--EVAL COMPLETE--'
            print ''
            System.Threading.Thread.sleep(_rng.next(12500,30000))
    def refresh
        _hash = _rng.next.getHashCode
        _pass = _rng.next(256)
        print '--LOADING NEXT TARGET--'
        print ''
        System.Threading.Thread.sleep(_rng.next(12500,30000))
\$\endgroup\$
4
  • 1
    \$\begingroup\$ You've got the whole weekend to work on this, so take your time. \$\endgroup\$ Jun 7, 2014 at 6:14
  • 1
    \$\begingroup\$ What is this Cobra language, it looks like the bastard child of Python and C#, haha (looking it up it does seem to have some interesting features though), +1 \$\endgroup\$
    – Thomas
    Jun 7, 2014 at 12:37
  • 1
    \$\begingroup\$ @Thomas For the most part, it's C# (currently without LINQ) using Python-esque syntax. And one of the most helpful default compilers I've ever had the pleasure of working with. \$\endgroup\$
    – Οurous
    Jun 8, 2014 at 0:51
  • \$\begingroup\$ So did you ever end up completing this code? \$\endgroup\$
    – rayryeng
    Sep 26, 2015 at 16:46
4
votes
\$\begingroup\$

I wrote a stupid python script to do this once. Called "ProgramAboutNothing"... I'm not sure it's that convincing but it only took me about 10 minutes. It just outputs random sentences describing what it is supposedly doing... I could probably have chosen better words for it that might look more convincing but I never actually used it properly. I guess if someone wants to use it they can edit it and add their own words in the lists... Fans of Sim City might notice something familiar, though. :P

from random import randrange
from time import sleep

nouns = ["bridge", "interface", "artifact", "spline"]
verbs = ["building", "articulating", "reticulating", "compiling", "analyzing"]
adjectives = ["mix", "abstract", "essential"]

while True:
    one = randrange(0,5)
    two = randrange(0,4)
    print "%s %s" % (verbs[one], nouns[two]),
    sleep(randrange(0,500)/100)
    print ".",
    sleep(randrange(0,500)/100)
    print ".",
    sleep(randrange(0,500)/100)
    print ".\n",
    loop = randrange(0,50)
    one = randrange(0,5)
    for i in range(loop):
        two = randrange(0,4)
        three = randrange(0,3)
        print "%s %s %s" % (verbs[one], nouns[two], adjectives[three]),
        sleep(randrange(0,250)/100)
        print ".",
        sleep(randrange(0,250)/100)
        print ".",
        sleep(randrange(0,250)/100)
        print ".\n",
\$\endgroup\$
12
  • 1
    \$\begingroup\$ Maybe you're using Python 3? Try adding parentheses around the print statements like this: print( ... ). \$\endgroup\$
    – daviewales
    Jun 11, 2014 at 13:55
  • 1
    \$\begingroup\$ @daviewales ninja'd :P \$\endgroup\$
    – Luke
    Jun 11, 2014 at 13:56
  • 1
    \$\begingroup\$ @Luke I've just installed Python 3.4.1 for Windows. I can't program in Python, but i'm interested in your little program... \$\endgroup\$
    – Mathlight
    Jun 11, 2014 at 13:56
  • 1
    \$\begingroup\$ @Mathlight prepare to be underwhelmed. :P \$\endgroup\$
    – Luke
    Jun 11, 2014 at 13:57
  • 1
    \$\begingroup\$ @luke, It's working now. And i'm impressed ^_^ \$\endgroup\$
    – Mathlight
    Jun 11, 2014 at 13:58
4
votes
\$\begingroup\$

How about this one? It will download the codegolf HTML data every 1 second. So, the data will keep on changing as long as the newer questions come in. At the same time, it will also appear as if you are downloading some critical data from a website.

while true; do     
sleep 1;     
curl "codegolf.stackexchange.com" -s |  w3m -dump -T text/html; 
done
\$\endgroup\$
3
votes
\$\begingroup\$

Bash

The recursive directory list:

ll -R /
\$\endgroup\$
2
votes
\$\begingroup\$

This is a C++ Compiler Simulation (written in C#):

using System;
using System.Collections.Generic;
using System.Management;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Reflection;

class FakeCompiler {
    static void DoPrint(string txt) {
        Console.WriteLine("Compiling " + txt);
        Thread.Sleep(1000);
    }
    static string Extract(string TypeName) {
        string rt = TypeName.Split(new Char[] {'.'})[ TypeName.Split(new Char[] {'.'}).Length - 1 ];
        if (rt.Contains("+")) {
            rt = rt.Split(new char[] { '+' })[1];
        }
        if (rt.Contains("[")) {
            rt = rt.Split(new char[] { '[' })[0];
        }
        return rt;
    }
    static void DoCompileSingleFile(string _Type_Name) {
        string print = Extract(_Type_Name);
        DoPrint(print + ".h");
        DoPrint(print + ".cpp");
    }
    static Type[] DoFakeCompile_Assembly(string _AssemblyFileName) {
        System.Reflection.Assembly _asm = System.Reflection.Assembly.Load(_AssemblyFileName);
        Type[] _ts = _asm.GetTypes();
        for (int h = 0; h < 15; ++h) {
            DoCompileSingleFile(_ts[h].ToString());
        }
        return _ts;
    }
    static void DoFakeLinkErrors(Type[] t) {
        Console.WriteLine("linking..");
        Thread.Sleep(2000);
        MethodInfo[] mi;
        for (int i = 0; i < t.Length; ++i) {
            mi = t[i].GetMethods();
            for (int j = 0; j < mi.Length; ++j) {
                Console.WriteLine("Link Error: The object {@!" + mi[j].ToString().Split(new char[] {' '})[0] + "#$? is already defined in " + Extract(t[i].ToString()) + ".obj");
                Thread.Sleep(200);
            }
        }
    }
    static void Main(string[] args) {
        Console.WriteLine("Fictional C/C++ Optimizing Command-line Compiler Version 103.33.0");
        DoFakeLinkErrors(DoFakeCompile_Assembly("mscorlib.dll"));
    }
}
\$\endgroup\$
2
votes
\$\begingroup\$

xdotool and an IDE (for example eclipse)

For X11 users.

Use this script and make sure you just Alt+tab'ed from Eclipse. You need a java file. For example here: https://raw.githubusercontent.com/Valay/Longest-Word-Made-of-other-Words/master/LongestWord.java

#!/bin/sh

xdotool key alt+Tab
xdotool sleep 0.2
xdotool type --delay 300 "$(cat LongestWord.java)"
xdotool key alt+Tab
\$\endgroup\$
2
votes
\$\begingroup\$

Batch

Place in a folder with a lot of files. If it scrolls by fast enough, no one will suspect anything.

:l
dir/s
echo %RANDOM%
echo %RANDOM%
echo %RANDOM% 
goto l
\$\endgroup\$
2
votes
\$\begingroup\$
emerge @world

full recompile on gentoo

\$\endgroup\$
1
  • \$\begingroup\$ I'm pretty sure the availability of this primo excuse is the leading reason to run Gentoo at all. \$\endgroup\$
    – Caleb
    Aug 15, 2015 at 10:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.