Javascript is a programming language with a peculiar twist. Its event driven model means that nothing blocks and everything runs concurrently. This is not to be confused with the same type of concurrency as running in parallel on multiple cores. Javascript is single threaded so each program runs on a single core yet every line of code executes without waiting for anything to return. This sounds weird but it's true. If you want to have any type of sequential ordering you can use events, callbacks, or as of late promises.
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
Parameters: | |
PrerenderToken: | |
Type: String | |
S3BucketName: | |
Type: String | |
Resources: | |
WebBucket: | |
Type: "AWS::S3::Bucket" | |
Properties: | |
BucketName: |
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 * as Application from 'koa'; | |
import * as KoaRouter from 'koa-router'; | |
import { IRegistrableController } from './RegistrableController'; | |
import { injectable } from 'inversify'; | |
@injectable() | |
export abstract class AbstractRouterController implements IRegistrableController { | |
public abstract prefix: string; | |
public abstract setup(router: KoaRouter); |
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
<div class="calendar"> | |
<div class="calendar-navs"> | |
<div class="month-nav"> | |
<button (click)="prevMonth()"><</button> | |
<span class="p4">{{ currentDate.format('MMMM') }}</span> | |
<button (click)="nextMonth()">></button> | |
</div> | |
<div class="year-nav"> | |
<button (click)="prevYear()"><</button> | |
<span>{{ currentDate.format('YYYY') }}</span> |
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
/** | |
* Read the text contents of a File or Blob using the FileReader interface. | |
* This is an async interface so it makes sense to handle it with Rx. | |
* @param {blob} File | Blob | |
* @return Observable<string> | |
*/ | |
const readFile = (blob) => Observable.create(obs => { | |
if (!(blob instanceof Blob)) { | |
obs.error(new Error('`blob` must be an instance of File or Blob.')); | |
return; |
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
<h1>Angular 2 Recursive List</h1> | |
<ul> | |
<ng-template #recursiveList let-list> | |
<li *ngFor="let item of list"> | |
{{item.title}} | |
<ul *ngIf="item.children.length > 0"> | |
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: item.children }"></ng-container> | |
</ul> | |
</li> | |
</ng-template> |
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 { Directive, Input, HostListener, Renderer, ElementRef } from '@angular/core'; | |
@Directive({ selector: '[hoverClass]' }) | |
export class HoverClassDirective { | |
@Input() | |
hoverClass: string; | |
constructor( | |
public elementRef: ElementRef, |
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 { Fetch, Utils } from 'teambition-sdk' | |
import { Observable } from 'rxjs/Observable' | |
import { Subject } from 'rxjs/Subject' | |
import { ReplaySubject } from 'rxjs/ReplaySubject' | |
import { AjaxResponse } from 'rxjs/observable/dom/AjaxObservable' | |
import { Subscriber } from 'rxjs/Subscriber' | |
import * as config from 'config' | |
export interface ChunkMeta { | |
fileType: string |
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
# set the base image to Debian | |
# https://hub.docker.com/_/debian/ | |
FROM debian:latest | |
# replace shell with bash so we can source files | |
RUN rm /bin/sh && ln -s /bin/bash /bin/sh | |
# update the repository sources list | |
# and install dependencies | |
RUN apt-get update \ |
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 {Directive, ElementRef, Input} from '@angular/core'; | |
@Directive({ | |
selector: '[background-image]' | |
}) | |
export class BackgroundImage { | |
private el: HTMLElement; | |
constructor(el: ElementRef) { | |
this.el = el.nativeElement; |
NewerOlder