Skip to content

Instantly share code, notes, and snippets.

View jornki's full-sized avatar
🏠
Working from home

Jørn Kinderås jornki

🏠
Working from home
View GitHub Profile
@jornki
jornki / mixin.scss
Created November 7, 2012 20:01
SCSS and Compass retina sprites
@import "compass/reset";
@import "compass/utilities/sprites";
@import "compass/css3/background-size";
$icons-spacing: 5px;
$sprites : sprite-map("icons/*.png");
@mixin retina-sprite($name) {
$name : $name;
background-image: sprite-url($sprites);
@jornki
jornki / performance_test.js
Created November 11, 2012 18:26
JavaScript loop performance
var i = 500000, ar = [], startTime, duration, output = {};
while(i--) {
ar.push(i);
}
// jQuery
startTime = new Date().getTime();
$.each(ar, function(index, item) {
//
@jornki
jornki / SrcsetSimplePolyfill
Created February 10, 2014 17:11
A simple polyfill for enabling the «img srcset 2x» attribute in browsers which does not yet support it
SrcSetSimplePolyfill =
init : () ->
img = new Image()
if 'srcset' of img is no and (window.devicePixelRatio || 1) > 1
images = document.querySelectorAll('img');
for image in images
@swapImagSrc image
swapImagSrc : (image) ->
@jornki
jornki / SimpleTextEditor
Last active August 29, 2015 13:56
A simple text editor using content editable
# SimpleTextEditor by Jørn Kinderås 2014
# A simple demonstration of using Content Editable
SimpleTextEditor =
init: () ->
# Grab the main content holder
@contentHolder = document.querySelector '#editbox'
if not @contentHolder
throw new Error 'The editbox element has not been defined'