This file contains hidden or 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
'use strict'; | |
const fetch = require('node-fetch'); | |
const functions = require('firebase-functions'); | |
const { smarthome } = require('actions-on-google'); | |
const util = require('util'); | |
const admin = require('firebase-admin'); | |
admin.initializeApp(); | |
const firebaseRef = admin.database().ref('/'); |
This file contains hidden or 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 int led1Pin = 13; // LED1 for Mode 1 | |
const int led2Pin = 12; // LED2 for Mode 2 | |
const int btn1Pin = 4; | |
const int btn2Pin = 3; | |
void setup() { | |
pinMode(led1Pin, OUTPUT); | |
pinMode(led2Pin, OUTPUT); | |
pinMode(btn1Pin, INPUT); | |
pinMode(btn2Pin, INPUT); |
This file contains hidden or 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
'use strict'; | |
const functions = require('firebase-functions'); | |
const { smarthome } = require('actions-on-google'); | |
const util = require('util'); | |
const admin = require('firebase-admin'); | |
// Initialize Firebase | |
admin.initializeApp(); | |
exports.fakeauth = functions.https.onRequest((request, response) => { |
This file contains hidden or 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 http = require('http'); | |
const heartbeat = 'echo heartbeat > /sys/class/leds/omega2p\:amber\:system/trigger'; | |
const o = require('omega2-gpio'); | |
const g = new o(); | |
const run = (pin, done) => { | |
g.tests().then( () => { | |
const p = g.pin({pin: pin, debug: true, mode: 'output'}); |
This file contains hidden or 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 omega2gpio = require('omega2-gpio'); | |
const gpio = new omega2gpio(); | |
gpio.tests().then( () => { | |
const p = g.pin({pin: 1, mode: 'output'}); | |
p.set(1); // set to HIGH | |
setTimeout( () => { | |
p.set(0); // set to LOW | |
}, 800); |
This file contains hidden or 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
class Force { | |
constructor(name = 'Force'){ | |
this.me = name; | |
} | |
print(){ | |
return `${this.me} Force`; | |
} | |
} | |
class Jedi extends Force { |
This file contains hidden or 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 force = Klass(function Force(name) { | |
this.me = name || 'Force'; | |
this.print = function () { | |
return this.me + ' Force'; | |
}; | |
}); | |
const jedi = Klass(force, function Jedi(name) { | |
this.me = name || 'Jedi'; | |
this.print = function () { |
This file contains hidden or 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 Klass(parent, child) { | |
if (!child) { | |
return parent; | |
} | |
//1) | |
child.prototype = new parent(); | |
//2) | |
child.prototype.constructor = child; |
This file contains hidden or 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 Jedi(name) { | |
this.name = name; | |
} | |
Jedi.prototype.toString = function () { | |
return 'I am ' + this.name; | |
}; | |
const luke = new Jedi('luke'); | |
console.log(luke.toString()); //=> 'I am luke' |
This file contains hidden or 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 Force() {} | |
Jedi.prototype.toString = function () { | |
return 'I am the Force'; | |
}; | |
function Jedi() {} | |
Jedi.prototype = Force.prototype; | |
Jedi.prototype.toString = function () { | |
return 'I am a Jedi'; | |
}; |