Skip to content

Instantly share code, notes, and snippets.

MyApp.HAS_AUTH = SC.State.design({
initialSubstate: 'SHOWING_APP',
SHOWING_APP: SC.State.design({
substates: [
SC.State.design({
enterState: function() {
MyApp.statechart = SC.Statechart.create({
trace: YES,
rootState: SC.State.design({
initialSubstate: 'CHECKAUTH',
CHECKAUTH: SC.State.plugin('MyApp.CHECK_AUTH'),
> var c = SC.Object.create({ foo: "bar" });
undefined
> c
SC.Object {__sc_super__: Object, _kvo_cloned: null, foo: "bar", _observers: Array[0], outlets: Array[0]…}
> var d = JSON.stringify(c)
undefined
> var e = JSON.parse(d)
undefined
> e
Object {__sc_super__: Object, _kvo_cloned: null, foo: "bar", _observers: Array[0], outlets: Array[0]…}
Faces.SinatraDataSource = SC.DataSource.extend(
/** @scope Faces.SinatraDataSource.prototype */ {
// ..........................................................
// QUERY SUPPORT
//
fetch: function(store, query) {
if (query == Faces.PEOPLE_QUERY) {
SC.Request.getUrl('/people').header({'Accept': 'application/json'}).json()
MyApp.PhpDataSource = SC.DataSource.extend({
queryQueries: function(query) {
var url, callback = "";
if (query == MyApp.FIRST_QUERY) {
url = "/books";
callback = "didFetchBooks";
}
else if (query == MyApp.SECOND_QUERY) {
url = "/test";
@awsp
awsp / gist:25b7f5366a74a90b2089
Created June 7, 2014 02:06
Problem with exampleView
toolbarBeltView: SC.GridView.design({
layout: { centerX: 0, height: 56, width: 68 * MyApp.toolbarMenuItemsController.get('length') },
columnWidth: 68,
rowHeight: 56,
classNames: ['header-background'],
contentBinding: 'MyApp.toolbarMenuItemsController.arrangedObjects',
exampleView: SC.View.design(SC.Control, {
childViews: 'textLabelView imageLabelView' . w(),
@awsp
awsp / SC.LabelView
Last active August 29, 2015 14:02
SC.LabelView
<snippet>
<content><![CDATA[
${1}: SC.LabelView.design({
layout: { width: ${2}, height: ${3}, left: ${4}, top: ${5} },
value: '${6}'
})
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>sclabel</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
@awsp
awsp / SC.TextFieldView
Created June 9, 2014 01:10
SC.TextFieldView
<snippet>
<content><![CDATA[
${1}: SC.TextFieldView.design({
layout: { width: ${2}, height: ${3}, left: ${4}, top: ${5} },
isTextArea: ${6:'NO'}
})
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>sctext</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
var validator = require('validator');
var hankaku = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ';
var zenkaku = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ';
var zenkakuToHankaku = function (word) {
for (var i = 0, n = zenkaku.length; i < n; i++) {
word = word.replace(new RegExp(zenkaku[i], 'gm'), hankaku[i]);
}
return word.replace(/^\s+|\s+$/g, ''); // trim head and tail white space
};
// Server side, BarController
module.exports = {
foo: function (req, res) {
res.view('foo');
},
save: function (req, res) {
Bar.create({
name: 'bar'