A Pen by unclepotap on CodePen.
This file contains hidden or 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
_.reduceRight(_.compact(a.replace(/\n/g, '').split(' ')), function(res, el, i) { | |
return i%2 === 1 ? res + 'location /sp/' + el.replace(/;/, '') + '/ { return 302 http://': res + el + '; }\n'}, | |
''); |
This file contains hidden or 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 L = { | |
}; | |
L.alert = function() { | |
console.log($(this).html()+1); | |
}; | |
L.cons = function() { | |
console.log($(this).html()); |
This file contains hidden or 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 asyncForeach(array, cb, stop) { | |
var index = 0; | |
function done() { | |
if (index > array.length - 1) { | |
return stop(); | |
} | |
cb(array[index], index, done); | |
index++; | |
}; | |
done(); |
This file contains hidden or 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 extend = function(target, source) { | |
for (var i in source) { | |
if (source.hasOwnProperty(i)) { | |
target[i] = source[i]; | |
} | |
} | |
return target; | |
}; | |
var objectCreate = function(ParentProto, ChildProto) { |
This file contains hidden or 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 forms = ['вася', 'васи', 'васей']; | |
if (/1[1-4]$/.test(number)) { | |
return forms[2]; | |
} | |
if (/[2-4]$/.test(number)) { | |
return forms[1]; | |
} | |
if (/1$/.test(number)) { | |
return forms[0]; |
This file contains hidden or 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
$('img').each(function () { | |
var img = new Image(); | |
img.onload = imageLoaded; | |
img.src = $(this).attr('src'); | |
}); | |
imageLoaded = function () { | |
}; |
This file contains hidden or 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 data = [1, 2, 3, 4, 5, 6, 7, 8, 9], | |
columns = 3, | |
dataAr = []; | |
for (var colCount = 0, i = 0; colCount < data.length; colCount+=(data.length/columns), i++) { | |
dataAr[i] = data.slice(colCount, colCount + data.length/columns); | |
} | |
console.log(dataAr); | |
/** | |
* http://jsbin.com/jeqijolisa/1/ |
This file contains hidden or 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
/* -- Android webkit mobile optimizeLegibility bug -- | |
A noticeable rendering bug when using the | |
Cross-browser kerning-pairs & ligatures css | |
declaration (text-rendering: optimizeLegibility;) | |
where the anchor links are highlighted and set | |
just above the actual text. This makes it difficult | |
to touch activate the link properly. | |
Use Modernizr to detect for touch events & |