Kamil Ogórek kamilogorek
- Kraków, Poland
- Sign in to view email
- https://kamilogorek.com
View Pull url parameters
var parameters = (function (src) { | |
var params = {}, qryStr = src.split('?')[1]; | |
qryStr && $.each(qryStr.split('&'), function (i, p) { | |
ps = p.replace(/\/$/, '').split('='); | |
var k = ps[0].replace(/^\?/, ''); | |
params[k] = ps[1] || true; | |
}); | |
return params; | |
})(location.search); |
View Convert image to base64
with(document)with(i=querySelector('img'),createElement('canvas'))width=i.width,height=i.height,getContext('2d').drawImage(i,0,0),toDataURL() |
View Carousel iteration logic
// Items number | |
var items = elem.length; | |
// Any element containing data about current index | |
var current = elem.data('current'); | |
var next; | |
// Button directory | |
var direction = elem.data('dir'); | |
// Logic for calculating next items index | |
if (direction === 'next') { |
View Missed border on rotate
selector { | |
@include backface-visibility(hidden); | |
@include perspective(1000); | |
} |
View Characters encoding
function encodeString(str) { | |
return str.replace(/\\n/g, '\n').replace(/\\'/g, '\'').replace(/\\"/g, '\"').replace(/\\\\/g, '\\'); | |
} |
View Equal cells width
var cells = []; | |
var header = $('table').find('tr:first').find('th'); | |
var rows = $('table').find('tr').not(':first'); | |
header.each(function(i, val){ | |
cells.push($(val).width()); | |
}); | |
rows.each(function(i, val) { | |
var _this = this; |
View vim-tips
# Reindent whole file | |
gg=G |
View gist:6366596
window.changeURL = function(photo) { | |
// not HTML history API browsers | |
if ($('html').hasClass('ie8') || $('html').hasClass('ie9')) { | |
window.location = photo.url; | |
} | |
else { | |
var stateObj = { video: 'xfactor' }; | |
history.pushState(stateObj, photo.description, photo.url); | |
} | |
}; |
View renditions-sort.js
<script type="text/javascript"> | |
var fapiResponse = {{ albums[0].photos[0].images | json_encode | raw }}; | |
var renditions = []; | |
var ratios = {}; | |
for (key in fapiResponse) { | |
renditions.push(key.split('_retina')[0]); | |
} | |
renditions.map(function(rendition, i) { |
OlderNewer