Skip to content

Instantly share code, notes, and snippets.

<!-- Ajouter le script froogaloop à la page -->
<script src="//f.vimeocdn.com/js/froogaloop2.min.js"></script>
var the_timer;
window.addEventListener('resize', function(){
clearTimeout(the_timer);
the_timer = setTimeout(function(){
console.log('resized');
}, 75);
});
window.ga_debug = {trace: true};
(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_debug.js','ga');
ga('create', 'UA-XXXX-Y');
ga('send', 'pageview');
@ethyde
ethyde / detect-google-universal-analytics.js
Created October 8, 2014 07:37
Detecting Google Universal Analytics, even with adblock/ghostery
if(window.ga && ga.create) {
// Do you ga stuff
ga('send', 'pageview');
}
;(function( window, document, $, undefined ) {
'use strict';
var DEMO = DEMO || {};
DEMO.defaultOptions = {
newFontSize : '20px',
onSetup : null,
onAfterAnimation: null
};
@ethyde
ethyde / async.js
Last active August 29, 2015 14:07
Optimised async loading of cross-domain scripts See also : http://css-tricks.com/thinking-async/
// source : https://gist.github.com/necolas/1025811
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
@ethyde
ethyde / jquery-ajax-deffered.js
Last active August 29, 2015 14:07
jQuery Ajax with deffered Object (jQuery 1.9).
var jqxhr = $.ajax({
beforeSend: function(){
console.log('Before send request');
},
dataType: 'json',
url: 'json.json'
})
.done(function( data, textStatus, jqXHR ) {
var $context = $(document.getElementById('content')),
@ethyde
ethyde / Gruntfile.js
Last active August 29, 2015 14:07
Grunt base config
/**
* @fileOverview Gruntfile tasks. These tasks are intended to help you when modifying the template. If you are
* just using the template, don't sweat this stuff. To use these tasks, you must install grunt, if you haven't already,
* and install the dependencies. All of this requires node.js, of course.
*
* Install grunt:
*
* npm install -g grunt-cli
*
* Then in the directory where you found this file:
@ethyde
ethyde / javascript-for-loop.js
Created September 30, 2014 15:15
How to use javacript "for loop".
for(start value; condition; increment){
//code that will be executed over and over
}
// iterate 5 times use it for count loop
for(var i=0; i < 5; i++){
console.log("The value of i is: " + i + " <br />");
}
// increment by 2 instead of 1
for(var i=0; i < array.length; i += 2){
console.log(i + "<br />");
// Use $.extend() to copy existing functionality
var demobox = $('#' + id);
demobox.empty();
var forms = {};
forms.enquiry = {
email: 'enquiries@domain.com',
sendForm: function () {
//code which sends email
demobox.append('sending email to: ' + this.email + '...' + '<br>');