Instantly share code, notes, and snippets.

View encryption.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bytes (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', new Buffer(ENCRYPTION_KEY), iv);
View index.js
var twilio = require('twilio');
var mongodb = require('mongodb');
module.exports = function(request) {
return new Promise(function(fulfill, reject){
// functional code goes in here
});
View bot.js
'use strict';
/**
* This sample demonstrates a simple skill built with the Amazon Alexa Skills Kit.
* The Intent Schema, Custom Slots, and Sample Utterances for this skill, as well as
* testing instructions are located at http://amzn.to/1LzFrj6
*
* For additional samples, visit the Alexa Skills Kit Getting Started guide at
* http://amzn.to/1LGWsLG
*/
View bot.js
// from https://claudiajs.com/news/2016/11/22/claudia-bot-builder-2.7.1-alexa-skills.html
// The list of platform names can include:
// facebook, slackSlashCommand, telegram, skype, twilio, kik, groupme, viber, alexa.
const botBuilder = require('claudia-bot-builder');
module.exports = botBuilder(function (message, originalApiRequest) {
return `I got ${message.text}`;
}, { platforms: ['alexa'] });
View .gitignore
# John Keefe’s global git ignore
.DS_Store
.AppleDouble
.LSOverride
.env
*.log
scratch.*
View index.html
// question-bot!
var twilio = require('twilio');
var mongodb = require('mongodb');
module.exports = function(request) {
return new Promise(function(fulfill, reject){
// functional code goes in here
View lambda.js
var questionbot = require('./index');
var ApiBuilder = require('claudia-api-builder');
var api = new ApiBuilder();
module.exports = api;
api.post('/question-bot', function(request){
// bulding the reply (repsonse)
// which first sends the request object to sparkbot for processing
return questionbot(request)
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Earthquakes Map: Last month</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.1/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.1/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Earthquakes Map: Last month</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.1/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.1/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }