Skip to content

Instantly share code, notes, and snippets.

$(function() {
//callback we must supply to the widget to interact with our server-side code
//must take 3 parameters: email, fingerprint, and app_code
//must return a jQuery POST request object
var callback = function(email, fingerprint, kickbox_app_code){
return $.post( "/authenticate", {
email: email,
fingerprint: fingerprint,
kickbox_app_code: kickbox_app_code,
@brandonmwest
brandonmwest / node+ra.md
Last active June 21, 2017 15:36
RA + Node.js tutorial draft

Introduction

Today we're going to build a node.js application to collect email addresses using Kickbox. We'll be using Express and Request on the server side, and jQuery on the client.

We'll be using Glitch during this tutorial, because it provides an environment, editor, and hosting in one convenient package. There's an example of the completed project too. If you want to follow along in your own environment, all of the code will work.

What is Recipient Authentication?

Recipient Authentication makes it easy to collect email addresses the right way. We handle account activation, double email opt-in subscriptions, and password resets. We make sure the email gets delivered, send drip reminders, expire old links, handle opt-outs, and automatically add authenticated addresses to your email service provider or marketing platform.

{
"personalizations": [{
"to": [{
"email": "anna@example.com"
}],
"cc": [{
"email": "bill@example.com"
}, {
"email": "connie@example.com"
}, {
{
"from": {
"name": "B West",
"email": "brandon@sendgrid.com"
},
"subject": "Mail v3 test",
"personalizations": [{
"to": [{
"name": "gYDXLV jeZLCy0VdiuU",
"email": "DuxWsA@sink.sendgrid.net"
/code {
"from": {
"name": "B West",
"email": "brandon@sendgrid.com"
},
"subject": "Mail v3 test",
"personalizations": [{
"to": [{
"name": "{{random_string(6)}} {random_string(12)}}",
"email": "{{random_string(6)}}@example.com"
$ ack MANDRILL_APP
models/email.rb
186: user_name: ENV['MANDRILL_USERNAME'],
187: password: ENV['MANDRILL_APIKEY'],
{
"email"=>"john.doe@sendgrid.com",
"sg_event_id"=>"VzcPxPv7SdWvUugt-xKymw",
"sg_message_id"=>"142d9f3f351.7618.254f56.filter-147.22649.52A663508.0",
"timestamp"=>1386636112, "smtp-id"=>"<142d9f3f351.7618.254f56@sendgrid.com>",
"event"=>"processed",
"category"=>["category1", "category2", "category3"],
"id"=>"001",
"purchase"=>"PO1452297845",
"uid"=>"123456"
@brandonmwest
brandonmwest / webhook.rb
Last active August 29, 2015 14:15
Log a JSON payload in Sinatra
post '/event' do
status 204 #successful request with no body content
request.body.rewind
request_payload = JSON.parse(request.body.read)
#append the payload to a file
File.open("events.txt", "a") do |f|
f.puts(request_payload)
end
@brandonmwest
brandonmwest / no_tables.rb
Last active August 29, 2015 14:03
Convert tables to {% parameters %} liquid blocks
require 'rubygems'
require 'json'
require 'nokogiri'
require 'nokogiri-pretty'
require 'iconv'
require 'fileutils'
html_files = File.join("/Users/brandonwest/SendGrid/docs/source/API_Reference", "**", "*.{md,html}")
Dir.glob html_files do |html_file|
@brandonmwest
brandonmwest / html2markdown.rb
Created July 2, 2014 17:25
convert jekyll html with custom liquid tags and codeblocks to well-structured markdown
require 'rubygems'
require 'json'
require 'nokogiri'
require 'nokogiri-pretty'
require 'iconv'
require 'pandoc-ruby'
require 'fileutils'
#convert HTML to markdown
html_files = File.join("/Users/brandonwest/SendGrid/docs/source", "**", "*.html")