This is a scaffold for setting up: an API with Rails and the ember-rails gem, persistence with Ember.Data, and a browser app using Ember.js
See source code on GitHub: pixelhandler/journal.
#!/bin/sh | |
# Called by "git push" after it has checked the remote status, | |
# but before anything has been pushed. | |
# | |
# If this script exits with a non-zero status nothing will be pushed. | |
# | |
# Steps to install, from the root directory of your repo... | |
# 1. Copy the file into your repo at `.git/hooks/pre-push` | |
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push` |
var application_root = __dirname, | |
express = require("express"), | |
path = require("path"), | |
mongoose = require('mongoose'); | |
var app = express.createServer(); | |
// database | |
mongoose.connect('mongodb://localhost/ecomm_database'); |
// Check if images load properly | |
// returns false if image not loaded | |
function imgOK(img) { | |
if (!img.complete) { | |
return false; | |
} | |
if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) { | |
return false; | |
} | |
return true; |
# JavaScript Generators and Concurrency | |
1. Why generators are a nice fit for handling a coroutine (source/sink) | |
2. How we use generators in the Dashboard app | |
3. What generators can do to help wrangle async behavior | |
Generators are functions that can be paused and resumed (think cooperative multitasking or coroutines) | |
Pitch: |
This is a scaffold for setting up: an API with Rails and the ember-rails gem, persistence with Ember.Data, and a browser app using Ember.js
See source code on GitHub: pixelhandler/journal.
import Ember from 'ember'; | |
import layout from '../templates/components/toggle-pill'; | |
const CHECKED = 'checked'; | |
export default Ember.Component.extend({ | |
layout, | |
inputId: 123, | |
// Component properties |
// using jQuery library and validation plugin in this code | |
// for checking keycodes | |
function getKeyCode(event) { | |
var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode)); | |
return keycode; | |
} | |
// is there an anchor as Submit button? | |
var $submit = $('a[id$="_submit"]'); | |
// is there any behavior already on submit, like -> onclick="__doPostBack(...)" |
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle' | |
}); |
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
matcher(item, query) { | |
let rating = item.get('rating'); | |
return rating.toLowerCase().indexOf(query.toLowerCase()); | |
}, | |
actions: { |
// bootstrap | |
PX.app = new PX.App(); | |
Backbone.history.start(); |