Skip to content

Instantly share code, notes, and snippets.


Tom Zurkan thomaszurkan-optimizely

  • Optimizely
View GitHub Profile
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 = '';
const options = {
hostname: '',
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'];
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\":\"\",\"cdn_url\":\"\"}}",
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);
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();