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
rm -rf \r\n |
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 arr = [ | |
['a', 'b', 'c', 'd', 'a'], | |
['c', 'd', 'e'], | |
['b', 'c', 'd', 'd'] | |
]; | |
var arr = arr.shift().reduce(function(res, v) { | |
if (res.indexOf(v) === -1 && arr.every(function(a) { | |
return a.indexOf(v) !== -1; | |
})) res.push(v); |
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 idleTime = 0; | |
$(document).ready(function () { | |
var idleInterval = setInterval(timerIncrement, 60000); // 1 minute | |
$(this).mousemove(function (e) { | |
idleTime = 0; | |
}); | |
$(this).scroll(function (e) { | |
idleTime = 0; | |
}); | |
$(this).keypress(function (e) { |
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
<div class="parallax" data-ratio="<?php $s = getimagesize("parallax.jpg"); echo round($s[0]/$s[1],2); ?>" data-speed="0.5" > | |
<span>test</span> | |
<img class="i" src="parallax.jpg" alt="" /> | |
</div> |
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
/* hiding option elements with $('option').hide() does not work with IE, instead use this strategy */ | |
var og = $('select').html(); | |
$('select').change(function() { | |
$('select').html(og); | |
$('select option[myfilter=1]').remove(); | |
}); |
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
array = $.grep(array, function(v, k){ return $.inArray(v ,array) === k; }); |
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
<span class="counter">150</span> | |
<textarea data-maxlength="150"></textarea> |
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
See github |
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
$.when( | |
$('.box').animate({ opacity: 0 }, 1000, 'linear'), | |
$.post( $(this).closest('form').attr('action'), $(this).closest('form').serialize() ) | |
).then(function () { | |
alert('both finished'); | |
}); |
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 d1 = new $.Deferred(); | |
var d2 = new $.Deferred(); | |
$.when(d1, d2).then(function(r1, r2) { | |
console.log(r1); | |
console.log(r2); | |
alert('done'); | |
}); | |
$.get(href1, function(data) { d1.resolve( data ); }) | |
$.get(href2, function(data) { d2.resolve( data ); }) |