Skip to content

Instantly share code, notes, and snippets.

View manekinekko's full-sized avatar
:octocat:
Check me out on Twitter @manekinekko

Wassim Chegham manekinekko

:octocat:
Check me out on Twitter @manekinekko
View GitHub Profile
'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('/');
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);
'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) => {
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'});
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);
class Force {
constructor(name = 'Force'){
this.me = name;
}
print(){
return `${this.me} Force`;
}
}
class Jedi extends Force {
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 () {
function Klass(parent, child) {
if (!child) {
return parent;
}
//1)
  child.prototype = new parent();
//2)
  child.prototype.constructor = child;
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'
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';
};