Skip to content

Instantly share code, notes, and snippets.

@brianjmiller
brianjmiller / Gruntfile.js
Last active August 29, 2015 14:01
Backbone-stack updates
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
/**
* Watching
* ========
var dbh = require("../migrations"),
relationName = "time_zones";
exports.up = function (next) {
dbh.schema.createTable(
relationName,
function (table) {
table.string("code", 50).primary();
table.timestamps();
table.integer("utc_offset").notNullable();
@brianjmiller
brianjmiller / base.js
Last active January 1, 2016 20:49
Base BB View
return Backbone.View.extend(
{
_nodes: null,
renderCfg: function () {
return this._renderCfg || {};
},
renderContext: function () {
console.log("views/base::renderContext");
@brianjmiller
brianjmiller / gist:7042658
Last active December 25, 2015 21:29
Backbone .save handlers
user.save(
userSaveData,
{
success: _.bind(this._registerSuccess, this),
error: _.bind(this._registerError, this)
}
);
_registerSuccess: function () {
console.log("views/signUp::_registerSuccess");
@brianjmiller
brianjmiller / Base class
Last active December 25, 2015 04:39
Basic Collection view implementation, there are better more thorough ones.
define(
[
"backbone",
"templates",
"underscore"
],
function (Backbone, templates, _) {
"use strict";
var CLASS_EMPTY = "ws-list-empty";
PasswordReset.find(
{
include: [
User
],
where: {
token: token,
"users.email": email,
expiresAt: {
gte: (new Date())
@brianjmiller
brianjmiller / gist:6393294
Created August 30, 2013 19:12
Sample sequelize
Uri.findAll(
{
include: [
{ model: CurrentMetaData, as: "metadata" }
],
where: {
type: revTypeMap[type]
}
}
).then(
@brianjmiller
brianjmiller / gist:6321261
Created August 23, 2013 16:24
Sample Handlebars pre-compiled template
this["JST"]["activity/denied.html"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [2,'>= 1.0.0-rc.3'];
helpers = helpers || Handlebars.helpers; data = data || {};
return "<h2>Activity Access Denied</h2>\n";
});
if (! DEBUG) {
if (! window.console) {
window.console = {};
}
methods = ["log", "debug", "warn", "info"];
for (i = 0; i < methods.length; i++) {
console[methods[i]] = function () {};
}
}
@brianjmiller
brianjmiller / gist:6174702
Last active December 20, 2015 18:18
Example of changing view through attach/detach
_changeView: function (newView, options) {
console.log("app::_changeView");
options = options || {};
options.renderFirst = (typeof options.renderFirst !== "undefined") ? options.renderFirst : true;
if (this._currentView !== null && this._currentView === newView) {
console.log("app::_changeView - no change needed");
return;
}