Skip to content

Instantly share code, notes, and snippets.

View elon-gs's full-sized avatar

elon-gs

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@elon-gs
elon-gs / UploaderComponent.js
Created October 4, 2018 18:53
React example component to upload image to Express backend
// for backend, see https://gist.github.com/elon-gs/d6adae8b77d7c90cb76b591fef10d24a
import React, { Component } from 'react';
import ImageUploader from 'react-images-upload';
import axios from 'axios';
let uploading = false;
export default class UploaderComponent extends Component {
state = {
@elon-gs
elon-gs / index.js
Created October 4, 2018 18:19
Express backend to upload user-files to Google Cloud Storage
const express = require('express');
const app = express();
const functions = require('firebase-functions');
const cors = require('cors')({ origin: true });
app.use(cors);
// upload account image
const API_LINK_BASE_URL = 'http://storage.googleapis.com';
const PROJECT_ID = ;// {YOUR_PROJECT_ID, USUALLY A SINGLE WORD};
const BUCKET_ID = ;// {YOUR_BUCKET_ID, E.G. PROJECT_ID.appspot.com};
@elon-gs
elon-gs / trigger-to-google-sheet.js
Created June 5, 2017 20:20
Trigger function that copies new data in FB database to Google Sheet
// Trigger function copies new data in FB database to Google Sheet
const FUNCTIONS_CLIENT_ID = functions.config().googleapi.client_id;
const FUNCTIONS_SECRET_KEY = functions.config().googleapi.client_secret;
const FUNCTIONS_REDIRECT = '{YOUR_FUNCTIONS_SUBDOMAIN}.cloudfunctions.net/OauthCallback';
// TODO: use firebase functions:config:set to configure your Google API client ID and secret
// Also update FUNCTIONS_REDIRECT
const googleAuth = require('google-auth-library');
const google = require('googleapis');
@elon-gs
elon-gs / google-auth-functions.js
Created June 5, 2017 20:13
Google Functions code for generating Google Auth tokens
// Code to write Google API Oauth tokens to Firebase database
const FUNCTIONS_CLIENT_ID = functions.config().googleapi.client_id;
const FUNCTIONS_SECRET_KEY = functions.config().googleapi.client_secret;
const FUNCTIONS_REDIRECT = '{YOUR_FUNCTIONS_SUBDOMAIN}.cloudfunctions.net/OauthCallback';
// TODO: use firebase functions:config:set to configure your Google API client ID and secret
// Also update FUNCTIONS_REDIRECT
const googleAuth = require('google-auth-library');
@elon-gs
elon-gs / index.js
Created June 5, 2017 19:56
Simple Firebase trigger Function to send a Twilio SMS
// index.js for Firebase Functions
// SMS is triggered when an alert object is added to the alert queue path
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const twilio = require('twilio');
admin.initializeApp(functions.config().firebase);
const db = admin.database();