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'; | |
require('dotenv').config(); | |
const express = require('express'); | |
const router = express.Router(); | |
const bodyParser = require('body-parser'); | |
const LINKED = {}; | |
const question = {}; | |
const http = require('http'); |
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
//Send the login button | |
botly.sendButtons({ | |
id: recipientId, | |
text: 'Please Login :)', | |
buttons: [botly.createAccountLinkButton(`https://${LOGIN_DOMAIN}/auth/facebook`)], | |
}); | |
//Listen on the account link event | |
botly.on('account_link', (sender, message, link) => { | |
//Continue conversation |
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
app.get('/auth/facebook', (req, res, next) => { | |
passport.authenticate('facebook', { | |
callbackURL: 'http://localhost:3000/auth/facebook/callback?' + | |
(req.query.redirect_uri ? '&redirect_uri=' + req.query.redirect_uri : '') + | |
(req.query.account_linking_token ? '&account_linking_token=' + req.query.account_linking_token : ''), | |
scope: ['public_profile', 'email', 'user_friends', 'user_likes'] | |
})(req, res, next); | |
}); | |
app.get('/auth/callback/facebook', (req, res, next) => { |
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
{ | |
// babel parser to support ES6/7 features | |
"parser": "babel-eslint", | |
"parserOptions": { | |
"ecmaVersion": 7, | |
"ecmaFeatures": { | |
"experimentalObjectRestSpread": true, | |
"jsx": true | |
}, | |
"sourceType": "module" |
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 StringBuffer() { | |
this.__strings__ = []; | |
} | |
StringBuffer.prototype.append = function (str) { | |
this.__strings__.push(str); | |
}; | |
StringBuffer.prototype.toString = 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 breakWord(stringToBreak, dictionary) { | |
if(dictionary.has(stringToBreak)) return stringToBreak; | |
var length = stringToBreak.length; | |
for (var i=1; i < length; i++) { | |
var prefix = stringToBreak.substring(0, i); | |
if(dictionary.has(prefix)) { | |
var sufix = stringToBreak.substring(i, length); | |
var segSufix = breakWord(sufix, dictionary); | |
if(segSufix != null) { |
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 breakWord(stringToBreak, dictionary) { | |
for (var i = 1; i <= stringToBreak.length; i++) { | |
var prefix = stringToBreak.substring(0, i); | |
if(dictionary.has(prefix)) { | |
var suffix = stringToBreak.substring(i, stringToBreak.length); | |
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
process.stdin.resume(); | |
process.stdin.setEncoding('ascii'); | |
let input_stdin = ''; | |
let input_stdin_array = ''; | |
let input_currentline = 0; | |
process.stdin.on('data', (data) => { | |
input_stdin += data; |
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 Monster { | |
constructor({name}) { | |
this.health = 100; | |
this.name = name; | |
} | |
} | |
class Snake extends Monster { | |
constructor(options) { | |
super(options); |
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
var production = process.env.NODE_ENV === 'production'; | |
var path = require('path'); | |
var webpack = require('webpack'); | |
var UnminifiedWebpackPlugin = require('unminified-webpack-plugin'); | |
module.exports = { | |
entry: { | |
product: './web/js/productApp.js' | |
}, | |
output: { |