Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@ianmstew
ianmstew / gist:6d0db2981c438b800d04
Last active August 29, 2015 14:02
Backbone.Model.set override that bubbles change events
var ModelWithNesting = Backbone.Model.extend({
/*
* Backbone.Model.set() override that sniffs out child Backbone Models and bubbles up events.
* Accepts the same parameters as Backbone.Model.set().
*/
set: function (key, val, options) {
var self = this,
attrs;
if (key == null) return this;
ContactManager.module("ContactsApp.Show", function(Show, ContactManager, Backbone, Marionette, $, _){
var localCh = require('mymodule/mymodule.channel');
Show.Controller = Marionette.Controller.extend({
initialize: {
_.bindAll(this, 'contactEdited');
this.listenTo(localCh, "contact:edit", this.contactEdited);
},
contactEdited: function (contact) {
/*
* So, your json from here http://screencast.com/t/zv8sQGVk6 is organized like this:
* array (roles) -> model (role) -> array (permissions) -> model (permission). Collections
* already handle array -> model by design. What you need to add is a model that contains a
* collection; in other words, the role model should contain a permission collection.
* That's what this file is :)
*/
var RoleModel = Backbone.Model.extend({
// See http://backbonejs.org/#Model-parse
@ianmstew
ianmstew / Vagrantfile
Created August 20, 2014 12:43
vagrant-parallels
# -*- mode: ruby -*-
# vi: set ft=ruby :
require "rbconfig"
HOST_NAME = "prerender"
VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.5"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
define(function (require) {
var Backbone = require('backbone');
var Marionette = require('marionette');
var eventedClasses = [
Backbone.Model,
Backbone.Collection,
Marionette.Controller,
Marionette.Object,
Marionette.Region,
define(function (require) {
var sinon = require('sinon');
var database = require('test/data/database');
var server = sinon.fakeServer.create();
var CONTENT_JSON = { 'Content-Type': 'application/json' };
var lastAppId = 0;
server.autoRespond = true;
server.autoRespondAfter = 100;
define(function (require) {
var Mixin = require('lib/classes/mixin');
var Radio = require('backbone.radio');
var logger = require('lib/util/logger');
var HasChannel = Mixin.extend({
// Declarative option for channel name
// channelName: nameOfChannel
@ianmstew
ianmstew / .jscsrc
Last active April 9, 2018 16:49
Code Style
// Derived from AirBnB + LinkedIn Idiomatic + Crockford
// https://github.com/airbnb/javascript
// https://github.com/linkedin/idiomatic.js (Idiomatic fork with Crockford inner spacing)
// http://javascript.crockford.com/code.html
{
// Keywords
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
"disallowKeywords": ["with", "eval"],
// Functions
<section class="listing" data-view="listings/index" data-model_id="687210" data-model_name="listing">
<div class="slideshow"> ... </div>
<section class="details tab_panel" data-view="listings/details" data-model_id="687210" data-model_name="listing">
<ul> ... </ul>
</section>
<section class="user" data-view="listings/user" data-model_id="2088962" data-model_name="user" data-lazy="true"> ... </section>
</section>