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
@timestampable | |
class Dog { | |
public name: string = 'Paul'; | |
} | |
function timestampable(func) { | |
return <any>(function() { | |
var genericConstructor = () => {}; | |
genericConstructor.prototype = func.prototype; | |
var instance = new genericConstructor(); |
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
#Workflow:: CompStak | |
credentials: | |
username: | |
password: | |
account: | |
line: | |
title: CompStack V1.0 | |
template_id: DaAvql4Ayi |
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
/// <reference path="../../typings/tsd.d.ts" /> | |
/// | |
import {PipeFactory} from 'angular2/src/change_detection/pipes/pipe'; | |
import {async} from 'angular2/src/change_detection/change_detection'; | |
import {NullPipeFactory, Pipe, PipeRegistry, defaultPipes} from 'angular2/change_detection'; | |
import {bind} from 'angular2/di'; | |
import {ObservablePipe} from 'angular2/pipes'; | |
import * as Rx from 'rx'; | |
export function isObservable(obs) { |
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
import {Component} from 'angular2/core'; | |
import {bootstrap} from 'angular2/platform/browser'; | |
import 'rxjs/Rx'; | |
import {HTTP_PROVIDERS, Http} from 'angular2/http'; | |
@Component({ | |
selector: 'app', | |
template: ` | |
<ul *ngFor="#person of people | async"> | |
{{person.name}} | |
</ul> |
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 toRGB = (() => { | |
const expand = hex => | |
hex.length < 7 ? hex.split("").reduce((a, b) => a + b + b) : hex; | |
const convert = hex => | |
hex.match(/[\d\w]{2}/g).map(val => parseInt(val, 16)); | |
return hex => { | |
const [r, g, b] = convert(expand(hex)); | |
return `rgb(${r}, ${g}, ${b})`; | |
}; | |
})(); |
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
// based on https://gist.github.com/gre/1650294 | |
// no easing, no acceleration | |
export function linear( t ) { | |
return t; | |
} | |
// accelerating from zero velocity | |
export function easeInQuad( t ) { | |
return t * t; |
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
[] + []; // JavaScript will give you "" (which makes little sense), TypeScript will error | |
// | |
// other things that are nonsensical in JavaScript | |
// - don't give a runtime error (making debugging hard) | |
// - but TypeScript will give a compile time error (making debugging unnecessary) | |
// | |
{} + []; // JS : 0, TS Error | |
[] + {}; // JS : "[object Object]", TS Error | |
{} + {}; // JS : NaN, TS Error |
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
export function createReducer(initialState, reducerMap) { | |
return (state = initialState, action) => { | |
const reducer = reducerMap[action.type]; | |
return reducer | |
? reducer(state, action.payload) | |
: state; | |
}; | |
} |
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
// | |
// WRONG | |
/// | |
class InMemorySparseMap<K, V> implements SparseMap<K, V> { | |
private latest: Map<K, Updatable<V>>; | |
private factory: ((key: K) => Observable<V>) | undefined; | |
subscribe(key: K): Updatable<V> { | |
let ret = this.latest.get(key); |
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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<script src="http://d3js.org/d3.v2.js"></script> | |
<style> | |
line.arrow { | |
stroke: #666; |
OlderNewer