Skip to content

Instantly share code, notes, and snippets.

View snorpey's full-sized avatar

georg fischer snorpey

View GitHub Profile
@snorpey
snorpey / get-transition-duration.js
Last active December 26, 2015 23:28
Get the CSS transition duration of a DOM element, cross-browser. without jQuery.
// based on http://stackoverflow.com/a/13008597
function getTransitionDuration ( element, with_delay )
{
var prefixes = ' webkit moz ms o khtml'.split( ' ' );
var result = 0;
var duration, delay, prefix;
for ( var i = 0; i < prefixes.length; i++ )
{
prefix = prefixes[i] + '-';
@snorpey
snorpey / serialize-url.js
Last active August 29, 2015 13:57
converts an object to an url parameter string
/*global define*/
define(
function ()
{
// serializeURL({foo:'bar',one:'two'}) => '?foo=bar&one=two'
// serializeURL({foo:'bar',one:'two'}, 'prefix') => '?prefix[foo]=bar&prefix[one]=two'
function serializeURL( obj, prefix )
{
var str = [ ];
@snorpey
snorpey / load-file.js
Last active August 29, 2015 14:00
AMD module for loading a file asynchronously. It also stores the file in the browsers local storage for quicker access. I mostly use it for loading GLSL shader files
/*global define*/
/*
AMD module for loading files asynchronously. It also stores the contents of the files
in the browsers local storage for quicker access. I mostly use it for loading GLSL
shader files. Note: This has not been tested extensively, so use with caution.
MIT License
*/
define(
function()
{
@snorpey
snorpey / load-image.js
Created April 23, 2014 08:06
AMD module that loads an image. Caches images.
/*global define*/
/*
AMD module that loads an image. Caches images.
Note: this code has not been tested extensively. Use with caution.
MIT License
*/
define(
function ()
{
var images = { };
@snorpey
snorpey / easing.css
Created May 8, 2014 09:15
A collection of CSS easing functions
.easing-linear {
transition-timing-function: linear;
}
.easing-ease {
transition-timing-function: ease;
}
.easing-easeIn {
transition-timing-function: ease-in;
@snorpey
snorpey / css-easing-functions.js
Created May 8, 2014 09:20
An AMD module with CSS easing functions
/*global define*/
define(
function ()
{
return {
linear: 'linear',
ease: 'ease',
easeIn: 'ease-in',
easeOut: 'ease-out',
easeInOut: 'ease-in-out',
@snorpey
snorpey / circle rotated rectangle collision.js
Last active March 1, 2024 13:43
Calculate collision between circle and rotated rectangle
// Ported to JavaScript from
// http://www.migapro.com/circle-and-rotated-rectangle-collision-detection/
//
// An example:
// var circle: { x: 20, y: 10, radius: 20 };
// var rect: { x: 30, y: 30, width: 100, height: 100, rotation: Math.PI / 2 };
// collideCircleWithRotatedRectangle( circle, rect );
// // returns true.
//
//
@snorpey
snorpey / admin.html
Created February 12, 2015 23:05
Spacebrew Disconnect Test
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Admin</title>
<style>body{font-family:sans-serif;padding:50px;}.is-connected{background-color:green}</style>
</head>
<body>
<h1>ADMIN</h1>
<script src="spacebrew-1.4.1.js"></script>
@snorpey
snorpey / 00_readme.md
Last active September 27, 2015 10:35
B5 am Feiertag Downloader
@snorpey
snorpey / index.html
Last active December 5, 2015 21:10
localforage error in worker in safari
<!doctype html>
<script>
var worker = new Worker( 'localforageworker.js' );
</script>