Skip to content

Instantly share code, notes, and snippets.

@gbakernet
gbakernet / load-google-maps.js
Created February 15, 2011 23:42
Load Google Maps API using jQuery Deferred.
/*!
* JavaScript - loadGoogleMaps( version, apiKey, language )
*
* - Load Google Maps API using jQuery Deferred.
* Useful if you want to only load the Google Maps API on-demand.
* - Requires jQuery 1.5
*
* Copyright (c) 2011 Glenn Baker
* Dual licensed under the MIT and GPL licenses.
*/
// $('img.photo',this).imagesLoaded(myFunction)
// execute a callback when all images have loaded.
// needed because .load() doesn't work on cached images
// mit license. paul irish. 2010.
// webkit fix from Oren Solomianik. thx!
// callback function is passed the last image to load
// as an argument, and the collection as `this`
@gbakernet
gbakernet / Node Smart Machine CouchDB
Created January 18, 2011 00:09
Node Smart Machine CouchDB
#Steps
pkgin install couchdb
svccfg import /opt/local/share/smf/manifest/couchdb.xml
svcadm enable couchdb
#Test
curl http://127.0.0.1:5984/
{"couchdb":"Welcome","version":"1.0.1"}
/*!
* jQuery Tiny Pub/Sub - v0.X - 11/18/2010
* http://benalman.com/
*
* Original Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*
* Made awesome by Rick Waldron
*
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.pubsubLogging = false;
@gbakernet
gbakernet / jquery.pubsub.js
Created November 18, 2010 05:41
PUBSUB on the back of jquery events
(function($){
$.pubsub = (function(){
var mule = $({});
return {
subscribe:function(key, fn){
//Normalise
mule.bind(key, function(e, data){
fn.apply(null, [data]);
});
function rand(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
.mouse, #preview{
position: absolute;
background-repeat: no-repeat;
height: 22px;
min-width: 15px;
z-index: 100;
}
.mouse{
background-image: url('../images/cursor.png');
javascript:void((function(){
var script=document.createElement('script');
script.src='http://yui.yahooapis.com/2.8.0r4/build/yuiloader/yuiloader-min.js';
script.setAttribute('type', 'text/javascript');
document.getElementsByTagName('HEAD')[0].appendChild(script);
var loaderCheck = setInterval(function(){
if(window['YAHOO']) {
clearInterval(loaderCheck);
doit();
FWImage
FWPage
FWArticle