Skip to content

Instantly share code, notes, and snippets.

View sperand-io's full-sized avatar

Chris Sperandio sperand-io

  • Stripe
  • SF
View GitHub Profile
duo index.js > build.js
@sperand-io
sperand-io / command.js
Last active August 29, 2015 13:57
Squirt Backtick Command
(function(){
if(window.sq){
window.sq.closed && window.document.dispatchEvent(new Event('squirt.again'));
} else {
window.sq = {};
window.sq.userId = '--squirtUser--';
s = document.createElement('script');
s.src = 'http://www.squirt.io/bm/squirt.js';
document.body.appendChild(s);
}
@sperand-io
sperand-io / cookie.es6
Last active August 29, 2015 14:04 — forked from reinpk/cookie.js
@sperand-io
sperand-io / Makefile
Last active August 29, 2015 14:20
Example Duo Makefile
#
# Environment.
#
NODE := node --harmony
NODE_ENV ?= development
#
# Binaries
#
@sperand-io
sperand-io / index.js
Last active August 29, 2015 14:24
Get Emails of Users Interested in Raw Data from Zendesk
var includes = require('@ndhoule/includes');
var fold = require('@ndhoule/foldl');
var each = require('@ndhoule/each');
var ZD = require('node-zendesk')
var Batch = require('batch');
var batch = new Batch;
var zendesk = ZD.createClient({
username: /*usernamen*/,
token: /*token*/,
@sperand-io
sperand-io / README.md
Last active August 29, 2015 14:27 — forked from tmcw/README.md
Line Chart
@sperand-io
sperand-io / index.js
Last active September 2, 2015 22:16
Sending Some Traits to Some Tools But Not To Others!
// these are the trait keys you want to send to customer.io
var importantTraits = ['trait1', 'trait2', 'trait3'];
function identify(userId, traits) {
traits = extend({}, traits || {});
var matchingTraits = reduce(function(acc, val, key){
if (~importantTraits.indexOf(key)) acc[key] = val;
return acc;
@sperand-io
sperand-io / index.js
Last active October 30, 2015 17:10
Wootric -> Segment
analytics.ready(function() {
window.wootricSetttings.survey_callback = function survey_callback() {
analytics.identify({ last_wootric_surveyed_at: Math.round((testDate.getTime())/1000) });
};
window.wootricSetttings.decline_callback = function decline_callback() {
analytics.identify({ last_wootric_declined_at : Math.round((testDate.getTime())/1000) });
};
window.wootricSetttings.response_callback = function response_submitted_callback(score, comment) {
@sperand-io
sperand-io / applyFirst.es6
Last active October 31, 2015 21:25
<3 ES6
export default function applyFirst (fn, first) {
return (...args) => fn(first, ...args);
}
@sperand-io
sperand-io / index.es6
Last active November 5, 2015 03:19
Track Youtube Views By Visitor (Like Wistia!)
// download youtube API by constructing script tag and inserting to dom
const el = document.getElementsByTagName('script')[0];
const script = document.createElement('script');
script.src = 'https://www.youtube.com/iframe_api';
el.parentNode.insertBefore(script, el);
// take an existing youtube player <iframe>
// and decorates with a state change handler