Skip to content

Instantly share code, notes, and snippets.

View weilandia's full-sized avatar
🏄‍♂️
workinnn

Nick Weiland weilandia

🏄‍♂️
workinnn
View GitHub Profile

Test

# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
# frozen_string_literal: true
require "pry"
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Activate the gem you are reporting the issue against.
# frozen_string_literal: true
require "pry"
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Activate the gem you are reporting the issue against.
@weilandia
weilandia / laptop.local
Created May 1, 2018 00:51
airbo laptop
#!/bin/sh
brew bundle --file=- <<EOF
cask "slack"
cask "google-chrome"
cask "google-chrome-canary"
cask "atom"
cask "firefox"
cask "mongodb-compass"
cask "ngrok"
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end
Capybara.register_driver :headless_chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { args: %w(headless disable-gpu) }
)
Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities)
{
"name": "sendgrid-webhook-to-mixpanel-lambda",
"version": "1.0.0",
"description": "A lambda function for tracking SendGrid events in Mixpanel",
"main": "index.js",
"license": "MIT",
"dependencies": {
"mixpanel": "^0.7.0",
"serverless-http": "^1.5.2"
},
service: sendgrid-webhook-to-mixpanel-lambda
provider:
name: aws
runtime: nodejs6.10
stage: ${opt:stage}
region: us-east-1
profile: your-profile
environment:
MIXPANEL_TOKEN: ${file(./serverless.env.yml):${self:provider.stage}.MIXPANEL_TOKEN}
const serverless = require('serverless-http');
const Mixpanel = require('mixpanel');
const mixpanel = Mixpanel.init(process.env.MIXPANEL_TOKEN);
function handler(event, context, callback) {
let body = JSON.parse(event.body);
let eventsTracked = 0;
body.forEach((sendGridEvent) => {
mixpanel.track('SendGrid: ' + sendGridEvent.event, sendGridEvent);
class Api::SendgridEventsController < Api::ApiController
def create
events = Integrations::SendgridEventsParser.new.track_events(params["_json"])
render json: events.to_json
end
end
class Integrations::SendgridEventsParser
def track_events(events)
events.each { |e|