Skip to content

Instantly share code, notes, and snippets.

View gricha2380's full-sized avatar

gricha2380

View GitHub Profile
exports.handler = async (event) => {
let min = 0;
let max = 10;
let randomNumber = Math.floor(Math.random() * max) + min;
return randomNumber;
};
@gricha2380
gricha2380 / index.html
Created May 31, 2018 01:24
Pokémon Battle
<header>
<img class="logo" title="Reset Game" src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/98/International_Pok%C3%A9mon_logo.svg/2000px-International_Pok%C3%A9mon_logo.svg.png" alt="Pokemon">
</header>
<main>
<div class="instructions">
<p>Choose your hero</p>
</div>
<section class="characters"></section>
@gricha2380
gricha2380 / index.js
Created January 1, 2018 22:31
Writing to Database: index.js
const functions = require('firebase-functions'); //for firebase storage
const firebase = require('firebase-admin'); //for firebase database
const express = require('express'); // load express from node_modules
const bodyParser = require('body-parser');
const app = express(); // instantiate express to use its functionality
const PORT = process.env.PORT || 3000; // set a port. Look to environment variable if avaialble
app.engine('hbs', engines.handlebars); // use consolidate to attach handlebars templating
app.set('views', './views'); // set views folder to our directory
@gricha2380
gricha2380 / index.js
Created January 1, 2018 22:17
Serving up HTML pages: index.js
const functions = require('firebase-functions'); //for firebase storage
const firebase = require('firebase-admin'); //for firebase database
const express = require('express'); // load express from node_modules
const app = express(); // instantiate express to use its functionality
const PORT = process.env.PORT || 3000; // set a port. Look to environment variable if avaialble
app.engine('hbs', engines.handlebars); // use consolidate to attach handlebars templating
app.set('views', './views'); // set views folder to our directory
app.set('view engine', 'hbs'); // use our engine
@gricha2380
gricha2380 / index.js
Last active January 1, 2018 21:13
Reading from Database: index.js (don't forget to install all required dependencies!) Raw
const functions = require('firebase-functions'); //for firebase storage
const firebase = require('firebase-admin'); //for firebase database
const express = require('express'); // load express from node_modules
const app = express(); // instantiate express to use its functionality
const PORT = process.env.PORT || 3000; // set a port. Look to environment variable if avaialble
const firebaseApp = firebase.initializeApp(
functions.config().firebase // use credentials from configured project
);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>All Houses</title>
</head>
<body>
<h1>List of Houses</h1>
[ {
"name" : "bill's house",
"color" : "white",
"address" : "224 NE 111st",
"rooms" : 4,
"garage" : null
}, {
"name" : "steve's house",
"color" : "yellow",
"address" : "5101 NE 111st",
@gricha2380
gricha2380 / firebase.json
Last active January 1, 2018 20:54
Basic Config: index.js & firebase.json (don't forget to install all required dependencies!)
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites" : [{
"source" : "**",