-
Clone an existing repository:
git clone <repo>
(e.g.
https://gist.github.com/1125520.git
). -
[Checkout and pull an existing branch][gcp]:
This is more an art than a science. The [Mongo Documentation on Schemas][1] is a good reference, but here are some things to consider:
- Put as much in as possible
The joy of a Document database is that it eliminates lots of Joins. Your first instinct should be to place as much in a single document as you can. Because MongoDB documents have structure, and because you can efficiently query within that structure there is no immediate need to normalize data like you would in SQL. In particular any data that is not useful apart from its parent document should be part of the same document.
- Separate data that can be referred to from multiple places into its own collection.
This is not so much a "storage space" issue as it is a "data consistency" issue. If many records will refer to the same data it is more efficient and less error prone to update a single record and keep references to it in other places.
.factory('TokenHandler', function() { | |
var tokenHandler = {}; | |
var token = "none"; | |
tokenHandler.set = function( newToken ) { | |
token = newToken; | |
}; | |
tokenHandler.get = function() { | |
return token; |
rails s -e production |
Start Mamp | |
Start MySQL with: | |
``` | |
sudo /usr/local/mysql/support-files/mysql.server start | |
sudo /usr/local/mysql/support-files/mysql.server stop | |
sudo /usr/local/mysql/support-files/mysql.server restart | |
``` |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
sass: { | |
dist: { | |
files: { | |
'public/css/style.css' : 'public/scss/style.scss' | |
} | |
} | |
}, |
function serialize(obj) { | |
var str = []; | |
for(var p in obj) | |
if (obj.hasOwnProperty(p)) { | |
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); | |
} | |
return str.join("&"); | |
} | |
module.exports = serialize; |
// sending to sender-client only | |
socket.emit('message', "this is a test"); | |
// sending to all clients, include sender | |
io.emit('message', "this is a test"); | |
// sending to all clients except sender | |
socket.broadcast.emit('message', "this is a test"); | |
// sending to all clients in 'game' room(channel) except sender |
function consumer() { | |
return new oauth.OAuth( | |
"https://twitter.com/oauth/request_token", | |
"https://twitter.com/oauth/access_token", | |
keys.twitterConsumerKey, | |
keys.twitterConsumerSecret, | |
"1.0A", | |
"http://localhost:3000/sessions/callback", | |
"HMAC-SHA1" | |
); |
// Include our plug-ins | |
var gulp = require('gulp'); | |
var mainBowerFiles = require('main-bower-files'); | |
var exists = require('path-exists').sync; | |
// Create some task | |
gulp.task( 'copy-bower-dep', function() { | |
// Replace files by their minified version when possible | |
var bowerWithMin = mainBowerFiles().map( function(path, index, arr) { |