Skip to content

Instantly share code, notes, and snippets.

View addyosmani's full-sized avatar
🎯
Focusing

Addy Osmani addyosmani

🎯
Focusing
View GitHub Profile
function Promise () {
this._thens = [];
}
Promise.prototype = {
then: function (resolve, reject) {
// capture calls to then()
this._thens.push({ resolve: resolve, reject: reject });
},
NEEDSDOCS no ticket associated
https://github.com/jquery/jquery/commit/4e97543
FEATURE (SMALL) SHOULD THIS BE REMOVED BEFORE 1.5.1??
.invert() method on promises
returns an inverted promise that is resolved/rejected when the underlying deferred is rejected/resolved)
https://github.com/jquery/jquery/commit/e0b1bb8
http://api.jquery.com/extending-ajax/ <-- the code example at the very bottom should be updated to match the new regex
#8122
$ git clone github:lenary/guides.git
Cloning into guides...
remote: Counting objects: 255, done.
remote: Compressing objects: 100% (216/216), done.
remote: Total 255 (delta 111), reused 163 (delta 35)
Receiving objects: 100% (255/255), 1.49 MiB | 564 KiB/s, done.
Resolving deltas: 100% (111/111), done.
$ cd guides
$ git remote -v
/*!
* jQuery whenthen - v0.2 - 3/12/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($){
/*!
* jQuery whenthen - v0.2 - 3/12/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($){
<?xml version="1.0" encoding="utf-8"?>
<project name="sample-require-js" default="" basedir=".">
<!-- properties -->
<property name="requirejs.dir" value="_build/requirejs" />
<!-- custom tasks -->
@addyosmani
addyosmani / vendorPrefix.js
Created August 8, 2011 06:13 — forked from danheberden/vendorPrefix.js
JS snippet for getting the current vendor prefix of a CSS(3) property
function getPrefix( prop ){
var vendorPrefixes = ['Moz','Webkit','Khtml','O','ms'],
style = document.createElement('div').style,
upper = prop.charAt(0).toUpperCase() + prop.slice(1),
pref, len = vendorPrefixes.length;
while( len-- ){
if((vendorPrefixes[len] + upper) in style){
pref = (vendorPrefixes[len]);
}
}
@addyosmani
addyosmani / vendorPrefix.js
Created August 8, 2011 06:13 — forked from danheberden/vendorPrefix.js
Get the vendor prefix for a property in a specific context.
function getPrefix(prop, context) {
var vendorPrefixes = ['moz', 'webkit', 'khtml', 'o', 'ms'],
upper = prop.charAt(0).toUpperCase() + prop.slice(1),
pref, len = vendorPrefixes.length,
q;
while (len--) {
q = vendorPrefixes[len];
if (context.toString().indexOf('style')) {
q = q.charAt(0).toUpperCase() + q.slice(1);
@addyosmani
addyosmani / LICENSE.txt
Created August 10, 2011 13:39 — forked from 140bytes/LICENSE.txt
140byt.es -- objectClone
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@addyosmani
addyosmani / mobileURLs.js
Created August 17, 2011 11:32 — forked from louisremi/mobileURLs.js
matchMedia Demo
// matchMedia is supported and the device has a small screen
if ( "matchMedia" in window
&& window.matchMedia( "(max-device-width: 800px)" )
) {
Array.prototype.forEach.call(
// for each element matching the selector...
document.querySelectorAll(
"a[href*='youtube.com/watch'], a[href*='flickr.com']"
),
// ...replace the href with their mobile equivalent