Skip to content

Instantly share code, notes, and snippets.

View Smuliii's full-sized avatar

Samuli Saarinen Smuliii

View GitHub Profile
@Smuliii
Smuliii / gist:6d0a59056e4976b37136
Created March 18, 2015 11:03
Convert ems to pixels
/**
* Convert ems to pixels
*
* @param {Number|String} value
* @param {Boolean} [withUnit]
* @return {Number|String}
*/
function convertEmToPx( value, withUnit ) {
if( typeof value !== 'undefined' && value )
@Smuliii
Smuliii / gist:c3c5c801cc222b410211
Created March 18, 2015 11:03
Convert pixels to ems
/**
* Convert pixels to ems
*
* @param {Number|String} value
* @param {Boolean} [withUnit]
* @return {Number|String}
*/
function convertPxToEm( value, withUnit ) {
if( typeof value !== 'undefined' && value )
@Smuliii
Smuliii / gist:774e677442d90b34924b
Last active August 29, 2015 14:14
Simple carousel
;(function( $, window, document, undefined ) {
'use strict';
var pluginName = 'simpleCarousel',
defaults = {
autoPlay : false,
circular : false,
className : 'carousel',
fullWidth : false,
@Smuliii
Smuliii / gist:73a22fdb8e9dcc229524
Created October 7, 2014 08:12
Calculate distance between two points
/**
* Calculate distance between two points. Credits to {@link http://www.movable-type.co.uk/scripts/latlong.html|Chris Veness}
*
* @param {Number|String} lat1 Latitude of point 1 in decimal degrees
* @param {Number|String} lon1 Longitude of point 1 in decimal degrees
* @param {Number|String} lat2 Latitude of point 2 in decimal degrees
* @param {Number|String} lon2 Longitude of point 2 in decimal degrees
* @return {Number} The distance between the points in kilometers
*/
function calculateDistance( lat1, lon1, lat2, lon2 ) {
@Smuliii
Smuliii / gist:8431834e2d02794879ad
Last active August 29, 2015 14:07
Simple localStorage script
/**
* Set and get localStorage
*
* @param {String} key
* @param {Boolean} [sessionOnly]
* @return {Object}
*/
var Cache = function( key, sessionOnly ) {
var now = new Date().getTime();
/**
* Detect swiping
*/
;(function( $, window, document, undefined ) {
var pluginName = 'detectSwipe',
defaults = {
direction : '',
minLength : 35,
onStart : function( direction, length ) {},
@Smuliii
Smuliii / gist:6ebe78551fed9bc21834
Last active August 29, 2015 14:02
Test if browser supports a CSS property
/**
* Test if browser supports a CSS property
*
* @param {String} property
* @param {Array} [prefixes]
* @param {Function} [callback]
* @return {Boolean|Function}
*/
function supportsCSSProperty( property, prefixes, callback ) {