Skip to content

Instantly share code, notes, and snippets.

@seblambla
seblambla / mercator_projection
Last active August 29, 2015 14:15
Geographic coordinates to 2D x% and y% coords
function getCoordinates($lat, $lng){
$mapWidth = 1000; // change this value
$mapHeight = 1000; // change this value
$pi = pi();
// get x value
$c['x'] = ($lng+180)*($mapWidth/360);
// convert from degrees to radians
$latRad = $lat*$pi/180;
@seblambla
seblambla / getTotalLength.js
Created November 16, 2015 10:33
getTotalLength() equivalent for circle, rect, polygon and line shapes.
/*
Author: ZetCoby
http://stackoverflow.com/a/30376660/3708754
*/
var tools = {
/**
*
* Used to get the length of a rect
*
@seblambla
seblambla / videojs.sass
Created March 3, 2016 10:20
Video-js styles (sass syntax)
$base-font-size: 10px
$touch-device-font-size: 15px
// The main font color controls the color of the text and the icons (font icons)
$main-font-color: #cccccc
// e.g. rgb(255, 255, 255) or #ffffff
// The default color of control backgrounds is mostly black but with a little
// bit of blue so it can still be seen on all black video frames, which are
@seblambla
seblambla / getParameterByName.js
Created June 20, 2016 10:27
Get GET params in JS
// http://stackoverflow.com/a/901144
function getParameterByName(name, url) {
if (!url) url = window.location.href
name = name.replace(/[\[\]]/g, "\\$&")
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url)
if (!results) return null
if (!results[2]) return ''
return decodeURIComponent(results[2].replace(/\+/g, " "))
}
for file in `ls *.scss`;
do
n="$(echo $file | sed 's/^\(.*\).scss$/\1.sass/')";
sass-convert $file $n;
rm $file;
done
@seblambla
seblambla / mousewheel-event-polyfill.js
Created January 17, 2017 09:54
Cross-browsers mousewheel event polyfill
// creates a global "addWheelListener" method
// example: addWheelListener( elem, function( e ) { console.log( e.deltaY ); e.preventDefault(); } );
(function(window,document) {
var prefix = "", _addEventListener, onwheel, support;
// detect event model
if ( window.addEventListener ) {
_addEventListener = "addEventListener";
} else {