Skip to content

Instantly share code, notes, and snippets.

View ortense's full-sized avatar
💀
Coding...

Marcus Ortense ortense

💀
Coding...
View GitHub Profile
@ortense
ortense / analytics.js
Created May 4, 2014 00:51
Código padrão do universal analytics
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXX-Y', 'auto');
ga('send', 'pageview');
@ortense
ortense / google-analytics-track-scroll-end.js
Last active August 29, 2015 14:00
Google Analytics Track Scroll End
(function($){
var $window = $(window),
$document = $(document),
scrollEnd = function(){
if(($window.height() + $window.scrollTop() + 20) >= $document.height()){
ga("send", "event", "scroll", document.location.pathname, "100%");
$window.off("scroll", scrollEnd);
}
};
$window.on("scroll", scrollEnd);
@ortense
ortense / google-analytics-track-external-links.js
Created May 5, 2014 00:58
Google Analytics Track External Links
/* ==|=======================================================================
Grid // http://semantic.gs/
========================================================================== */
/* Altere estes valores de acordo com a largura das colunas,
largura das margens e o número de colunas do seu grid.*/
@column-width: 60;
@gutter-width: 20;
@columns: 12;

The HTML5 Amount of Awesomeness

Rainbox Vomit

A collection of freaking awesome HTML5 demos (work in progress).

WebGL

@ortense
ortense / google-analytics-track-youtube.coffee
Last active August 29, 2015 14:01
Google Analytics Track Youtube Interactions
do (window, document) ->
iframes = document.getElementsByTagName("iframe")
youTubeIframes = []
regex = /.*youtube.*\/(embed|v)\/(.+)\?.*/
window.youtube = window.youtube or {}
youtube.movies = youtube.movies or {}
category = youtube.movies.category = if youtube.movies.category then youtube.movies.category else "youtube"
@ortense
ortense / bitLy.js
Created May 13, 2014 16:31
Function to shorten url by bit.ly
/**
* @function bitLy
* @param {string} long_url - Long URL to shorten
* @param {function} func - receives short url
*/
function bitLy(long_url, func){
$.getJSON(
"http://api.bitly.com/v3/shorten?callback=?",
{
"format": "json",
@ortense
ortense / redirect.jsp
Created May 13, 2014 20:45
Redirect page in JSP
<%
String requestURL = request.getRequestURL().toString();
String queryString = request.getQueryString();
String redirectUrl = "http://redirect.to/path";
if (queryString != null) redirectUrl += "?" + queryString;
response.setStatus(301);
response.setHeader( "Location", redirectUrl);
response.setHeader( "Connection", "close" );
%>
@ortense
ortense / google-analytics-track-twitter.js
Created May 27, 2014 14:58
Google Analytics Events for Twitter plugin interactions
(function(){
/**
* Twitter interaction
* @see https://dev.twitter.com/docs/tfw/events
*/
var category = 'social',
action = 'twitter';
if(twttr && twttr.events && twttr.events.bind){
twttr.events.bind('tweet', function (event) {
@ortense
ortense / constructor.js
Created July 16, 2014 18:18
My JS Constructor/Class template
var Constructor_name = (function(){
/** CONSTRUCTOR **/
function Constructor_name (params) {
// body...
}
/** PRIVATE METHODS **/