This file contains hidden or 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 getUsage = async uid => { | |
| const [ files ] = await bucket.getFiles({ prefix: uid }); | |
| if (!files || !files.length) { | |
| return 0; | |
| } | |
| const getFileSize = file => +file.metadata.size; | |
| const sum = (a, b) => a + b; | |
| return files.map(getFileSize).reduce(sum, 0); | |
| }; |
This file contains hidden or 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 const getQuotaToken = functions.https.onCall(async ({ id }, context) => { | |
| if (!context.auth) { | |
| throw new functions.https | |
| .HttpsError('failed-precondition', 'The function must be called while authenticated.'); | |
| } | |
| const { uid } = context.auth; | |
| const usage = await getUsage(uid); | |
| const quota = context.auth.token.quota || DEFAULT_QUOTA; | |
| const remaining = quota - usage; |
This file contains hidden or 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
| doFileUpload(uid, id, file) { | |
| return new Observable(subscriber => { | |
| const task = this.storage.upload(`${uid}/${id}`, file); | |
| task.snapshotChanges() | |
| .pipe( | |
| finalize(() => { | |
| subscriber.next({ done: true, id }); | |
| subscriber.complete(); | |
| }) | |
| ) |
This file contains hidden or 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
| #!/bin/bash | |
| docker run --name fc \ | |
| -v $PWD/ssl:/etc/nginx/certs \ | |
| -v $PWD/ssl/nginx-default.conf:/etc/nginx/conf.d/default.conf:ro \ | |
| -v $PWD/dist/___PROJECT_NAME___:/usr/share/nginx/html:ro -p 8080:443 -d nginx |
This file contains hidden or 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, EventEmitter, HostBinding, HostListener, Input, Output } from '@angular/core'; | |
| // Angular Drag and Drop File | |
| // | |
| // Add this directive to an element to turn it into a dropzone | |
| // for drag and drop of files. | |
| // Example: | |
| // | |
| // <div (appDropZone)="onDrop($event)"></div> | |
| // |
This file contains hidden or 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 { Injectable, NgZone } from '@angular/core'; | |
| import { BehaviorSubject } from 'rxjs/BehaviorSubject'; | |
| import { interval } from 'rxjs/observable/interval'; | |
| import { combineLatest, filter, map, merge, startWith, switchMap, takeUntil } from 'rxjs/operators'; | |
| import { Observable } from 'rxjs/Observable'; | |
| declare const YT: any; | |
| export enum YouTubePlayerState { | |
| Unstarted = -1, |
This file contains hidden or 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 { Pipe, PipeTransform } from '@angular/core'; | |
| @Pipe({ | |
| name: 'duration' | |
| }) | |
| export class DurationPipe implements PipeTransform { | |
| transform(value: string): string { | |
| const leftPad = x => String(x).length >= 2 ? x : leftPad(`0${x}`); | |
| const [ _, hours, mins, secs ] = value.match(/PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?/); | |
| return [hours || 0, mins || 0, secs || 0].map(leftPad).join(':'); |
This file contains hidden or 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
| get paths() { | |
| return _.map(this.bands, (v, x) => { | |
| return `M ${x} 128 L ${x} ${128 - (v / 2)}`; | |
| }); | |
| } | |
| get w() { | |
| const points = _.map(this.wavePoints, (v, x) => `L ${x} ${128 - (v / 2)}`); | |
| return 'M 0 64 ' + points.join(' '); | |
| } |
This file contains hidden or 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
| <svg class="spectrum"> | |
| <g *ngIf="!!bands"> | |
| <path fill="none" stroke="lightgrey" *ngFor="let p of paths" [attr.d]="p"></path> | |
| </g> | |
| <g *ngIf="!!wavePoints"> | |
| <path fill="none" stroke="black" stroke-opacity="0.75" [attr.d]="w"></path> | |
| </g> | |
| </svg> | |
| <br> |
This file contains hidden or 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
| <lab-slider label="Slider #1" [min]="0" [max]="10" [(value)]="value"></lab-slider> |