Skip to content

Instantly share code, notes, and snippets.

Harry Lincoln harrylincoln

Block or report user

Report or block harrylincoln

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View fake-bubz.js
var SURNAME = ["Abraham", "Allan", "Alsop", "Anderson", "Arnold", "Avery", "Bailey", "Baker", "Ball", "Bell", "Berry", "Black", "Blake", "Bond", "Bower", "Brown", "Buckland", "Burgess", "Butler", "Cameron", "Campbell", "Carr", "Chapman", "Churchill", "Clark", "Clarkson", "Coleman", "Cornish", "Davidson", "Davies", "Dickens", "Dowd", "Duncan", "Dyer", "Edmunds", "Ellison", "Ferguson", "Fisher", "Forsyth", "Fraser", "Gibson", "Gill", "Glover", "Graham", "Grant", "Gray", "Greene", "Hamilton", "Hardacre", "Harris", "Hart", "Hemmings", "Henderson", "Hill", "Hodges", "Howard", "Hudson", "Hughes", "Hunter", "Ince", "Jackson", "James", "Johnston", "Jones", "Kelly", "Kerr", "King", "Knox", "Lambert", "Langdon", "Lawrence", "Lee", "Lewis", "Lyman", "MacDonald", "Mackay", "Mackenzie", "MacLeod", "Manning", "Marshall", "Martin", "Mathis", "May", "McDonald", "McLean", "McGrath", "Metcalfe", "Miller", "Mills", "Mitchell", "Morgan", "Morrison", "Murray", "Nash", "Newman", "Nolan", "North", "Ogden", "Oliver", "Paige", "Parr"
View webpack.config.js
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const path = require('path');
let prod = process.argv.indexOf('-p') !== -1;
let watchOption = process.argv.indexOf('--watch') !== -1;
module.exports = {
entry: ['./js/site.js'],
output: {
@harrylincoln
harrylincoln / routes.js
Created Jul 13, 2017
/api routes and the authentication handled by the brilliant express-firebase-middleware
View routes.js
...
router.use('/api', cors(), firebaseMiddleware.auth);
router.get('/api/hello', (req, res) => {
res.json({
message: `You're logged in as ${res.locals.user.email} with Firebase UID: ${res.locals.user.uid}`
});
});
...
@harrylincoln
harrylincoln / af.ts
Created Jul 13, 2017
Get a token ID so our BE knows you're legit
View af.ts
...
getTokenAndSendToAPI() {
this.afAuth.auth.currentUser.getToken().then(idToken => {
this.tokenID = idToken;
console.log('getTokenAndSendToAPI() idToken', this.tokenID);
let headersObj = new Headers();
headersObj.append('Authorization', 'Bearer ' + this.tokenID)
let options = new RequestOptions({ headers: headersObj });
@harrylincoln
harrylincoln / routes.js
Last active Jul 12, 2017
Express route for creating user via firebase admin
View routes.js
const express = require('express');
const router = express.Router();
const admin = require('firebase-admin');
const db = admin.database();
...
router.use('/create-user', (req, res) => {
console.log('createUser: req', req.body);
admin.auth().createUser({
email: req.body.emailAddress,
emailVerified: false,
@harrylincoln
harrylincoln / app.component.html
Created Jul 12, 2017
Html snippet to give context to createNewUserHit
View app.component.html
...
<h2>Example 1</h2>
<button (click)="createNewUserHit($event)">Create a user via backend</button>
<button (click)="signInEmailPassHit($event)">Sign in using email and pass</button>
...
@harrylincoln
harrylincoln / app.component.ts
Last active Jul 12, 2017
Extended component with createNewUser function
View app.component.ts
import { Component } from '@angular/core';
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
import { AF } from '../providers/af';
import { HttpModule } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { AngularFireAuthModule, AngularFireAuth } from 'angularfire2/auth';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
@harrylincoln
harrylincoln / af.ts
Last active Jul 12, 2017
Angularfire injectable provider
View af.ts
import {Injectable} from "@angular/core";
import { Observable } from 'rxjs/Observable';
import { FirebaseObjectFactoryOpts } from "angularfire2/interfaces";
import { AngularFireDatabaseModule, AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database';
import { AngularFireAuthModule, AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
import { Headers, Http, RequestOptions } from '@angular/http';
import 'rxjs/add/operator/toPromise';
@Injectable()
@harrylincoln
harrylincoln / app.component.ts
Created Jul 12, 2017
Component with focus on the constructor
View app.component.ts
import { Component } from '@angular/core';
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
import { AF } from '../providers/af';
import { HttpModule } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { AngularFireAuthModule, AngularFireAuth } from 'angularfire2/auth';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
@harrylincoln
harrylincoln / app.module.ts
Created Jul 12, 2017
App module bootstrapping angularfire2 functionality
View app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { AngularFireAuthModule } from 'angularfire2/auth';
import { environment } from '../environments/environment';
import { RegisterComponent } from './register/register.component';
You can’t perform that action at this time.