Skip to content

Instantly share code, notes, and snippets.

Avatar
🤹‍♂️
hardly working

Jeff Delaney codediodeio

🤹‍♂️
hardly working
View GitHub Profile
View auth.service.ts
import { Injectable } from '@angular/core';
import { AngularFireAuth } from "angularfire2/auth";
import { AngularFireDatabase } from "angularfire2/database";
import * as firebase from 'firebase';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
export class User {
uid: string;
username:string;
@codediodeio
codediodeio / auth.service.ts
Last active May 12, 2017
AngularFire2 Auth service that merges custom data from the database
View auth.service.ts
import { Injectable } from '@angular/core';
import { AngularFireAuth } from "angularfire2/auth";
import { AngularFireDatabase } from "angularfire2/database";
import * as firebase from 'firebase';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
export class User {
uid: string;
username:string;
@codediodeio
codediodeio / index.js
Created Jun 24, 2017
English to any language as a background task with Firebase cloud functions.
View index.js
var functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const request = require('request-promise');
const _ = require('lodash');
// List of output languages.
const LANGUAGES = ['es', 'fr', 'ar'];
@codediodeio
codediodeio / reverse.pipe.ts
Created Jul 3, 2017
Reverse a FirebaseListObservable in Angular 4
View reverse.pipe.ts
<div *ngFor="let item of listObservable | async | reverse">
{{item?.whatever}}
</div>
@codediodeio
codediodeio / example.ts
Last active Jul 26, 2017
Composite Key Pattern in Firebase
View example.ts
createData() {
const data = {
name: 'Crane',
family: 'bird',
weight: 10,
endangered: false,
// composite keys
endangered_family: 'false_bird',
@codediodeio
codediodeio / search-ui.html
Last active Jul 27, 2017
Custom InstantSearchJS template with Angular bindings
View search-ui.html
<div *ngFor="let hit of hits | async">
{{hit | json}}
</div>
View app.state.ts
@State<AppStateModel>({
name: 'app',
defaults: {
hello: '',
}
})
export class AppState {}
@codediodeio
codediodeio / send-email.component.html
Last active Apr 19, 2018
Trigger HTTP Cloud Function via Angular Component (for transactional email)
View send-email.component.html
<button (click)="sendEmail()">Send Email via Cloud Function</button>
@codediodeio
codediodeio / search-ui.component.html
Last active May 12, 2018
Algolia instantsearch.js Angular 4
View search-ui.component.html
<div id="search-box">
<!-- SearchBox widget will appear here -->
</div>
<div id="stats">
<!-- stats widget will appear here -->
</div>
<div id="hits">
<!-- Hits widget will appear here -->
</div>
<div id="pagination">
View ref.ts
export class DocRef {
private ref: firebase.firestore.DocumentReference;
private stream;
constructor(private path: string) {
this.ref = firebase.firestore().doc(path);
this.stream = Observable.create(observer => {
this.ref.onSnapshot({
next(doc) {
observer.next(doc);
You can’t perform that action at this time.