Skip to content

Instantly share code, notes, and snippets.

View triniMahn's full-sized avatar

Nesta R triniMahn

View GitHub Profile
@triniMahn
triniMahn / XtoCSVUtility.cs
Created December 16, 2014 22:10
Utility methods to convert certain data structures to CSV (note: the name, LinqToCSV, is slightly misleading)
public static class LinqToCSV
{
public static string ToCsv(SqlDataReader reader)
{
StringBuilder csvBuilder = new StringBuilder();
string line = null;
int i = 0;
//Get column headings
for (i = 0; i < reader.FieldCount - 1; i++)
class Foo extends Bar
constructor: (@name, job) ->
#With @name we can auto set an instance variable named "name", if we like.
@Job = job
longAssFunction: (param)->
#Use parentheses for function calls
result = eat(param)
class DocumentRow extends Backbone.View
tagName: "li"
className: "document-row"
events:
"click .icon": "open"
"click .button.edit": "openEditDialog"
"click .button.delete": "destroy"
var DocumentRow = Backbone.View.extend({
tagName: "li",
className: "document-row",
events: {
"click .icon": "open",
"click .button.edit": "openEditDialog",
"click .button.delete": "destroy"

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:

@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: ''
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-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)
@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 / 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()