Skip to content

Instantly share code, notes, and snippets.

View ajb413's full-sized avatar

Adam Bavosa ajb413

View GitHub Profile
@ajb413
ajb413 / app.js
Last active March 29, 2018 01:12
Amazon Comprehend ChatEngine demo snippet
sentimentAnalysis: function (text, id) {
var deferred = $.Deferred();
$.ajax({
method: "POST",
url: comprehendFunctionURI,
data: JSON.stringify({
"data": {
"text": text,
"comprehend": {
@ajb413
ajb413 / index.js
Created April 28, 2018 02:00
MonkeyLearn block for PubNub Functions - an On Request event handler
const xhr = require('xhr');
const vault = require('vault');
export default (request, response) => {
let body;
let classifier;
let input;
/**
* Validate the request.
@ajb413
ajb413 / index.js
Created May 1, 2018 00:32
audio lext test
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: "__id__",
secretAccessKey: "__secret__",
});
var lexruntime = new AWS.LexRuntime({region: 'us-east-1'});
@ajb413
ajb413 / snippet.js
Created May 15, 2018 16:00
ChatEngine User Connect Example
const me = {
name: 'John Smith',
uuid: '12345', // Can be a valid UUID, as long as it's a string
};
ChatEngine.connect(me.uuid, me);
@ajb413
ajb413 / snippet.js
Created May 15, 2018 16:06
ChatEngine Chat Example
chat.emit('custom-event', {value: true});
chat.on('custom-event', (payload) => {
console.log(payload.sender.uuid, 'emitted the value', payload.data.value);
});
@ajb413
ajb413 / snippet.js
Created May 15, 2018 16:27
ChatEngine Chat Create Example
const aliceBobPrivateChat = new ChatEngine.Chat('alice-bob-channel', true);
aliceBobPrivateChat.emit('message', {
text: 'Hey!'
});
@ajb413
ajb413 / snippet.js
Created May 15, 2018 16:49
ChatEngine Message Example
chat.emit('message', {
text: "This is the chatbot speaking :]",
});
// Separate into 2 snippets
chat.on('message', (payload) => {
chatLog.append(payload.text);
});
@ajb413
ajb413 / snippet.js
Created May 15, 2018 16:52
ChatEngine History Search Example
// Get the message history in the global chat
globalChat.search({
event: 'message',
limit: 6,
});
@ajb413
ajb413 / index.js
Created May 24, 2018 20:22
a gist for a medium article from my eth-megaphone repo
// Libs
const PubNub = require('pubnub');
const Web3 = require('web3');
const ContractBuild = require('PATH_TO_TRUFFLE/build/contracts/Token.json');
// PubNub
pubnub = new PubNub({
publishKey : '__YOUR_PUB_KEY__',
subscribeKey : '__YOUR_SUB_KEY__'
});
@ajb413
ajb413 / snippet.sh
Created May 30, 2018 19:47
snippet for medium
## Get the Vue CLI
npm i vue -g
## Create a new Vue app
## Chose whichever settings you want using the Vue CLI
vue init webpack chat-app
cd chat-app
npm i vuex vue-chat-engine chat-engine chat-engine-typing-indicator