Skip to content

Instantly share code, notes, and snippets.

View brentchow's full-sized avatar

Brent Chow brentchow

View GitHub Profile
@brentchow
brentchow / Keen IO and Stripe Revenue Metric Example.js
Last active April 6, 2017 17:38
Keen IO and Stripe - How to get the total volume of purchases after refunds and declined cards, and convert to dollars (Keen.Metric)
Keen.onChartsReady(function(){
// Create a Metric containing our total $ amount in Keen IO credit card transactions (to and from)
// Excludes: refund transactions from Stripe to card and declined cards
var myMetric = new Keen.Metric("Stripe_Event", {
analysisType: "sum",
targetProperty: "data.object.amount",
filters: [
{"property_name":"data.object.captured","operator":"eq","property_value":true},
{"property_name":"data.object.amount_refunded","operator":"eq","property_value":0}]
});
@brentchow
brentchow / Keen IO and Stripe Revenue Series Example.js
Created February 22, 2014 01:33
Keen IO and Stripe - How to get the total volume of purchases after refunds and declined cards, and convert to dollars (Keen.Series)
Keen.onChartsReady(function() {
// Create a Series containing our total $ amount in Keen IO credit card transactions (to and from)
// Excludes: refund transactions from Stripe to card and declined cards
var myMetric = new Keen.Series("Stripe_Event", {
analysisType: "sum",
timeframe:"this_month",
interval:"daily",
targetProperty: "data.object.amount",
filters: [
@brentchow
brentchow / Decrypt.js
Last active August 29, 2015 14:15
Trello JavaScript Test for Hiring New Developers - https://trello.com/jobs/developer
// My Solution
function decrypt(h) {
var s = '',
letters = 'acdegilmnoprstuw';
for(i = 7; i > 0; i--) {
var p = h % 37,
l = letters.charAt(p),
s = l + s,
h = (h - p)/37;
@brentchow
brentchow / Console Easter Egg
Created July 15, 2015 17:56
Appcues Console Trick
(function(w) {
if (w.chrome && w.console) {
// Console Easter Egg.
// TODO: Abstract this into a separate library.
var logoStyle = [
'margin: 10px 0',
'padding: 2px 3px 3px',
'color: transparent',
'background-image: url("http://appcues.com/images/logos/mark-angle.png")',
'background-repeat: no-repeat',