Skip to content

Instantly share code, notes, and snippets.

View tomfuertes's full-sized avatar

Tom Fuertes tomfuertes

View GitHub Profile
@tomfuertes
tomfuertes / gas.core.js
Created October 18, 2013 16:15
GAS w/ dc.js
/**
* @preserve Copyright 2011, Cardinal Path and DigitalInc.
*
* GAS - Google Analytics on Steroids
* https://github.com/CardinalPath/gas
*
* @author Eduardo Cereto <[email protected]>
* Licensed under the GPLv3 license.
*/
(function(window, undefined) {
@tomfuertes
tomfuertes / gas-snippet.html
Last active December 25, 2015 21:39
How to include gas
<script>
var _gas = _gas || [];
_gas.push(['_setAccount', 'UA-YYYYYY-Y']); // REPLACE WITH YOUR GA NUMBER
_gas.push(['_setDomainName', '.mydomain.com']); // REPLACE WITH YOUR DOMAIN
_gas.push(['_trackPageview']);
_gas.push(['_gasTrackForms']);
_gas.push(['_gasTrackOutboundLinks']);
_gas.push(['_gasTrackMaxScroll']);
_gas.push(['_gasTrackDownloads']);
_gas.push(['_gasTrackYoutube', {force: true}]);
/**
* @preserve Copyright 2011, Cardinal Path and DigitalInc.
*
* GAS - Google Analytics on Steroids
* https://github.com/CardinalPath/gas
*
* @author Eduardo Cereto <[email protected]>
* Licensed under the GPLv3 license.
*/
!function(a,b){function c(){var a=this;a.version="1.11.0",a._accounts={},a._accounts_length=0,a._queue=F,a._default_tracker="_gas1",a.gh={},a._hooks={_addHook:[a._addHook]},a.push(function(){a.gh=new E})}function d(a){return a===_gas._default_tracker?"":a+"."}function e(b){if(_gas.debug_mode)try{console.log(b)}catch(c){}return a._gaq.push(b)}function f(a,b){if("string"!=typeof a)return!1;var c=a.split("?")[0];return c=c.split("."),c=c[c.length-1],c&&this.inArray(b,c)?c:!1}function g(){var a,b,c=0,d=0,e=G.getElementsByTagName("meta");for(a=0;a<e.length;a++)if("ga_trans"===e[a].name){if(b=e[a].content.split("^"),b.length<3)break;for(;b.length<8;)b.push("");_gas.push(["_addTrans",b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7]]),c++}else"ga_item"===e[a].name&&(b=e[a].content.split("^")
@tomfuertes
tomfuertes / social.haml
Created December 19, 2013 16:32
Social Sharing w/ no external requests (Bootstrap3 + FontAwesome)
%li
-# https://developers.facebook.com/docs/reference/dialogs/feed/#redirect
%a{:href => "https://www.facebook.com/sharer/sharer.php?u=#{u request.original_url}", :target=>"blank", :rel=>"external nofollow"}
%span.fa.fa-facebook.fa-2x
%span.text-hide Facebook
%li
-# http://stackoverflow.com/a/11212220/94668
%a{:href => "//pinterest.com/pin/create/button/?url=#{u request.original_url}", :target=>"blank", :rel=>"external nofollow"}
%span.fa.fa-pinterest.fa-2x
%span.text-hide Pinterest
@tomfuertes
tomfuertes / config.diff
Created February 9, 2014 17:47
uncss on a rails landing page in < 15 min (initial config steps in comments)
diff --git a/Gruntfile.js b/Gruntfile.js
index 53fe849..80ce14a 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -56,6 +56,16 @@ module.exports = function (grunt) {
max_jshint_notifications: 5
}
},
+ uncss: {
+ gettingStarted: {
@tomfuertes
tomfuertes / make-website.sh
Last active August 26, 2022 21:54
create an s3 bucket, config website serving, create cloudfront distribution, sync local dir
#!/usr/bin/env bash
# To run:
# $ brew uninstall s3cmd && brew install s3cmd --HEAD
# $ s3cmd --configure # fill in w/ amazon account vars
# $ cd path/to/local/static/site
# $ wget https://gist.githubusercontent.com/tomfuertes/9175005/raw/make-website.sh
# $ bash make-website.sh
#
# NOTE: cfcreate takes ~15 minutes to run on AWS.
@tomfuertes
tomfuertes / 0.result.md
Last active May 11, 2016 03:29
De-'Async Inject'ing Universal Analytics

De-'Async Inject' Universal Analytics

This gist applies the theory from Ilya Grigorik's Script-injected "async scripts" considered harmful on the default Universal Analytics snippet. TLDR place this above the CSS in the <head> of your document

<!-- Google Analytics Part 1: Creates window.ga, sets account, and queues pageview-->
<script>
  (function(e,t){e.GoogleAnalyticsObject=t;e[t]=e[t]||function(){
     (e[t].q=e[t].q||[]).push(arguments)};e[t].l=1*new Date})(t,"ga");
 ga('create', 'UA-XXXX-Y'); // REPLACE UA-XXXX-Y w/ YOUR ACCOUNT
@tomfuertes
tomfuertes / google-tag-manager.js
Last active August 29, 2015 14:03
Google Tag Manager & Optimizely
/* _optimizely_evaluate=force */ /*jshint curly:false*/
/**
* Curries "{experiment name}: {variation name}" to GTM
* via window.clearhead['ab{n}']
*/
var experimentId = 'TODO'; // experiment id
var chDimension = 'TODO'; // 1,2,3,4,5
// poll till optimizely's global exists
var timeout = setInterval(function () {
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
bar[foo?'doSomething':'doSomethingElse'](el);
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}