Skip to content

Instantly share code, notes, and snippets.

Tom Zurkan thomaszurkan-optimizely

Block or report user

Report or block thomaszurkan-optimizely

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thomaszurkan-optimizely
thomaszurkan-optimizely / UserAttribute.swift
Created Aug 9, 2019
A swift data object with a generic field
View UserAttribute.swift
struct UserAttribute: Codable, Equatable {
// MARK: - JSON parse
var name: String?
var type: String?
var match: String?
var value: Any?
}
View sendWebhook.js
function sendWebhook(data, done) {
var url = 'https://hooks.slack.com/services/LONG_UNIQUE_KEY';
const options = {
hostname: 'hooks.slack.com',
protocol: 'https:',
//port: 80,
path: '/services/LONG_UNIQUE_KEY',
method: 'POST',
headers: {
'Content-Type': 'application/json'
View secret_key.js
const crypto = require('crypto');
const hmac = crypto.createHmac('sha1', process.env.SECRET_KEY);
let hubHeader = event.headers['X-Hub-Signature'];
hmac.update(event.body);
let secretCompare = 'sha1=' + hmac.digest('hex');
console.log(secretCompare + ' == ' + hubHeader, secretCompare == hubHeader);
View json-segment.js
"body": "{\"project_id\":1234,\"timestamp\":1468447113,\"event\":\"project.datafile_updated\",\"data\":{\"revision\":1,\"origin_url\":\"https://optimizely.s3.amazonaws.com/json/1234.json\",\"cdn_url\":\"https://cdn.optimizely.com/json/1234.json\"}}",
View ex1.js
case 'POST':
let body = JSON.parse(event.body);
let projectId = body['project_id'];
let url = body['data']['cdn_url'];
console.log(‘project url:’, url);
break;
@thomaszurkan-optimizely
thomaszurkan-optimizely / index.js
Created Jul 30, 2018
Using AWS Lambda with Optimizely Web hooks for Project Management
View index.js
'use strict';
console.log('Loading function');
const http = require('https');
const doc = require('dynamodb-doc');
const dynamo = new doc.DynamoDB();
You can’t perform that action at this time.