Skip to content

Instantly share code, notes, and snippets.

@linus-amg
linus-amg / controller.coffee
Created Dec 30, 2014
Valid controller pattern for repetitive shows?
View controller.coffee
NavigationView = require 'views/navigation.coffee'
HomeView = require 'views/home.coffee'
OtherView = require 'views/other.coffee'
LogoutView = require 'views/logout.coffee'
ListView = require 'views/list/index.coffee'
TableView = require 'views/table/index.coffee'
ListCollection = require 'collections/list.coffee'
TableCollection = require 'collections/table.coffee'
module.exports = Marionette.Controller.extend
@linus-amg
linus-amg / pagination_example.json
Last active Aug 29, 2015
pagination json example
View pagination_example.json
{
results: [
{
_id: "54a1cb3b4d5366f565e988ff",
name: "Principal Viaje y Viáticos",
parent: "dfb5833b-1a9a-4c09-b575-3d27ae868423",
description: "",
png: "https://s3.amazonaws.com/g4-qa/images/thumbnails/processes/dcb41c70-8fa3-11e4-9fcb-b79a15b9e978.png",
author: "Jaime",
user: "546febce4b987f438415b9be",
@linus-amg
linus-amg / index.js
Created Jan 7, 2015
express-session
View index.js
var express = require('express'),
app = express(),
bodyParser = require('body-parser'),
methodOverride = require('method-override'),
compression = require('compression'),
session = require('express-session'),
RedisStore = require('connect-redis')(session),
app.use(session({
saveUninitialized: true,
View gist:b48014e7514677c3262f
$.ajaxSetup({
beforeSend: function(jqXHR, settings) {
if (!settings.raw) {
settings.xhrFields = { withCredentials: false };
}
View query.coffee
myArray = []
_id = 'e427a9b6-328c-4b95-a6e3-421ab74d5163'
key = "bpm.processes." + _id
obj = {}
obj[key] = 'b4503eb5-7e8b-44da-bca1-73735bd3a92a';
myArray[0] = {'root': true}
myArray.push(obj)
query = {};
query['$and'] = myArray
console.log JSON.stringify(query)
View pushstate.js
Backbone.history.start({ pushState: true });
$(document).on('click', 'a:not([data-bypass])', function (evt) {
var href = $(this).attr('href');
var protocol = this.protocol + '//';
if (href.slice(protocol.length) !== protocol) {
evt.preventDefault();
app.router.navigate(href, true);
}
View gist:a41a600bd2aa5046382b
$.load('/' + id, function(reseponseText) {
$('#main').html(responseText);
$('#main').trigger('create'); // (no recuerdo 100% si era asi esta linea suya.)
});
View examples.coffee
# example 1
class AppRouter extends Mn.AppRouter
appRoutes:
'': DefaultRoute
module.exports = new AppRouter
# example 2
module.exports = new Mn.AppRouter
appRoutes:
View gist:857a702e52bf6b563500
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>
View app.js
var App = new Marionette.Application({
regions: {
'detail': '#detail'
}
});
var doc1 = {
"_id": "123",
"type": "customer",
"datosGenerales": {