Skip to content

Instantly share code, notes, and snippets.

Mymag.SourceItemView = SC.Checkbox.extend({
titleBinding: ".parentView.content.label"
});
Mymag.sourceListController = SC.ArrayController.create({
content: [
{ label: "BBC News", url: "http://www.bbc.co.uk/news/" },
{ label: "Snow forecast", url: "http://www.snow-forecast.com/resorts/Leysin/6day/mid" },
{ label: "XE", url: "http://www.xe.com/" }
]
mainPane: SC.MainPane.design({
childViews: "workspaceView".w(),
workspaceView: SC.WorkspaceView.design({
topToolbar: SC.ToolbarView.design({
childViews: "backButtonView forwardButtonView ".w(),
backButtonView: SC.LabelView.design({
layout: { left: 10, width: 24, height: 24 },
@ccapndave
ccapndave / gist:1410350
Created November 30, 2011 19:09
npm install -g bunch
info it worked if it ends with ok
verbose cli [ 'C:\\Program Files (x86)\\nodejs\\\\node.exe',
verbose cli 'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
verbose cli 'install',
verbose cli '-g',
verbose cli 'brunch' ]
info using npm@1.1.0-alpha-2
info using node@v0.6.3
verbose config file C:\Users\Dave\.npmrc
verbose config file C:\Program Files (x86)\etc\npmrc
makeRandomArray: ->
for x in [0..10]
Math.round Math.random() * 100
# How can I get the value at (x-1) here???
<div class="row">
<div class="cell">100</div>
</div>
<div class="row">
<div class="cell">50</div>
<div class="cell">50</div>
</div>
<div class="row">
@ccapndave
ccapndave / gist:1411510
Created November 30, 2011 22:40
Loop timer
for n in [0..10]
callback = (n) -> console.log "Hello from #{n}"
setTimeout callback, n * 1000, n
# This works but is it a bit hacky?
class Pyramid extends Spine.Model
@configure "Pyramid"
@hasMany "rows", "models/row"
constructor: (rowCount) ->
throw new Error("Row count needs to be more than one") unless rowCount > 1
(@rows().create y, row) for row, y in @createRows(rowCount)
createRows: (rowCount) ->
rows = []
@ccapndave
ccapndave / gist:1431291
Created December 4, 2011 21:12
Coffeescript
MyObject = SC.Object.extend({
fullName: function() {
return "How to add .property() in Coffeescript?"
}.property()
});
@ccapndave
ccapndave / gist:1436310
Created December 6, 2011 01:43
Tictactoe SC2
App = SC.Application.create()
### Model ###
class App.Game extends SC.Object
@createNewGame: ->
game = App.Game.create( { cells: [] } )
for x in [0...3]
for y in [0...3]
game.get("cells").pushObject App.Cell.create { x, y }
@ccapndave
ccapndave / gist:1443726
Created December 7, 2011 17:36
Nested loops
for x in [0...3]
for y in [0...3]
doSomething x, y
# Is there a clever Coffee way to do this is a single loop/line?