This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lets say you're making a plugin with the typical design of | |
// passing an object literal of options. Here's what you can do. | |
$.Controller("myPlugin", { // Static properties | |
// The options you pass get auto extended over these | |
defaults: { | |
className: "default-class" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Boo | |
exports.Person = function( first, last ) { | |
this.first = first; | |
this.last = last; | |
}; | |
// In your app, you'd have to do | |
var Person = require( "person" ).Person, // woof. | |
me = new Person( "ralph", "holzmann" ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function __construct( $params = null, $load = true ) { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var db = new mongo.Db('myDB', new mongo.Server("localhost", "27017", {})), | |
to = "ralph"; | |
db.open( function( err, p_client ) { | |
// Problem opening the database? | |
if ( err ) { | |
console.log( "db.open: " + err ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getEl = (function (doc) { | |
var getElementsByClassName = (function () { | |
return doc.getElementsByClassName ? | |
function (selector) { | |
return doc.getElementsByClassName(selector.split('.').pop()); | |
} : function (selector) { | |
var parts = selector.split("."), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var obj = {}, ordered = []; | |
$.get("js/jquery-1.6.1.min.js", function( src ) { | |
src.replace(/[^\w]|\d/gi, '').split('').forEach(function( c ) { | |
obj[ c ] ? ++obj[ c ] : ( obj[ c ] = 1 ) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var oauthPercentEncode = (function(){ | |
var escapeChars = "!*'();:@&=+$,/?%#[]", | |
matchChars = new RegExp( "([\\" + ( escapeChars.split('').join('\\')) + "])", "gi"); | |
return function( p ) { | |
return p.replace( matchChars, function( char ) { | |
return '%' + ( "" + char ).charCodeAt(0).toString(16).toUpperCase(); | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DropboxClient.prototype.putFile = function(file, path, optargs, cb) { | |
if (typeof optargs == 'function') cb = optargs, optargs = {}; | |
var boundary = 'sAxIqse3tPlHqUIUI9ofVlHvtdt3tpaG', | |
content_type = 'multipart/form-data; boundary=' + boundary, | |
self = this; | |
require('fs').readFile(file, function (err, data) { | |
if (err) return cb(err); | |
// Build request body. | |
path = escapePath(path); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Yepnope JS | |
* | |
* Version 0.2.6pre | |
* | |
* by Alex Sexton - AlexSexton@gmail.com | |
* | |
* Tri-Licensed WTFPL, BSD, & MIT | |
*/ | |
(function(window, doc, undef) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Modernizr | |
.addTest('iframe', function() { | |
return window.top.location != window.location; | |
}) | |
.addTest('facebook', function() { | |
return !! ~ location.href.indexOf( 'fb_sig_in_iframe=1' ); | |
}); |