Skip to content

Instantly share code, notes, and snippets.

View Eric013's full-sized avatar

Sanchez Eric Eric013

View GitHub Profile
const admin = require("admin");
function getFirebaseUser(req, res, next) {
console.log("Check if request is authorized with Firebase ID token");
if (
!req.headers.authorization ||
!req.headers.authorization.startsWith("Bearer ")
) {
console.error(
"No Firebase ID token was passed as a Bearer token in the Authorization header.",
@Eric013
Eric013 / index.js
Created December 14, 2017 20:46 — forked from giolaq/index.js
Script to use Firebase Cloud Functions and Vision API
const Vision = require('@google-cloud/vision');
const vision = Vision();
const functions = require('firebase-functions');
const admin = require("firebase-admin");
admin.initializeApp(functions.config().firebase);
exports.callVision = functions.storage.object().onChange(event => {
const object = event.data;
const fileBucket = object.bucket;
const filePath = object.name;
@Eric013
Eric013 / gist:28bf6ee9914e5abcf9b93023acd57658
Created March 14, 2017 13:08 — forked from yunghoy/gist:a425f91824d26461bb2e3653bc56ebbf
AMQP library (RabbitMQ) - async/await
alias babel-node='babel-node --presets stage-0'
------ RECV ------
// babel-node recv2.js "#"
// babel-node recv2.js "kern.*"
const amqp = require('amqplib');
const args = process.argv.slice(2);
if (args.length == 0) {
@Eric013
Eric013 / levenshtein.js
Created January 30, 2017 08:52 — forked from andrei-m/levenshtein.js
Levenshtein distance between two given strings implemented in JavaScript and usable as a Node.js module
/*
Copyright (c) 2011 Andrei Mackenzie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
@Eric013
Eric013 / AWS_S3_File_Upload.js
Created January 27, 2017 11:06 — forked from homam/AWS_S3_File_Upload.js
How to upload files to AWS S3 with NodeJS SDK
var AWS = require('aws-sdk'),
fs = require('fs');
// For dev purposes only
AWS.config.update({ accessKeyId: '...', secretAccessKey: '...' });
// Read in the file, convert it to base64, store to S3
fs.readFile('del.txt', function (err, data) {
if (err) { throw err; }
@Eric013
Eric013 / training.sh
Created January 16, 2017 14:10 — forked from christianroman/training.sh
Tesseract OCR training new font
#! /bin/bash
# build the environment
mkdir tessenv; cd tessenv
TROOT=`pwd`
mkdir $TROOT/stockfonts; mkdir $TROOT/build; mkdir $TROOT/build/eng
echo "Environment built"
# Get the stock english fonts from Google (old, but they work)
cd $TROOT/stockfonts
GET http://tesseract-ocr.googlecode.com/files/boxtiff-2.01.eng.tar.gz > boxtiff-2.01.eng.tar.gz
@Eric013
Eric013 / beforeSaveService.spec
Created September 23, 2016 23:57 — forked from mmazzarolo/beforeSaveService.spec
Parse-server setup
import Parse from 'parse/node'
import { afterEach, describe, it } from 'mocha'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { resetParse, getAdminUser } from '../../../test/parseHelper'
import errors from '../../utils/errors'
chai.use(chaiAsPromised)
const assert = chai.assert
@Eric013
Eric013 / gist:036ae66e507ff4e5c10cb4b12fbaa02f
Created September 3, 2016 04:35 — forked from Alex-D/gist:a41f10603ad86be8f371
Comment contribuer : comprendre comment suivre le workflow

Salut à tou-te-s !

J'écris ce message pour expliquer brièvement comment procéder pour avoir une copie locale propre du projet sans utiliser des branches sur le dépôt principal.

Ca n'a pas tellement sa place dans le README car c'est limite un tuto git simplifié.

@Eric013
Eric013 / react-native-talk.md
Created February 25, 2016 13:36 — forked from peterjmag/react-native-talk.md
Let's build a React Native app in 20 minutes - React Berlin #1 (April 2015)