Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Basic HTML5 Template</title> | |
<link href="stylesheets/style.css" rel="stylesheet" type="text/css" media="screen" /> | |
<script src="example.js"></script> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadImage(url) { | |
return new Promise((resolve, reject) => { | |
let img = new Image(); | |
img.addEventListener('load', e => resolve(img)); | |
img.addEventListener('error', () => { | |
reject(new Error(`Failed to load image's URL: ${url}`)); | |
}); | |
img.src = url; | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// function decorating in JS | |
function ___(wrapper) { | |
return function wrap(f) { | |
let a = { [f.name] : function(...args) {return wrapper.call(this, f, ...args)} } | |
return this[f.name] = a[f.name] | |
} | |
} | |
function $__(inner) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Speccy memory addresses for y-coords on screen (first byte) | |
let list = [], third, midblock, fine, i; | |
for (i=0;i<192;i++) { | |
third = i&192 ; | |
midblock = (i&56)>>3 ; | |
fine = (i&7)<<3 ; | |
list.push(midblock+third+fine) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getFlagEmoji = countryCode=>String.fromCodePoint(...[...countryCode.toUpperCase()].map(x=>0x1f1a5+x.charCodeAt(0))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Number.prototype[Symbol.iterator] = function* () { | |
for (let i = 1; i <= this; i++) yield i | |
} | |
[...5] // [1,2,3,4,5] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isValidCSSColour = str => { | |
const s = new Option().style | |
s.color = str | |
return s.color != '' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isPrime = x=>!'1'.repeat(x).match(/^1?$|^(11+?)\1+$/) |
OlderNewer