Skip to content

Instantly share code, notes, and snippets.

Kamil Ogórek kamilogorek

Block or report user

Report or block kamilogorek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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
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, '\\');
}
@kamilogorek
kamilogorek / Equal cells width
Created May 8, 2013
Equal cells width within table columns
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;
@kamilogorek
kamilogorek / Navigation icons
Created May 8, 2013
Navigation icons with scalable sprite image
View Navigation icons
@mixin control-icon($dir, $size:76px) {
$icons-count: 4;
width: $size;
height: $size;
display: inline-block;
background: url(../img/ico-controls.png);
background-size: ($size*2) ($size*$icons-count);
background-repeat: no-repeat;
cursor: pointer;
@kamilogorek
kamilogorek / vim-tips
Created May 19, 2013
Useful vim commands
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);
}
};
@kamilogorek
kamilogorek / renditions-sort.js
Last active Dec 22, 2015
Sorting renditions ratio
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) {
You can’t perform that action at this time.