Skip to content

Instantly share code, notes, and snippets.

@james-gardner
james-gardner / invocation-patterns.js
Last active August 29, 2015 14:10
Invocation Patterns - Examples
/**
* Fake scope object for demo purposes.
*/
var myObj = {
test : true
};
/**
* Examples of 'function' invocation with different scope options.
*/
@james-gardner
james-gardner / constructors.js
Last active August 29, 2015 14:10
constructor invocation
/**
* Very simple constructor example.
*
* Remember the 'constructor' invocation pattern. Constructor invocation is done by using the 'new' keyword
* in front of an object.
*
*/
var MyConstructor = function() {
console.log('MyConstructor');
};
console.clear();
var dest = {
foo : {
b1 : "b1 value",
b2 : "b2 value"
},
baz : {
q1 : "q1 value"
},
@james-gardner
james-gardner / webpack.config.js
Created January 19, 2015 19:19
Webpack Configuration - Part 1
var webpack = require('webpack');
module.exports = {
entry: './app/app.js',
output: {
path: __dirname + '/app',
filename: 'app.min.js'
},
@james-gardner
james-gardner / welcome.view.js
Last active August 29, 2015 14:13
welcome.view.js
var View = Backbone.View.extend({
template: require('../templates/welcome.html'),
render: function() {
this.$el.html(this.template({
message: 'Hello There.'
}));
return this;
}
@james-gardner
james-gardner / app.js
Created January 19, 2015 19:24
boilerplate entry
var WelcomeView = require('./scripts/welcome.view.js'),
Router;
Router = Backbone.Router.extend({
routes: {
'': 'home'
},
home: function() {
@james-gardner
james-gardner / webpack.config.js
Created January 19, 2015 19:27
webpack config - part 2
var webpack = require('webpack');
module.exports = {
entry: './app/app.js',
output: {
path: __dirname + '/app',
filename: 'app.min.js'
},
@james-gardner
james-gardner / welcome.html
Created January 19, 2015 19:41
basic template
<h1>Welcome!</h1>
<p><%= message %></p>
@james-gardner
james-gardner / gruntfile-wintersmith-gh-pages.js
Created January 27, 2015 10:10
My wintersmith/grunt builder
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-gh-pages');
grunt.loadNpmTasks('grunt-wintersmith');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
wintersmith: {
build: {
options: {
config: './config.json'
@james-gardner
james-gardner / backbone-view.js
Created January 27, 2015 14:30
Backbone.View
var Ape = Backbone.Model.extend({
url : 'https://my.restful.api.com/'
});
var ApeView = Backbone.View.extend({
template : _.template('A <%= ape.type %> named <%= ape.name %>'),
render : function () {
this.$el.html(this.template({
ape : this.model.toJSON()