Skip to content

Instantly share code, notes, and snippets.

View thedavidmeister's full-sized avatar

David Meister thedavidmeister

View GitHub Profile
(defn all+status!
"Get all ideas, with the status merged in."
[]
(let [statuses (into ["New"] (map :status (prod-pad.statuses/all!)))
ideas-with-status (map (fn [status] (map (fn [idea] (merge idea {:status status}))
(with-status! status)))
statuses)]
(flatten ideas-with-status)))
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
function clicked() {
clicked.counter = clicked.counter || 0;
clicked.counter++;
@thedavidmeister
thedavidmeister / gist:68cf53456c61c37a33331d06008c4940
Created November 26, 2016 05:45
Basic Hoplon integration with Garden
(ns styles.hoplon
(:require garden.compiler
hoplon.core))
(defmethod hoplon.core/do! :garden
[el _ v]
; Replace all the inline styles on an element with css generated by Garden.
; Obviously does not play nice with other methods of setting inline styles.
(let [vs (if (sequential? v) v [v])
css (garden.compiler/compile-style vs)]
@thedavidmeister
thedavidmeister / mixpanel-snippet.min.js
Created December 3, 2016 11:50
Mixpanel snippet sans HTML tags, script tag injection, init and token.
(function(e,a){if(!a.__SV){var b=window;try{var c,l,i,j=b.location,g=j.hash;c=function(a,b){return(l=a.match(RegExp(b+"=([^&]*)")))?l[1]:null};g&&c(g,"state")&&(i=JSON.parse(decodeURIComponent(c(g,"state"))),"mpeditor"===i.action&&(b.sessionStorage.setItem("_mpcehash",g),history.replaceState(i.desiredHash||"",e.title,j.pathname+j.search)))}catch(m){}var k,h;window.mixpanel=a;a._i=[];a.init=function(b,c,f){function e(b,a){var c=a.split(".");2==c.length&&(b=b[c[0]],a=c[1]);b[a]=function(){b.push([a].concat(Array.prototype.slice.call(arguments,
0)))}}var d=a;"undefined"!==typeof f?d=a[f]=[]:f="mixpanel";d.people=d.people||[];d.toString=function(b){var a="mixpanel";"mixpanel"!==f&&(a+="."+f);b||(a+=" (stub)");return a};d.people.toString=function(){return d.toString(1)+".people (stub)"};k="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charg
@thedavidmeister
thedavidmeister / auth0-mixpanel-alias.js
Last active December 4, 2016 10:05
Alias auth0 users in mixpanel, expects `MIXPANEL_TOKEN` to be set in auth0 and `mpDistinctID` to be sent in `state` as base64 encoded JSON
function (user, context, callback) {
// https://github.com/auth0/rules/blob/master/rules/signup.md
user.app_metadata = user.app_metadata || {};
var state64 = context.request.query.state || context.request.body.state;
// https://github.com/node-browser-compat/atob/blob/master/node-atob.js
var state = new Buffer(state64, 'base64').toString('binary');
var statep = JSON.parse(state);
// short-circuit if the user has already been aliased.
if (user.app_metadata.mp_aliased) return callback(null, user, context);
@thedavidmeister
thedavidmeister / calq-snippet.min.js
Last active December 5, 2016 13:03
calq embed snippet sans script tags, DOM manipulation and init/track calls
(function (e, t) { if (!t.__SV) { window.calq = t; t.init = function (e, o) { if (t.writeKey) return; t.writeKey = e; t._initOptions = o; t._execQueue = []; var m = "action.track action.trackSale action.trackHTMLLink action.trackPageView action.setGlobalProperty user.profile user.identify user.clear".split(" "); for (var n = 0; n < m.length; n++) { var f = function () { var r = m[n]; var s = function () { t._execQueue.push({ m: r, args: arguments }) }; var i = r.split("."); if (i.length == 2) { if (!t[i[0]]) { t[i[0]] = [] } t[i[0]][i[1]] = s } else { t[r] = s } }(); } }; t.__SV = 1 } })(document, window.calq || []);
@thedavidmeister
thedavidmeister / google-analytics-snippet.min.js
Created December 7, 2016 12:04
Google snippet sans script tags and api calls
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
@thedavidmeister
thedavidmeister / heap-snippet.min.js
Created December 9, 2016 06:03
Heap analytics snippet sans HTML tags, load call and DOM manipulation
window.heap=window.heap||[],heap.load=function(e,t){window.heap.appid=e,window.heap.config=t=t||{};for(var o=function(e){return function(){heap.push([e].concat(Array.prototype.slice.call(arguments,0)))}},p=["addEventProperties","addUserProperties","clearEventProperties","identify","removeEventProperty","setEventProperties","track","unsetEventProperty"],c=0;c<p.length;c++)heap[p[c]]=o(p[c])};
(ns pattern-lib.pattern
(:require [hoplon.core :as h]
camel-snake-kebab.core))
(defmacro pattern
[name desc f examples]
(list 'h/div
:class "pattern"
:id (camel-snake-kebab.core/->kebab-case-string name)
(ns tween.core
(:require [javelin.core :as j]
[hoplon.core :as h]))
; Not actually 0 but performance.now() returns values larger than the first
; frame of RAF, even before we've called RAF.
; https://stackoverflow.com/questions/38360250/requestanimationframe-now-vs-performance-now-time-discrepancy
(def t (j/cell 0))
(letfn [(frame [tick]
(reset! t tick)