Skip to content

Instantly share code, notes, and snippets.

View luckyshot's full-sized avatar
🌍
xaviesteve.com

Xavi Esteve luckyshot

🌍
xaviesteve.com
View GitHub Profile
@luckyshot
luckyshot / gist:4770332
Created February 12, 2013 14:47
Load PrettyPrint plugin only if needed
// Load Prettyprint only if needed
if ($('.content pre').length > 0) {
$('.content pre').addClass('prettyprint');
$('head').append('<link href="/prettify.css" type="text/css" rel="stylesheet" /><script type="text/javascript" src="prettify.js"></script>');
prettyPrint();
}
@luckyshot
luckyshot / gist:4770337
Last active December 12, 2015 12:09
Add target blank and track in Google Analytics to outgoing links
// Add target blank and track outgoing links in Google Analytics
// Method 1 (recommended): Event delegation. Track as Event.
// 'click'
// element and class names (i.e. a.button)
// href value clicked
$('body').on('click', function( e ) {
var target = $(e.target);
if ( target.tag == 'A' )
{
@luckyshot
luckyshot / gist:4987211
Last active December 13, 2015 22:48
HTML Elements for theme testing Source: http://wordpress.com
<p>Below is just about every <abbr title="HyperText Markup Language">HTML</abbr> element you might want to use in your blog posts. Check the source code to see the many embedded elements within paragraphs.</p>
<hr />
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
@luckyshot
luckyshot / gist:4995633
Last active December 13, 2015 23:59
YouTube - Embed video with autoplay and no controls
<!-- Deprecated -->
<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/GUL8B3CPmmc&autoplay=1&controls=0&rel=0&showinfo=0&iv_load_policy=3&theme=light&modestbranding=1" width="601" height="338" id="player" style="visibility: visible;"></object>
<!-- New -->
<iframe width="560" height="315" src="https://www.youtube.com/embed/FV7wx01BGQk?controls=2&modestbranding=1&rel=0&showinfo=0&hl={{ config.lang }}" frameborder="0" allowfullscreen></iframe>
<!--
Documentation: https://developers.google.com/youtube/player_parameters
@luckyshot
luckyshot / gist:5005111
Created February 21, 2013 14:36
Google Analytics - Make full screen
document.getElementById('ID-headerPanel').style.display='none';
document.getElementById('ID-headerTabPanel').style.display='none';
document.getElementsByClassName('uI')[0].style.marginTop=0;
document.getElementById('ID-navToggle').click();
if (document.getElementsByClassName('ACTION-remove')[0]) {document.getElementsByClassName('ACTION-remove')[0].click();}
document.getElementById('ID-reportHeader-toolbarSection').style.display='none';
document.getElementById('ID-reportHeader-titleSection').style.display='none';
@luckyshot
luckyshot / is-touch.js
Last active December 14, 2015 16:29
Detect if is a touch device
/**
* TOUCH DEVICE
* Detects touch devices
* Usage: if (is_touch_device) { yes! }
*/
var is_touch_device = 'ontouchstart' in document.documentElement;
@luckyshot
luckyshot / gist:5147735
Last active December 14, 2015 20:59
Google Spreadsheets (Excel) - Nested IFs formula
=($C5*if(CZ25>3, if(CZ25>5,if(CZ25>10,if(CZ25>25,if(CZ25>30,32,16),8),4),2),1)
+$C5*if(CZ26>3, if(CZ26>5,if(CZ26>10,if(CZ26>25,if(CZ26>30,32,16),8),4),2),1)
+$C5*if(CZ27>3, if(CZ27>5,if(CZ27>10,if(CZ27>25,if(CZ27>30,32,16),8),4),2),1)
+$C5*if(CZ28>3, if(CZ28>5,if(CZ28>10,if(CZ28>25,if(CZ28>30,32,16),8),4),2),1)
+$C5*if(CZ29>3, if(CZ29>5,if(CZ29>10,if(CZ29>25,if(CZ29>30,32,16),8),4),2),1)
+$C5*if(CZ30>3, if(CZ30>5,if(CZ30>10,if(CZ30>25,if(CZ30>30,32,16),8),4),2),1)
+$C5*if(CZ31>3, if(CZ31>5,if(CZ31>10,if(CZ31>25,if(CZ31>30,32,16),8),4),2),1)
+$C5*if(CZ32>3, if(CZ32>5,if(CZ32>10,if(CZ32>25,if(CZ32>30,32,16),8),4),2),1)
+$C5*if(CZ33>3, if(CZ33>5,if(CZ33>10,if(CZ33>25,if(CZ33>30,32,16),8),4),2),1)
+$C5*if(CZ34>3, if(CZ34>5,if(CZ34>10,if(CZ34>25,if(CZ34>30,32,16),8),4),2),1)
@luckyshot
luckyshot / gist:5148188
Created March 12, 2013 23:54
jQuery - Attach event to parent delegating to child targets
$('#parent').click(function(e){
var target = $(e.target); // the child that fired the original click
// do stuff here
});
@luckyshot
luckyshot / gist:5263561
Created March 28, 2013 14:29
Disable copy paste in an input field
<input autocomplete="off" onpaste="return false">
@luckyshot
luckyshot / gist:5335507
Created April 8, 2013 09:26
CSS animation/transition
.box {
transition: all 0.2s ease;
animation: down-bump 0.4s ease;
}
.box:hover {
animation: up-bump 0.4s ease;
}
@keyframes up-bump {