(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
// TLDR: Oi, Barnes. We'll miss ya. Here's a grimy RNG in your honor. | |
// node oi.js or paste the below into your favorite browser's JS console. | |
// DEFCON CHALLENGE: Break this! | |
function millis() { return Date.now(); } | |
function flip_coin() { n=0; then = millis()+1; while(millis()<=then) { n=!n; } return n; } | |
function get_fair_bit() { while(1) { a=flip_coin(); if(a!=flip_coin()) { return(a); } } } | |
function get_random_byte(){ n=0; bits=8; while(bits--){ n<<=1; n|=get_fair_bit(); } return n; } | |
report_console = function() { while(1) { console.log(get_random_byte()); }} |
// Boring | |
if (isThisAwesome) { | |
alert('yes'); // it's not | |
} | |
// Awesome | |
isThisAwesome && alert('yes'); | |
// Also cool for guarding your code | |
var aCoolFunction = undefined; |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.