Skip to content

Instantly share code, notes, and snippets.

View milankinen's full-sized avatar
🐦
tsers

Matti Lankinen milankinen

🐦
tsers
View GitHub Profile
jQuery ->
# Simple person model with two attributes
class Person extends Backbone.Model
validation:
age:
required: true
min: 10
name:
required: true
msg: "All persons have a name..."
# PART 2: bind our backbone view to validation events and also for
# input changes so that model changes automatically when input changes
# =======================================================================
# This defines which element's attribute will be used for linking
inputSelector = 'name'
# model update function, which is called when input changes
updateModel = (model, attr, value) ->
model.set(attr, value || null)
# PART 1: tweak backbone validation a little bit
# ===============================================
# first, allow errorous inputs to update our model
Backbone.Validation.configure
forceUpdate: true
# then disable default callbacks for backbone validation events
_.extend Backbone.Validation.callbacks,
valid: (view, attr, selector) ->
import com.tunkkaus._MultiModuleResourceMapper
beans = {
_MultiModuleResourceMapper.enable()
}
package com.tunkkaus
import org.grails.plugin.resource.ResourceMeta
import org.grails.plugin.resource.ResourceProcessor
import org.grails.plugin.resource.mapper.MapperPhase;
import org.grails.plugin.resource.module.ModuleBuilder
import org.springframework.util.AntPathMatcher
/**
* We are using prefix '_' because we want that this resource mapper
@milankinen
milankinen / gist:4261912
Created December 11, 2012 20:33
Aspect examples
class MyClass
simple: ->
alert "hello!"
another: ->
alert "hi!"
withParams: (a, b) ->
alert a + " - " + b
withReturnValue: (a) ->
return 2 * a
@milankinen
milankinen / aspect_example.coffee
Created November 24, 2012 13:56
Coffeescript aspects
class MyClass
foo: ->
alert "foobar"
bar: ->
alert "barfoo"
@foo()