Skip to content

Instantly share code, notes, and snippets.

View addyosmani's full-sized avatar
🎯
Focusing

Addy Osmani addyosmani

🎯
Focusing
View GitHub Profile
var application = {
page_loaded : false,
page_init : function() {
var i;
application.page_loaded = true;
// Load scripts that have not already been loaded.
var script;
for (i=0; script = application.scripts_to_load[i]; i++) {
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 April 21, 2011 06:33
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[0].toUpperCase() + prop.slice(1),
pref, len = vendorPrefixes.length;
while( len-- ){
if((vendorPrefixes[len] + upper) in style){
pref = (vendorPrefixes[len]);
}
}
@addyosmani
addyosmani / browser-prefix-detection
Created June 7, 2011 13:14
Compact browser prefix checking
/* GPL */
/*Whitelist version with quick test*/
function k(q){
var s,
d = document.createElement("div"),
n = q,
p = [ "webkit", "moz", "ms", "O", "" ],
o = n,
r, j=0, len, l;
@addyosmani
addyosmani / iPadOrientationAndMotionDetection.coffee
Created June 19, 2011 14:00
CoffeeScript iPad Orientation and Motion detection
updateInputField = (el, value) ->
el.value = value
value += 10
el.setAttribute "style", "width:" + Math.round(value * 25, 10) + "px"
moveThing = (el, acc) ->
acc.x = Math.round(acc.x * 20)
acc.y = Math.round(acc.y * 20)
acc.z = Math.round(acc.z * 25)
attr = "-webkit-transform:translate3d(" + acc.x + "px," + acc.y + "px," + acc.z + "px);"
attr += "-webkit-transition-duration:0.1s"