Skip to content

Instantly share code, notes, and snippets.

@mckamey
mckamey / requestAnimationFrame.js
Created October 2, 2012 01:19 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
// perf improvements by Stephen McKamey
(function(window) {
'use strict';
@mckamey
mckamey / bezier.js
Created September 25, 2012 16:35
JavaScript port of Webkit CSS cubic-bezier(p1x.p1y,p2x,p2y) and various approximations
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
@mckamey
mckamey / index.html
Created September 20, 2012 17:48
Mobile Webkit reflow issue repro
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Mobile Webkit reflow issue</title>
<meta name="viewport" id="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<!doctype html><link rel="stylesheet" href="http://codepen.io/stylesheets/css/normalize.css"><style>
html {
background-image: linear-gradient(#8b9da9, #fff6e4);
box-shadow: inset 0 0 100px hsla(0,0%,0%,.3);
min-height: 100%;
}
body {
background-color: #082746;
background-image: linear-gradient(20deg, transparent 67%, hsla(0,0%,100%,.05) 67%, hsla(0,0%,100%,.025)),
@mckamey
mckamey / README.md
Created July 20, 2012 23:23
Example iOS Custom URL Redirection

The way you can do this for "http://" URLs (and what I think Apple and Spotify do) this is to:

  1. Register a custom URL scheme [like the other answers have shown][1].

  2. Set up your HTTP URL to point to a real webpage.

  3. Put a script on that page to redirect to your custom URL if is on iOS.

For example, here is a sample page which will take you to the Twitter app for a particular user or the Twitter website depending upon if you are on the web or on your iOS device.

@mckamey
mckamey / debounce.js
Created July 16, 2012 22:14
Debounce closure
/**
* Creates a function which fires only once when called in quick succession
* @param {function...} action the function to fire
* @param {number} delay amount of time until considered done, default:100ms
* @param {boolean} asap if should execute at the start of the series (true) or the end (false), default:false
* return {function} debounced function
*/
var debounce = function(action, delay, asap){
if ('function' !== typeof action) {
return null;
@mckamey
mckamey / README.md
Created June 13, 2012 23:08
Polyfill for touch dblclick
@mckamey
mckamey / storage.js
Created January 23, 2012 17:49 — forked from remy/gist:350433
Storage polyfill
(function (window) {
'use strict';
if (window.localStorage && window.sessionStorage) {
return;
}
// initialize if data already stored
var data = JSON.parse(window.name || '{}');
@mckamey
mckamey / module.js
Created January 13, 2012 20:21
JS Module Pattern C
/*global jQuery */
// ensure root namespace
var App = App || {};
App.foo = (function($){
'use strict';
// private members
@mckamey
mckamey / module.js
Created January 13, 2012 17:50
JS Module Pattern B
/*global jQuery */
// ensure root namespace
var App = App || {};
(function(App, $){
'use strict';
// private members