This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Movies sub-module | |
require ['app'], (MyApp) -> | |
MyApp.module 'Movie', (Movie, MyApp, Backbone, Marionette, $, _) -> | |
Movie.on 'start', -> | |
..... | |
# A file movies/ListViews | |
require ['app'], (MyApp) -> | |
MyApp.module 'Movie.Views', (Views, MyApp, Backbone, Marionette, $, _) -> | |
class Views.ItemView extends Marionette.ItemView |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MailSenderServiceTest extends GroovyTestCase { | |
// logging | |
Logger logger = Logger.getLogger(MailSenderServiceTest.class.getName()) | |
// service & data | |
def mailSenderService | |
def mockMailService | |
def fixtureData = [:] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'View', -> | |
Given -> @model = {} | |
Given -> @subject = new View | |
Then -> expect(@subject.events).toEqual | |
'click button': 'createAccount' | |
'change input[name="login"]': 'checkAvailability' | |
describe 'render', -> | |
Given -> spyOn(JST, ['app/templates/sign-up-form.us'].andReturn(-> '<div id="woot" />') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MultiRenderView | |
render: -> | |
_(@) | |
.chain() | |
.functions() | |
.select((f) -> f.indexOf("render") == 0) | |
.without("render") | |
.each (f) => @[f]() | |
class MyView extends MultiRenderView |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert an instance of Moment to the specified timeZone: | |
# date = new moment(new Date()) | |
# date.forTimeZone(moment.central) | |
moment.fn.forTimeZone = (timeZone) -> | |
currentOffset = (this.zone() * 60) * -1 | |
if this.isDST() | |
timeZoneOffset = timeZone.utcTotalOffset | |
else | |
timeZoneOffset = timeZone.utcOffset | |
if currentOffset > timeZoneOffset |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var reverseNum = function(num) { return num.toString().split('').reverse().join(''); }; | |
var sqrt = function(num) { return Math.sqrt(num); }; | |
var msqrt = _.memoize(function(num){ return sqrt(num); }); | |
var isFair = function(num) { return num == reverseNum(num);}; | |
var isSqr = function(num) { return (msqrt(num) % 1) == 0;}; | |
var sqrFair = function(num) { | |
var _sqrt = msqrt(num); | |
return isFair(_sqrt); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class List.Controller extends App.Controllers.Base | |
initialize: (options) -> | |
@searchModel = options.searchModel | |
@searchModel.on "change:sortField", @fetchAttendees | |
@searchModel.on "change:queryString", @fetchAttendees | |
@searchModel.on "change:group", @fetchAttendees | |
@fetchAttendees() | |
@layout = @getLayout() | |
@show @layout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def trimMonoid(s: String): Monoid[String] = new Monoid[String] { | |
def op(x: String, y: String) = x.trim() + " " + y.trim() | |
val zero = "" | |
} | |
trimMonoid("").op("Something ", " Somewhere ") //=> Something Somewhere |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RedParrot.module "AttendeeAdmin.CenterRegion", (CenterRegion, App, Backbone, Marionette, $, _) -> | |
class CenterRegion.Controller extends App.Controllers.Base | |
initialize: (options) -> | |
@region = options.region | |
@attendee = options.attendee | |
@layout = @getLayout() | |
@_listenToLayoutEvents() | |
@show @layout | |
@modulesOptions = {region: @layout.tabContentRegion, attendee: @attendee} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def countChange(money: Int, coins: List[Int]): Int = { | |
def compare(a: Int, b: Int) = { | |
if (a == b) "==" | |
else if (a > b) ">" | |
else "<" | |
} | |
def calculateChange(sum: Int, coins: List[Int]): Int = { | |
if (coins.isEmpty) 0 | |
else |