Skip to content

Instantly share code, notes, and snippets.

View eduardocereto's full-sized avatar
💩

Eduardo Cereto Carvalho eduardocereto

💩
View GitHub Profile
@eduardocereto
eduardocereto / ga-track-outbound.js
Last active July 16, 2022 17:19
Outbound Link Tracking
(function(){
// Provides a plugin name and constructor function to analytics.js. This
// function works even if the site has customized the ga global identifier.
function _providePlugin(pluginName, pluginConstructor) {
var ga = window[window['GoogleAnalyticsObject'] || 'ga'];
if (ga) ga('provide', pluginName, pluginConstructor);
}
// Creates the plugin to tag outbound link
function outboundConstructor(tracker, config){
@eduardocereto
eduardocereto / get_top_domain.js
Created July 3, 2012 21:18
Always return top level domain
/**
* First domain where cookies can be set by the browser.
*/
function get_top_domain(){
var i,h,
weird_cookie='__top_level=cookie',
hostname = document.location.hostname.split('.');
for(i=hostname.length-1; i>=0; i--) {
h = hostname.slice(i).join('.');
document.cookie = weird_cookie + ';domain=.' + h + ';';
@googleanalyticsresoneo
googleanalyticsresoneo / ga-addthis.html
Last active October 5, 2015 22:27
AddThis and Google Analytics integration Async Syntax
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!--
AddThis integration with Google Analytics Async - (c) 2013 analytics (chez) resoneo (point) com
https://gist.github.com/googleanalyticsresoneo/2887422
see http://support.addthis.com/customer/portal/articles/1293805-using-addthis-asynchronously
@hrldcpr
hrldcpr / tree.md
Last active April 15, 2024 15:27
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@cowboy
cowboy / jquery.ba-detach.js
Created May 18, 2011 12:54
jQuery Detach+: Improve .detach to allow optional reattaching!
/*!
* jQuery Detach+ - v0.1pre - 5/18/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($){
@eduardocereto
eduardocereto / cb_addEventListener.js
Created May 4, 2011 17:45
a cross-browser implementation of addEventListener/AttachEvent without external dependencies
/**
* Cross Browser helper to addEventListener.
*
* @param {HTMLElement} obj The Element to attach event to.
* @param {string} evt The event that will trigger the binded function.
* @param {function(event)} fnc The function to bind to the element.
* @return {boolean} true if it was successfuly binded.
*/
var cb_addEventListener = function(obj, evt, fnc) {
// W3C model
@googleanalyticsresoneo
googleanalyticsresoneo / google_image.html
Created May 2, 2011 15:04
Détection des mots clef pour le trafic en provenance de Google Image
<!-- exemple de referral depuis le 22 juillet 2011
http://www.google.fr/imgres?q=resoneo&um=1&hl=fr&sa=N&biw=1260&bih=832&tbm=isch&tbnid=oHqMFLKPHlmBuM:&imgrefurl=http://www.boitedeveille.fr/tag/resoneo/&docid=Hy5kqj7oMth2tM&w=191&h=82&ei=9kU4TtyKGcOs8gOq--z7Ag&zoom=1&iact=hc&vpx=602&vpy=176&dur=8629&hovh=65&hovw=152&tx=64&ty=32&page=1&tbnh=65&tbnw=152&start=0&ndsp=23&ved=1t:429,r:2,s:0
-->
<script type="text/javascript">
// now as a standard syntax
_gaq.push(['_addOrganic', 'google', 'q', true, 'google images', '/imgres?']);
</script>