This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//CANTOR PAIRING | |
/* Combines two integer values in a single one that can be reversed to the original ones */ | |
cantorPair = function(x, y) { | |
var z = ((x + y) * (x + y + 1)) / 2 + y; | |
return z; | |
}; | |
reverseCantorPair = function(z) { | |
var pair = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fisherYates = function( myArray ) { | |
var i = myArray.length, j, tempi, tempj; | |
if ( i == 0 ) return false; | |
while ( --i ) { | |
j = Math.floor( Math.random() * ( i + 1 ) ); | |
tempi = myArray[i]; | |
tempj = myArray[j]; | |
myArray[i] = tempj; | |
myArray[j] = tempi; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Function to generate random numeric token. Usefull to append it at the end of URLs we don't want to be cached by the browser. <img src="/path/image.png?XXXXXXX"> */ | |
var rand = function() { | |
return Math.random().toString(36).substr(2); // remove '0.' | |
}; | |
var token = function(char_num) { | |
var token = rand() + rand(); // make it longer | |
token = token.substr(0, char_num); | |
return token; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@media | |
only screen and (-webkit-min-device-pixel-ratio: 2), | |
only screen and ( min--moz-device-pixel-ratio: 2), | |
only screen and ( -o-min-device-pixel-ratio: 2/1), | |
only screen and ( min-device-pixel-ratio: 2), | |
only screen and ( min-resolution: 192dpi), | |
only screen and ( min-resolution: 2dppx) { | |
.image{ | |
background: url (myIMG@2x.png); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Paste into Firebug or Chrome Dev Tools console | |
// when viewing a page with multiple checkboxes. | |
(function(d) { | |
var input = d.getElementsByTagName('input'); | |
var i = input.length; | |
while (i--) { | |
if (input[i].type === 'checkbox') { | |
input[i].setAttribute('checked', 'checked'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Responsive Pseudo-grid | |
We define here the cols width that will be asigned to the containers. | |
Include this mixins in the corresponding semantic container this way. | |
.container { | |
@include col-50(%3, %3); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><![endif]--> | |
<!--[if lt IE 7 ]> <html lang="<%= ::I18n.locale %>" class="no-js ie6"> <![endif]--> | |
<!--[if IE 7 ]> <html lang="<%= ::I18n.locale %>" class="no-js ie7"> <![endif]--> | |
<!--[if IE 8 ]> <html lang="<%= ::I18n.locale %>" class="no-js ie8"> <![endif]--> | |
<!--[if IE 9 ]> <html lang="<%= ::I18n.locale %>" class="no-js ie9"> <![endif]--> | |
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="<%= ::I18n.locale %>" class="no-js"> <!--<![endif]--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin font-face($font-family, $file-path, $weight: normal, $style: normal) { | |
@font-face { | |
font-family: $font-family; | |
font-weight: $weight; | |
font-style: $style; | |
src: font-url('#{$file-path}.eot'); | |
src: font-url('#{$file-path}.eot?#iefix') format('embedded-opentype'), | |
font-url('#{$file-path}.woff') format('woff'), | |
font-url('#{$file-path}.ttf') format('truetype'), | |
font-url('#{$file-path}.svg##{$font-family}') format('svg'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$.fn.plugin = function() { | |
return this.each(function() { | |
var $this = $( this ); | |
if ( !$this.data('plugin') ) { | |
$this.data( 'plugin', new Plugin(this) ); | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Send a form with a link with data-form="#form_id" | |
/ You can define params="name,value name,value" | |
/ All params will be append to the form as hidden inputs before send it | |
*/ | |
$('body').on('click', '[data-form]', function(e) { | |
e.preventDefault(); | |
var el = $(this), | |
form = $(el.data('form')), | |
params; |
OlderNewer