Skip to content

Instantly share code, notes, and snippets.

View codediodeio's full-sized avatar
🤹‍♂️
hardly working

Jeff Delaney codediodeio

🤹‍♂️
hardly working
View GitHub Profile
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 22:22
AngularFire2 Auth service that merges custom data from the database
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 June 24, 2017 16:59
English to any language as a background task with Firebase cloud functions.
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 July 3, 2017 14:50
Reverse a FirebaseListObservable in Angular 4
<div *ngFor="let item of listObservable | async | reverse">
{{item?.whatever}}
</div>
@codediodeio
codediodeio / example.ts
Last active July 26, 2017 15:21
Composite Key Pattern in Firebase
createData() {
const data = {
name: 'Crane',
family: 'bird',
weight: 10,
endangered: false,
// composite keys
endangered_family: 'false_bird',
@codediodeio
codediodeio / search-ui.html
Last active July 27, 2017 16:10
Custom InstantSearchJS template with Angular bindings
<div *ngFor="let hit of hits | async">
{{hit | json}}
</div>
@State<AppStateModel>({
name: 'app',
defaults: {
hello: '',
}
})
export class AppState {}
@codediodeio
codediodeio / send-email.component.html
Last active April 19, 2018 13:28
Trigger HTTP Cloud Function via Angular Component (for transactional email)
<button (click)="sendEmail()">Send Email via Cloud Function</button>
@codediodeio
codediodeio / search-ui.component.html
Last active May 12, 2018 23:41
Algolia instantsearch.js Angular 4
<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">
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);