Skip to content

Instantly share code, notes, and snippets.

View triniMahn's full-sized avatar

Nesta R triniMahn

View GitHub Profile
@triniMahn
triniMahn / CompositeModel_declaration.coffee
Last active December 29, 2015 01:39
Backbone.CompositeModel class
class window.CompositeModel extends Backbone.Model
#override the Backbone.Model constructor -- setting up our CompositeBin, and then
#allow Backbone.Model to run its constructor
constructor: (attributes, options)->
@__ = new CompositeBin(options)
Backbone.Model.apply(@, arguments)
#When your Shui ain't Funging, homes
Backbone.SF = {}
@triniMahn
triniMahn / CompositeModel_example.coffee
Last active December 29, 2015 01:39
CompositeModel example
describe 'Auto model instances with a CompositeBin which', ->
beforeEach ->
@fuelInjector = new FuelInjector()
@engine = new Engine {}, FuelInjector: @fuelInjector
@auto = new Automobile
modelName: 'Ford'
,
@triniMahn
triniMahn / CompositeModel_aggr_ex.coffee
Last active December 29, 2015 01:39
CompositeModel aggregate root example.
class window.Automobile extends Backbone.SF.CompositeModel
initialize: (attributes,options)->
defaults:
modelName: null
startEngine: =>
@__.Engine.start()
@triniMahn
triniMahn / marionette-app-notes.coffee
Last active August 29, 2015 13:57
Backbone-orm-todo: Marionette App Notes
window.TodoMVC = new Backbone.Marionette.Application()
window.app = {}
window.app.collections = {}
TodoMVC.addRegions
header: '#header'
main: '#main'
footer: '#footer'
filters: '#filters'
@triniMahn
triniMahn / backbone-orm-todo-model.coffee
Created March 17, 2014 23:20
Shows the Backbone Model set up for use with Backbone-orm on the server.
class window.Todo extends Backbone.Model
#You can use this to test the (client-side) app logic if you're having issues with BackboneORM to start
#localStorage: new Backbone.LocalStorage('todos-backbone-marionettejs')
urlRoot: '/todos'
#Use backbone-http to communicate with your server -- overriding the model sync method here
sync: BackboneHTTP.sync(Todo)
searchArchivedByDate: =>
dateFrom = Date.parse(@ui.dateFrom.val())
dateTo = Date.parse(@ui.dateTo.val())
Todo.find {archived: true, created: {$gte: dateFrom.valueOf(), $lt: dateTo.valueOf()}}, (err,todos)->
console.log(err) if err
app.collections.tds.reset(todos or [])
@triniMahn
triniMahn / backbone-orm-todo-server.coffee
Created March 18, 2014 15:52
Snippet of server side code for the backbone-orm-todo sample app
Backbone = require 'backbone'
RestController = require 'backbone-rest'
AppSettings = require('./_config')
class Todo extends Backbone.Model
urlRoot: "mongodb://#{AppSettings.DB.cnnString}/Todos"
sync: require('backbone-mongo').sync(Todo)
defaults:
title: ''

Keybase proof

I hereby claim:

  • I am triniMahn on github.
  • I am trinimahn (https://keybase.io/trinimahn) on keybase.
  • I have a public key whose fingerprint is 637B D6DD E483 ED3E 3C01 50C0 21ED CFD3 9174 936A

To claim this, I am signing this object:

var DocumentRow = Backbone.View.extend({
tagName: "li",
className: "document-row",
events: {
"click .icon": "open",
"click .button.edit": "openEditDialog",
"click .button.delete": "destroy"
class DocumentRow extends Backbone.View
tagName: "li"
className: "document-row"
events:
"click .icon": "open"
"click .button.edit": "openEditDialog"
"click .button.delete": "destroy"