This file contains 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
git config --global --add alias.permission-reset '!git diff -p -R | grep -E "^(diff|(old|new) mode)" | git apply' | |
git permission-reset |
This file contains 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
socket.on('status', function(status){ | |
// ... | |
if(status.intrusion){ | |
takeSnapShotAndCompareTo('me@WorkmateProtection'); | |
} | |
}); | |
function takeSnapShotAndCompareTo(tag, done){ |
This file contains 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'; | |
// WARN : works only for 1 instance at time, we have to call describeTags for each instance | |
const zlib = require('zlib'); | |
const AWS = require('aws-sdk'); | |
const ec2 = new AWS.EC2(); | |
exports.handler = (event, context, callback) => { | |
const payload = new Buffer(event.awslogs.data, 'base64'); |
This file contains 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 sendSMS(cb){ | |
var sendSMSOptions = { | |
hostname: 'api.ninja.is', | |
path: '/my-SMS-web-hook', | |
method: 'POST', | |
headers: {accept: 'text/plain'} | |
}; | |
req = http.request(sendSMSOptions, function(res){ | |
res.on('end', function () { |
This file contains 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
app.post('/detect', function (req, res) { | |
// ... | |
if(alarmArmed){ | |
intrusion = 1; | |
alarmArmed = false; | |
} | |
// ... | |
}); |
This file contains 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
var alarmArmed = false; | |
// Called by Ninja Block when the remote button is pressed | |
app.post('/button', function (req, res) { | |
alarmArmed = !alarmArmed; | |
setAlarmStatus(alarmArmed, function(err){ | |
if(err){ | |
console.log('err : '+err); | |
} |
This file contains 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
var io = require('socket.io-client'); | |
var socket = io.connect('http://my-server'); | |
socket.on('status', function(status){ | |
if(status.exit == 1){ | |
lockScreen(); | |
}else if(status.sensei == 1){ | |
launchSite(); | |
} | |
}); |
This file contains 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
var exitDetected = 0; | |
var senseiDetected = 0; | |
var doorOpened = 0; | |
var existStatusInterval = 0; | |
app.post('/door-open', function (req, res) { | |
doorOpened = 1; | |
existStatusInterval = setTimeout(setExitStatus, 5000); | |
dispatchInfos(); |
This file contains 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
var app = require('express')(); | |
var http = require('http'); | |
var server = http.createServer(app); | |
var io = require('socket.io').listen(server, { log: false }) | |
app.post('/door-open', function (req, res) { | |
}); | |
app.post('/detect', function (req, res) { | |
}); |