Skip to content

Instantly share code, notes, and snippets.

@nnance
nnance / backbone-auth-query-params
Last active January 2, 2016 17:09
Backbone authentication by passing tokens as query params
define(function (require) {
"use strict";
var Backbone = require('backbone');
return Backbone.Model.extend({
initialize: function() {
this.backboneAjax = Backbone.ajax;
},
@nnance
nnance / app-settings
Last active January 2, 2016 17:09
Application settings example
define([], function () {
'use strict';
var AppSettings = {
baseUrl: "http://myapp.appspot.com",
modelType: "common/models/jsonp/event"
};
return AppSettings;
});
@nnance
nnance / backbone-session
Last active January 2, 2016 17:09
Backbone session management
define([
'underscore',
'backbone',
'backbone.localstorage',
], function (_, Backbone, BBLocalStorage) {
'use strict';
var SessionModel = Backbone.Model.extend({
defaults: {
signedIn: false
@nnance
nnance / backbone-auth-header
Last active January 2, 2016 17:19
Backbone authentication using auth headers
define(function (require) {
"use strict";
var Backbone = require('backbone');
return Backbone.Model.extend({
initialize: function() {
this.backboneSync = Backbone.sync;
},
@nnance
nnance / static-node-server
Last active August 29, 2015 14:04
Nodejs Simple Static Server
var connect = require('connect');
var serveStatic = require('serve-static');
connect().use(serveStatic(__dirname)).listen(8080);
@nnance
nnance / gulp-livereload-express
Created July 24, 2014 03:30
Gulpfile for livereload + express server
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserify = require('gulp-browserify'),
concat = require('gulp-concat'),
embedlr = require('gulp-embedlr'),
refresh = require('gulp-livereload'),
lrserver = require('tiny-lr')(),
express = require('express'),
livereload = require('connect-livereload')
livereloadport = 35729,
Create separate SSH key for your personal account and your company. Named them with different extensions in your .ssh folder. Upload them to your github account and finally create a config file for your SSH
Create a config file in ~/.ssh/
vim config:
# PERSONAL ACCOUNT Github
Host github.com-COOL
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_COOL
@nnance
nnance / Bubble-loader.markdown
Created September 9, 2014 12:51
A Pen by Nick Nance.
@nnance
nnance / amd-module.js
Created September 16, 2014 22:13
Simple AMD Module
define(optionalId, ['underscore', 'backbone'], function (_, Backbone) {
// Return a defined module
return function () {};
});
@nnance
nnance / amd-dynamic.js
Created September 16, 2014 22:14
AMD Module With Dynamic Dependencies
define(function ( require ) {
var isReady = false, foobar;
// note the inline require within our module definition
require(['foo', 'bar'], function (foo, bar) {
isReady = true;
foobar = foo() + bar();
});
// we can still return a module
return {
isReady: isReady,