(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.
(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.
// In app.js or main.js or whatever: | |
// var myApp = angular.module('askchisne', ['ngSanitize', 'ngAnimate', 'ui.bootstrap', 'ui.bootstrap.tpls']); | |
// This filter makes the assumption that the input will be in decimal form (i.e. 17% is 0.17). | |
myApp.filter('percentage', ['$filter', function ($filter) { | |
return function (input, decimals) { | |
return $filter('number')(input * 100, decimals) + '%'; | |
}; | |
}]); |
<?php | |
/* a sample of traffic data from the real website, deduplicated and REST URLs digested */ | |
$traffic = unserialize(file_get_contents('seed.dat')) or die('Could not unserialize seed.dat'); | |
/* 20% chance by default */ | |
function chance($greater_than=20, $bottom=1, $top = 100) { | |
$toss = mt_rand($bottom, $top); | |
if($greater_than >= $toss) return true; else return false; | |
} |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
def archive_to_bytes(archive): | |
def to_seconds(s): | |
SECONDS_IN_A = { | |
's': 1, | |
'm': 1 * 60, | |
'h': 1 * 60 * 60, |
var HighResolutionTimer = window.HighResolutionTimer = window.HighResolutionTimer || (function() { | |
var HighResolutionTimer = function(options) { | |
this.timer = false; | |
this.total_ticks = 0; | |
this.start_time = undefined; | |
this.current_time = undefined; |
{ | |
"AL": "Alabama", | |
"AK": "Alaska", | |
"AS": "American Samoa", | |
"AZ": "Arizona", | |
"AR": "Arkansas", | |
"CA": "California", | |
"CO": "Colorado", | |
"CT": "Connecticut", | |
"DE": "Delaware", |
function interval(duration, fn){ | |
var _this = this | |
this.baseline = undefined | |
this.run = function(){ | |
if(_this.baseline === undefined){ | |
_this.baseline = new Date().getTime() | |
} | |
fn() | |
var end = new Date().getTime() |