This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In the express server file | |
var express = require('express'); | |
var app = express(); | |
app.use((function(appInstance) { | |
'use strict'; | |
return function(req, res, next) { | |
appInstance.locals.mongo = require('mongodb'); | |
appInstance.locals.uuid = require('uuid'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
//Normal way - won't work if function is extracted to a module | |
app.use(function(req, res, next) { | |
'use strict'; | |
app.locals.greeting = 'hello'; | |
next(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* var person = { firstName: 'bill', lastName: 'johnson' } | |
* | |
* person = _.rename(person, 'firstName', 'first') | |
* person = _.rename(person, 'lastName', 'last') | |
* | |
* console.log(person) // { first: 'bill', last: 'johnson' } | |
*/ | |
_.rename = function(obj, key, newKey) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Assuming you're already in an angular controller... | |
$scope.user = {}; | |
//$scope.user will get filled with "email" and "password" keys | |
var enteredUsername = angular.copy($scope.username); | |
$scope.register = function() { | |
var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com"); | |
var user = angular.copy($scope.user); | |
ref.createUser({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//NON ES6 way | |
function actionWord () { | |
//Put your action here | |
} | |
//for example | |
//CREATE the function | |
function drive () { | |
console.log('I am driving now') | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = []; | |
var obj = {}; | |
var fun = function () {}; | |
var shoppingList = [ | |
'cheese', | |
'milk', | |
'bacon' | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import layout from './template'; | |
export default Ember.Component.extend({ | |
layout | |
}); |
OlderNewer