Skip to content

Commit

Permalink
webdirections initial
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Apr 30, 2014
1 parent 5becf7c commit da4b581
Show file tree
Hide file tree
Showing 39 changed files with 8,743 additions and 0 deletions.
59 changes: 59 additions & 0 deletions presentations/webdirections-code-2014/.jshintrc
@@ -0,0 +1,59 @@
{
"predef": [ ]
, "bitwise": false
, "camelcase": false
, "curly": false
, "eqeqeq": false
, "forin": false
, "immed": false
, "latedef": false
, "noarg": true
, "noempty": true
, "nonew": true
, "plusplus": false
, "quotmark": true
, "regexp": false
, "undef": true
, "unused": true
, "strict": false
, "trailing": true
, "maxlen": 120
, "asi": true
, "boss": true
, "debug": true
, "eqnull": true
, "esnext": true
, "evil": true
, "expr": true
, "funcscope": false
, "globalstrict": false
, "iterator": false
, "lastsemic": true
, "laxbreak": true
, "laxcomma": true
, "loopfunc": true
, "multistr": false
, "onecase": false
, "proto": false
, "regexdash": false
, "scripturl": true
, "smarttabs": false
, "shadow": false
, "sub": true
, "supernew": false
, "validthis": true
, "browser": true
, "couch": false
, "devel": false
, "dojo": false
, "mootools": false
, "node": true
, "nonstandard": true
, "prototypejs": false
, "rhino": false
, "worker": true
, "wsh": false
, "nomen": false
, "onevar": true
, "passfail": false
}
Binary file not shown.
Binary file not shown.
1,131 changes: 1,131 additions & 0 deletions presentations/webdirections-code-2014/fonts/Century-Schoolbook-Monospace-BT.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2,912 changes: 2,912 additions & 0 deletions presentations/webdirections-code-2014/fonts/SignikaNegative-Bold.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2,937 changes: 2,937 additions & 0 deletions presentations/webdirections-code-2014/fonts/SignikaNegative-Regular.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
105 changes: 105 additions & 0 deletions presentations/webdirections-code-2014/gen.js
@@ -0,0 +1,105 @@
// some asynchronous function, could be anything conforming to the normal node callpath pattern

function timer (callback) {
setTimeout(function () {
callback(null, new Date())
}, 1000)
}

// Linear congruential pseudo random number generator
function* random (seed) {
while (true) {
var m = 25, a = 11, c = 17, z = seed;
z = (a * z + c) % m;
yield z;
}
}

function* random (seed) {
var m = 25, a = 11, c = 17, z = seed;
while (true) {
z = (a * z + c) % m;
seed = yield z;
if (typeof seed == 'number')
z = seed
}
}

console.log('gen')
var gen = random(Date.now())
for (var i = 0; i < 10; i++)
console.log(gen.next().value)
console.log()

var s = Date.now()
var gen = random(s)
console.log(gen.next().value)
console.log(gen.next().value)
console.log(gen.next().value)
console.log(gen.next().value)
console.log(gen.next().value)
console.log(gen.next().value)
console.log('seed', s)
console.log(gen.next(s).value)
console.log(gen.next().value)
console.log(gen.next().value)
console.log(gen.next().value)
console.log(gen.next().value)

// generator that yields async functions as a way of performing work

function* gengen () {
var v1 = yield timer
console.log('v1', v1)
var v2 = yield timer
console.log('v2', v2)
var v3 = yield timer
console.log('v3', v3)
return 'all done'
}

// a pre-ES6 version of the generator confirming to the general protocol

function fakegen () {
var c = 0
return {
next: function (arg) {
c++
switch (c) {
case 1:
return { value: timer };
case 2:
console.log('v1', arg)
return { value: timer };
case 3:
console.log('v2', arg)
return { value: timer };
case 4:
console.log('v2', arg)
return { done: true, value: 'all done' };
}
}
}
}

// generator async runner, simplistic form of 'co'

function run (fn) {
var gen = fn();
(function next (arg) {
var it = gen.next(arg)
console.log('got', it, 'passed', arg)
if (it.done)
return console.log('done', it.value)

it.value(function (err, data) {
next(data);
})
}())
}

// execute the generator function (uncomment one)

//run(fakegen)
run(gengen);

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added presentations/webdirections-code-2014/img/npm.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit da4b581

Please sign in to comment.