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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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 / iframeSnippet.html
Last active January 6, 2022 22:56
Using Segment via iFrame Communication
<script>
/**
* Provides a fake analytics object that sends all calls to the parent window for processing
*/
var analytics = (function() {
var eventQueue = [];
// Send the events to the frame if it's ready.
function flush(method, args) {
while (eventQueue.length) {
@sperand-io
sperand-io / tagManager.js
Last active April 1, 2019 18:36
Piggybacking Segment Events for Ad-Hoc Conversion Pixels
/**
* Pixel Loader.
* It will make the http request on construction, no need to dom insert.
*/
const loadPixel = (src, fn=()=>{}) => ({
...new Image,
onload() { fn() },
height: 1,
@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 / formIdentify.js
Last active August 1, 2018 18:52
Squarespace Form Submission -> Segment "Identify"
/**
* helper function to take the form and
* get back a js object with field/value mappings
* ignoring submit fields and fields whose name we can't ascertain
*/
function serialize(form){
return Array.prototype.slice.call(form.elements)
.filter(isInputElement)
.filter(isNotSubmit)
@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.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 / index.html
Created July 18, 2015 02:31
Segment <-> Vimeo Tracking
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=700,maximum-scale=1.0,user-scalable=yes">
<title>Vimeo Froogaloop API Playground</title>
<script>
/* Don't forget your analytics.js snippet :) */
</script>
</head>
<body>