Skip to content

Instantly share code, notes, and snippets.

_.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'},
'');
@iptpv
iptpv / x.js
Created November 11, 2016 15:57
component idea, booking com inspired
var L = {
};
L.alert = function() {
console.log($(this).html()+1);
};
L.cons = function() {
console.log($(this).html());
function asyncForeach(array, cb, stop) {
var index = 0;
function done() {
if (index > array.length - 1) {
return stop();
}
cb(array[index], index, done);
index++;
};
done();
@iptpv
iptpv / inherit.js
Created February 10, 2016 21:11
Yet another inherit library.
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) {
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];
$('img').each(function () {
var img = new Image();
img.onload = imageLoaded;
img.src = $(this).attr('src');
});
imageLoaded = function () {
};
@iptpv
iptpv / gist:f8ca0db895160c3bbf46
Created January 28, 2015 13:28
разбитие массива на определенное число массивов
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/
/* -- 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 &