Skip to content

Instantly share code, notes, and snippets.

View hartct's full-sized avatar

Chris Hart hartct

View GitHub Profile
@hartct
hartct / keybase.md
Last active February 17, 2018 21:21

Keybase proof

I hereby claim:

  • I am hartct on github.
  • I am ceehart (https://keybase.io/ceehart) on keybase.
  • I have a public key ASBaYkQdRLAQ0gBhCSc43qHueLPqvuWi4c4YaftAu1TDvgo

To claim this, I am signing this object:

@hartct
hartct / join_channel.html
Created February 20, 2017 21:30
Agent UI for a specific customer conversation
<!doctype html>
<html>
<head>
<title>Socket.IO chat</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font: 13px Helvetica, Arial; }
form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
@hartct
hartct / index.html
Created February 20, 2017 21:27
Index page for the agent web UI
<!doctype html>
<html>
<head>
<title>Socket.IO chat</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font: 13px Helvetica, Arial; }
form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
@hartct
hartct / botServer.js
Created February 20, 2017 21:16
Bot server implementation
var restify = require('restify');
var builder = require('botbuilder');
var env = require('node-env-file');
var client = require("socket.io-client");
function findRooms(io) {
var availableRooms = [];
var rooms = io.sockets.adapter.rooms;
if (rooms) {
@hartct
hartct / socketManager.js
Created February 20, 2017 21:05
Socket.io connection manager
module.exports = function(io, http) {
const channelSpecificMessageTypes = ['agent joined', 'channel message', 'customer message', 'agent message'];
io.on('connection', function(socket){
console.log('a user connected');
socket.on('chat message', function(msg){
console.log('socketMgr: chat message: ' + msg);
io.emit('chat message', msg);
});
@hartct
hartct / app.js
Created February 20, 2017 21:03
Bootstrap the hybrid bot application
var env = require('node-env-file');
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var redis = require('redis').createClient;
var adapter = require('socket.io-redis');
env('.env');
var pub = redis(process.env.redisPort, process.env.redisHost, { auth_pass: process.env.redisPassword });
@hartct
hartct / .env
Created February 20, 2017 21:00
.env sample for hybrid chatbot project
appId=<Azure Bot App ID>
appPassword=<Azure Bot App Password>
redisPassword=<Redis password>
redisUrl=<redis host>:<redis port>
redisHost=<redis host>
redisPort=<redis port>

Keybase proof

I hereby claim:

  • I am hartct on github.
  • I am ceehart (https://keybase.io/ceehart) on keybase.
  • I have a public key whose fingerprint is 55EB 1E8F A77A 10E1 1487 28C2 355D A92F 2642 C6CB

To claim this, I am signing this object:

@hartct
hartct / assets_controller.rb
Created June 1, 2013 21:42
Sample assets controller proxying some requests to S3
class AssetsController < ApplicationController
def somename1
uri = URI.parse "https://someurl2/#{params[:id]}.png"
response = Net::HTTP.get_response(uri)
send_data response.body, :type => 'image/png',:disposition => 'inline'
end
def somename2
uri = URI.parse "https://someurl2/#{params[:id]}.png"
@hartct
hartct / routes.rb
Last active December 17, 2015 23:49
Sample routes.rb that overrides the asset pipeline to serve assets using a controller fetching the content from S3
YourApp::Application.routes.draw do
# other routes
match '/assets/somename1/:id' => 'assets#somename1'
match '/assets/somename2/:id' => 'assets#somename2'
# ...
end