This file contains 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 admin = require('firebase-admin'); | |
const serviceAccount = require('path/to/serviceAccountKey.json'); | |
// User IDs to be deleted | |
const UIDs = []; | |
// initialize the app | |
admin.initializeApp({ | |
credential: admin.credential.cert(serviceAccount), | |
databaseURL: 'https://<DATABASE_NAME>.firebaseio.com' |
This file contains 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
/********************* | |
** I Dream in Code ** | |
*********************/ | |
while( I .sleep() ) { | |
I.dream() in code; | |
I.dream() in algorithms; | |
I.dream() in subroutines; | |
Rewind.age(5) && I.dream.of(["missing pants", "driving hotwheels", "peeing in fountains"]) ); //hint: it’s my bed |
This file contains 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
function copyFbRecord(oldRef, newRef) { | |
oldRef.once('value', function(snap) { | |
newRef.set( snap.value(), function(error) { | |
if( error && typeof(console) !== 'undefined' && console.error ) { console.error(error); } | |
}); | |
}); | |
} |
This file contains 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 './style.css'; | |
import logger from './logger'; // see https://gist.github.com/katowulf/08cd54013ad75f2c4d6cc9961ec77db1 | |
import {sendRequest} from './request'; | |
const endpoint = 'https://us-central1-YOUR_PROJECT_ID_HERE.cloudfunctions.net/validateRequest'; | |
const data = { | |
string: 'foo', | |
integer: 23, | |
boolean: false, |
This file contains 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
var app = angular.module('app', ['firebase']); | |
app.controller('ctrl', function($scope, $pageArray) { | |
$scope.pageItems = $pageArray(ref, 'number'); | |
}); | |
app.factory('$pageArray', function($firebaseArray) { | |
return function(ref, field) { | |
// create a Paginate reference | |
var pageRef = new Firebase.util.Paginate(ref, field, {maxCacheSize: 250}); |
This file contains 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 functions = require('firebase-functions'); | |
const admin = require('firebase-admin'); | |
admin.initializeApp(); | |
const express = require('express'); | |
const cookieParser = require('cookie-parser')(); | |
const cors = require('cors')({origin: true}); | |
const app = express(); | |
// See https://github.com/firebase/functions-samples/blob/Node-8/authorized-https-endpoint/functions/index.js | |
const validateFirebaseIdToken = require('./validateFirebaseIdToken'); |
This file contains 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 functions = require('firebase-functions'); | |
const util = require('util'); | |
exports.helloWorld = functions.https.onRequest((req, res) => { | |
// For Firebase Hosting URIs, use req.headers['fastly-client-ip'] | |
// For callable functions, use rawRequest | |
// Some users have better success with req.headers['x-appengine-user-ip'] | |
const ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress; | |
const headers = JSON.stringify(req.headers, null, 2); | |
const message = util.format("<pre>Hello world!\n\nYour IP address: %s\n\nRequest headers: %s</pre>", ipAddress, headers); |
This file contains 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
JSONStream = require('JSONStream'); | |
es = require('event-stream'); | |
fileStream = storage.bucket('your-bucket').file('your-JSON-file').createReadStream(); | |
db = admin.firestore(); | |
return new Promise( (resolve, reject) => { | |
batchPromises = []; | |
batchSize = 0; | |
batch = db.batch(); |
This file contains 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
// This can probably be simplified somehow. Not sure why I need to add it in the component to init the service. | |
import { Component, OnInit } from '@angular/core'; | |
import {TitleService} from "./@core/utils/title.service"; | |
@Component({...}) | |
export class AppComponent implements OnInit { | |
constructor(private titleService: TitleService) {...} |
This file contains 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 firebase from "firebase/app"; | |
import "firebase/firestore"; | |
const randomNumber = Math.floor(Math.random() * 1000); | |
const docRef = firebase.firestore.doc("path/to/doc"); | |
db.runTransaction(async function(t) { | |
const doc = await t.get(docRef); | |
if (doc.exists && doc.data().number < randomNumber) { | |
console.log("setting new max"); |