Skip to content

Instantly share code, notes, and snippets.

(function(global) {
var silpUrl = '//s3-eu-west-1.amazonaws.com/silp.shootitlive.com/js/silp.min.js';
// Globals
if(!global.Silp) { global.Silp = {}; };
var Silp = global.Silp;
// To keep track of which embeds we have already processed
if(!Silp.foundEls) Silp.foundEls = [];
@stephenvisser
stephenvisser / app.js
Created May 16, 2012 15:45
Using Twitter Bootstrap NavBars with Backbone.js
//This is the Backbone controller that manages the content of the app
var Content = Backbone.View.extend({
initialize:function(options){
Backbone.history.on('route',function(source, path){
this.render(path);
}, this);
},
//This object defines the content for each of the routes in the application
content:{
"":_.template(document.getElementById("root").innerHTML),
@visnaut
visnaut / yepnope-ga.js
Created May 11, 2012 15:45
Load Google Analytics Asynchronously via yepnope.js (Modernizr.load)
/**
* Using Google Analytics & yepnope.js (Modernizr.load) in the same project?
* Replace Google's default snippet with the code below to load and initialize GA asynchronously.
*
* Don't forget to copy and paste your full web property ID.
*
* If you use Modernizr:
* 1. Build with the Modernizr.load build option:
* http://modernizr.com/download/#-load
* 2. Replace 'yepnope' below with 'Modernizr.load'
@mtrpcic
mtrpcic / Testcase.html
Created December 27, 2011 23:41
Code examples for Issue #13 on mtrpcic/pathjs
/*
The following is a concise outline of the test environment that I've set up to test the outcome described in
Issue #13 on the PathJS master branch. This setup is running on a Rails server.
https://github.com/mtrpcic/pathjs/issues/13
*/
// Step 1 - Server, Routes, and Data
// I set up a Rails 3.1.0 server with a 'Widget' model, and the following test route:
@danott
danott / social.js
Created November 28, 2011 22:04
Replace Twitter/Facebook/G+ scripts with one Modernizr.load call.
Modernizr.load(
[ '//platform.twitter.com/widgets.js'
, '//apis.google.com/js/plusone.js'
, { test: document.getElementById('facebook-jssdk')
, nope: '//connect.facebook.net/en_US/all.js#xfbml=1'
}
]);
/* When Using Modernizr, the above replaces all the social includes below
@bergie
bergie / .gitignore
Created September 19, 2011 15:50
Node.js email handling examples
config.json
reading-image.png
@mjackson
mjackson / mockstream.js
Created September 7, 2011 17:31
A mock stream wrapper for node.js
var util = require("util"),
Stream = require("stream").Stream;
module.exports = MockStream;
/**
* A constructor that inherits from Stream and emits data from the given
* `source`. If it's a Stream it will be piped through to this stream.
* Otherwise, it should be a string or a Buffer which will be emitted by this
* stream as soon as possible.
@kig
kig / workcrew.js
Created September 2, 2011 11:03
WorkCrew - a WebWorker work queue library
/*
WorkCrew - a WebWorker work queue library
Usage:
// Create an 8 worker pool using worker.js.
var crew = new WorkCrew('worker.js', 8);
// Do something whenever a job is completed.
// The result object structure is
@fwielstra
fwielstra / api.js
Created June 14, 2011 14:46
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@Marak
Marak / mockreadwritestream.js
Created May 20, 2011 06:29 — forked from indexzero/mockreadwritestream.js
A mock stream for node.js that is both Readable and Writeable.
var events = require('events'),
util = require('util');
var MockReadWriteStream = helpers.MockReadWriteStream = function () {
//
// No need to do anything here, it's just a mock.
//
};
util.inherits(MockReadWriteStream, events.EventEmitter);