Skip to content

Instantly share code, notes, and snippets.

View erichocean's full-sized avatar

Erich Ocean erichocean

  • Xy Group Ltd
  • North Carolina
View GitHub Profile
// give CoreOI.Server time to load...
SC.ready(function() {
CoreOI.store = SC.Store.create().from(CoreOI.Server.create()) ;
});
@erichocean
erichocean / view_controller.js
Created January 13, 2011 18:37
How to do view controllers in SC
MyApp.menuPane.statechart: SC.Statechart.create({
});
MyApp.myPage = SC.Page.design({
menuPane: SC.Pane.design({
@erichocean
erichocean / peg_gen.js
Created January 5, 2011 05:06
How I converted the PEG grammar into source code (which I then modified)
var peg = require('./peg') ;
var sys = require('sys') ;
var posix = require('posix') ;
posix.cat("./ECMAScript_jsdoc.peg").addCallback(function (grammar) {
var parser = peg.generateParser(grammar) ;
sys.puts(parser) ;
});
; The entire ECMAScript grammar expressed as a single PEG
; Parser rules which share a name with ECMA-262 productions are intended to match the same language.
Program ←
(S? (Statement / FunctionDeclaration))* S?
FunctionBody ←
(S? (Statement / FunctionDeclaration))* S?
@erichocean
erichocean / peg.js
Created January 5, 2011 05:03
PEG grammar output for ECMAScript_unified.peg
/* PEG → JavaScript parser generator, with its dependencies.
* See http://inimino.org/~inimino/blog/peg_first_release */
var sys = require('sys') ;
;(function(exports){
exports.generateParser=generateParser
exports.generateParserThrowing=generateParserThrowing
@erichocean
erichocean / strip_assertions.js
Created January 5, 2011 05:01
removes hub_assert() and friends from the parse tree and outputs the results
// ==========================================================================
// Project: hub.js - cloud-friendly object graph sync
// Copyright: ©2010 Erich Ocean.
// Portions ©2006-2009 Sprout Systems, Inc. and contributors.
// Portions ©2008-2009 Apple Inc. All rights reserved.
// License: Licensed under an MIT license (see license.js).
// ==========================================================================
function Program(str){
var tbl=[],pos=0,l=str.length+1;while(l--)tbl.push([]);l=str.length;
@erichocean
erichocean / BUILD
Created January 5, 2011 02:12
fast sproutcore building
# An ordered list of files in ../src that are concatenated to produce hub.js,
# one file per line. Lines beginning with # are skipped. On node.js, the
# index.js file uses the contents of this file to assemble hub.js dynamically
# during development.
#
# To generate a custom build of hub.js, modify this BUILD file to include the
# list of files you need/want in the correct order.
#
# NOTE: In a production build, lines matching /^development[/].*/ will be
# skipped, and calls to hub_assert(), hub_precondition(), hub_postconditon(),
@erichocean
erichocean / gist:765713
Created January 5, 2011 00:26
SC.Binding.all
// Add Bindings
this.bindings = []; // will be filled in by the bind() method.
if (keys = this._bindings) {
for(loc=0, keysLen = keys.length; loc < keysLen;loc++) {
// get propertyKey
key = keys[loc] ; value = this[key] ;
propertyKey = key.slice(0,-7) ; // contentBinding => content
this[key] = this.bind(propertyKey, value) ;
}
}
@erichocean
erichocean / gist:745609
Created December 17, 2010 20:04
query-based to many relationship
messages: SC.RecordAttribute.create({
toType: function(record, key, value) {
var ary = record._messages ;
if (!ary) {
console.log('creating a messages query for Mailbox[%@]'.fmt(record.get('guid')));
CoreOI.Record.messages++ ;
ary = record._messages = record.get('store').findAll(SC.Query.create({
recordType: 'CoreOI.Message',
conditions: "mailbox = %@",
parameters: [record],
sc_require('controllers/mailboxes');
sc_require('controllers/messages');
SC.mixin(OI, {
registerStatechartObservers: function() {
var fun = this.folderSelectionDidChange ;
OI.foldersController.addObserver('selection', this, fun) ;
this.__mailboxesControllers__ = {} ;