Skip to content

Instantly share code, notes, and snippets.

Avatar
🤹‍♂️
hardly working

Jeff Delaney codediodeio

🤹‍♂️
hardly working
View GitHub Profile
@codediodeio
codediodeio / index.js
Created Jun 28, 2017
Firebase Cloud Functions image thumbnail generator using Sharp for 4x faster resizing
View index.js
const functions = require('firebase-functions');
const gcs = require('@google-cloud/storage')();
const sharp = require('sharp')
const _ = require('lodash');
const path = require('path');
const os = require('os');
exports.generateThumbnail = functions.storage.object('uploads/{imageId}').onChange(event => {
const object = event.data; // The Storage object.
@codediodeio
codediodeio / database.rules.json
Last active May 7, 2019
Associate Firebase users with database items based on their UID
View database.rules.json
"rules": {
"items": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
}
}
@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 / 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 / index.js
Created Jul 10, 2017
Simple Stripe Payments with Firebase Cloud Functions
View index.js
const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp(functions.config().firebase);
const stripe = require('stripe')(functions.config().stripe.testkey)
exports.stripeCharge = functions.database
@codediodeio
codediodeio / user.component.ts
Last active Sep 19, 2019
Link Anonymous Users to Google/Facebook with AngularFire2 (Angular 4 + Firebase)
View user.component.ts
import { Component, OnInit } from '@angular/core';
import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
import { Observable } from 'rxjs/Observable';
@Component({
selector: 'app-user',
templateUrl: './user.component.html',
styleUrls: ['./user.component.scss']
})
@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">
@codediodeio
codediodeio / index.js
Created Jul 17, 2017
Algolia Firebase Cloud Functions - Update/Delete Items from Index
View index.js
const functions = require('firebase-functions');
const admin = require("firebase-admin");
admin.initializeApp(functions.config().firebase);
const algoliasearch = require('algoliasearch');
const algolia = algoliasearch(functions.config().algolia.appid, functions.config().algolia.adminkey);
exports.updateIndex = functions.database.ref('/books/{bookId}').onWrite(event => {
@codediodeio
codediodeio / phone-login.component.html
Last active Mar 2, 2021
Firebase Phone Login Angular 4
View phone-login.component.html
<div [hidden]="user">
<h1>Sign In with Your Phone Number</h1>
<label for="phone">Phone Number</label><br>
<input type="text" [(ngModel)]="phoneNumber.country" class="input" placeholder="1" maxlength="2">
<input type="text" [(ngModel)]="phoneNumber.area" class="input" placeholder="949" maxlength="3">
<input type="text" [(ngModel)]="phoneNumber.prefix" class="input" placeholder="555" maxlength="3">
<input type="text" [(ngModel)]="phoneNumber.line" class="input" placeholder="5555" maxlength="4">
@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>