Skip to content

Instantly share code, notes, and snippets.

View mauritslamers's full-sized avatar

Maurits Lamers mauritslamers

  • Den Haag, Netherlands
View GitHub Profile
@mauritslamers
mauritslamers / gist:d7c5450642da8be9539e
Created January 7, 2016 15:25
Make SC.RecordArray behave conform specifications
SC.RecordArray.prototype.flush = function(_flush) {
// Are we already inside a flush? If so, then don't do it again, to avoid
// never-ending recursive flush calls. Instead, we'll simply mark
// ourselves as needing a flush again when we're done.
if (this._insideFlush) {
this.set('needsFlush', YES);
return this;
}
if (!this.get('needsFlush') && !_flush) return this; // nothing to do
// Init
App = SC.Application.create({
store: SC.Store.create().from(SC.Record.fixtures)
});
App.Contact = SC.Record.extend({
firstName: SC.Record.attr(String, { key: 'first_name' }),
lastName: SC.Record.attr(String, { key: 'last_name' }),
age: SC.Record.attr(Number),
ageSlow: function() {
node_modules/tern/bin/condense --name Sproutcore scruntime.js > sproutcore_tern.json
@mauritslamers
mauritslamers / fix_jsdoc3.js
Last active August 29, 2015 14:20
NodeJS script to rewrite most problems for JSDocv3 in SproutCore
/*jshint node:true*/
/*
purpose of this script is to walk through all files in sproutcore/frameworks and find the following:
- move @private to the bottom of the doc block
- move @namespace to the bottom of the doc block
- move @override to the bottom of the doc block
- rename @property without parameters to @member
- change @param {[type]...} to @param {...[type]}
var newFFTPitch = {
calc: function (fft, samplerate, fftSize) {
var fftLen = fft.length;
var i;
var max = fft[0];
var curVal;
for (i=1; i < fftLen; i += 1) {
curVal = fft[i];
if (curVal > max) max = curVal;
Sites.AUTHSTATE = SC.State.design({
initialSubstate: 'CHECKSESSION',
CHECKSESSION: SC.State.plugin('Sites.CHECKSESSION'),
SHOWLOGIN: SC.State.plugin('Sites.SHOWLOGIN'),
AUTHENTICATING: SC.State.plugin('Sites.AUTHENTICATING'),
AUTHENTICATED: SC.State.plugin('Sites.AUTHENTICATED')

SproutCore - Build Tools

SproutCore is a platform for building native look-and-feel applications on the web. This Node JS library includes a copy of the SproutCore JavaScript framework as well as a Node JS-based build system called Build Tools.

Build Tools is a build system for creating static web content. You can supply the Build Tools with a collection of JavaScript, HTML, CSS and image files and it will combine the files into a bundle that are optimized for efficient, cached deliver directly from your server or using a CDN.

Some of the benefits of using the Build Tools versus assembling your own content include:

  • Easy maintenance. Organize your source content in a way that is useful for
/Users/maurits/Development/sproutcore/assam/node_modules/sproutcore/lib/appbuilder.js:871
fwdeps.forEach(findDeps, this); // now all deps are in deps, doesn't need
^
TypeError: Cannot call method 'forEach' of null
at BT.AppBuilder.SC.Object.extend.wrapTest (/Users/maurits/Development/sproutcore/assam/node_modules/sproutcore/lib/appbuilder.js:871:12)
at BT.AppBuilder.SC.Object.extend.fileFor (/Users/maurits/Development/sproutcore/assam/node_modules/sproutcore/lib/appbuilder.js:826:29)
at null.<anonymous> (/Users/maurits/Development/sproutcore/assam/node_modules/sproutcore/lib/project.js:367:32)
at Array.forEach (native)
at BT.projectManager.SC.Object.create.onRequest (/Users/maurits/Development/sproutcore/assam/node_modules/sproutcore/lib/project.js:364:16)
at Server.f (/Users/maurits/Development/sproutcore/assam/node_modules/sproutcore/lib/project.js:63:20)
<html>
<head>
<title>AudioPlayground</title>
<style>* {box-sizing: border-box;}</style>
</head>
<body>
<h3>AudioPlayground</h3>
<p>If you're happy and you know it, clap your hands!</p>
<script>
var Recording = function(cb){
"most_recent_profile": {
"map": "function (doc) {\n
if (doc.type === 'personal_data') {\n
emit(doc._id, doc);\n
}\n}",
"reduce": "function (key, values, rereduce) {\n
var r = values[0];\n
for (var i = 1; i < values.length; i += 1) {\n
if (r.timestamp < values[i].timestamp) r = values[i];\n
}\n