Skip to content

Instantly share code, notes, and snippets.

View tdelam's full-sized avatar

Trevor Delamorandiere tdelam

View GitHub Profile
controller.on('conversationStarted', (bot, convo) => {
console.log('A conversation started with ', convo.context.user);
// Map the convo when it starts with the proper user
// and set `quote_completed` to false. This is useful for
// resuming a quote. This is set to true with convo.on('end') callback
if (convo.status === 'active') {
const usersPublicProfile = 'https://graph.facebook.com/v2.6/' + convo.context.user + '?fields=first_name,last_name,&access_token=' + process.env.page_token;
request({
url: usersPublicProfile,
json: true // parse
[debug] Simple CORS request from Origin 'http://localhost:3000' is allowed
[debug] Processing by PhoenixChat.UserController.create/2
Parameters: %{"user" => %{"email" => "[email protected]", "password" => "[FILTERED]", "username" => "tdelam"}}
Pipelines: [:api]
[info] Sent 500 in 47ms
[error] #PID<0.353.0> running PhoenixChat.Endpoint terminated
Server: localhost:4000 (http)
Request: POST /api/users
** (exit) an exception was raised:
** (FunctionClauseError) no function clause matching in Ecto.Changeset.cast_key/1
@tdelam
tdelam / promises.md
Last active August 29, 2015 14:24 — forked from domenic/promises.md

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
For C#[##]-DW##-MP###[-D][d]
C\d\[\d{2}\]-[A-Z]W\d{2}-MP\d{3}\[-[A-Z]\]\[[a-z]\]
For B#[##]-FD###-FL###[-D][d]:
B\d\[\d{2}\]-F[A-Z]\d{3}-FL\d{3}\[-[A-Z]\]\[[a-z]\]
For T#[##]-MP###[-D][d]
T\d\[\d{2}\]-MP\d{3}\[-[A-Z]\]\[[a-z]\]
Characters in [ ] are optional
@tdelam
tdelam / gist:7769d4fa714a913da813
Last active August 29, 2015 14:16
Tracking user movement and display recommendations based on their likes
# Project: Catalogue fun
# Author: Trevor Delamorandiere,2012
#
import os
import base64
from django.conf import settings
from search.models import SearchTerm
ARCHFLAGS=-arch x86_64
Apple_PubSub_Socket_Render=/tmp/launch-P4hAVq/Render
CFLAGS=-Qunused-arguments
CPPFLAGS=-Qunused-arguments
DISPLAY=/tmp/launch-TfyrF7/org.macosforge.xquartz:0
GEM_HOME=/Users/trevor/.rvm/gems/ruby-2.0.0-p353
GEM_PATH=/Users/trevor/.rvm/gems/ruby-2.0.0-p353:/Users/trevor/.rvm/gems/ruby-2.0.0-p353@global
GREP_COLOR=1;32
GREP_OPTIONS=--color=auto --exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn
HOME=/Users/trevor
➜ bodhi git:(master) cat /Users/trevor/.rvm/log/1399059150_ruby-1.9.3-p545/configure.log
configure: WARNING: unrecognized options: --without-tcl, --without-tk
checking build system type... x86_64-apple-darwin13.1.0
checking host system type... x86_64-apple-darwin13.1.0
checking target system type... x86_64-apple-darwin13.1.0
checking whether the C compiler works... no
configure: error: in `/Users/trevor/.rvm/src/ruby-1.9.3-p545':
configure: error: C compiler cannot create executables
See `config.log' for more details
➜ ~ cat /Users/trevor/.rvm/src/ruby-1.9.3-p545/config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure --prefix=/Users/trevor/.rvm/rubies/ruby-1.9.3-p545 --with-opt-dir=/usr/local/opt/libyaml:/usr/local/opt/readline:/usr/local/opt/libksba:/usr/local/opt/openssl --without-tcl --without-tk --disable-install-doc --enable-shared
configure: WARNING: unrecognized options: --without-tcl, --without-tk
checking build system type... x86_64-apple-darwin13.1.0
checking host system type... x86_64-apple-darwin13.1.0
checking target system type... x86_64-apple-darwin13.1.0
checking whether the C compiler works... no
configure: error: in `/Users/trevor/.rvm/src/ruby-1.9.3-p545':
configure: error: C compiler cannot create executables
See `config.log' for more details
➜ src rvm install 1.9.3
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.9/x86_64/ruby-1.9.3-p545.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
==> Upgrading 3 outdated packages, with result:
libyaml 0.1.6, openssl 1.0.1g, readline 6.3.3
==> Upgrading libyaml
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libyaml-0.1.6.mavericks.bottle.tar.gz
######################################################################## 100.0%