var mongoose = require('mongoose'), | |
// Load User model | |
User = mongoose.model('User'), | |
// Create Thing schema | |
thingSchema = new mongoose.Schema({ | |
_user: { | |
type: ObjectId, |
// View controller is a subclass of GLKViewController | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
self.eaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; | |
self.ciContext = [CIContext | |
contextWithEAGLContext:self.eaglContext |
######################### | |
# .gitignore file for Xcode5 | |
# | |
# NB: if you are storing "built" products, this WILL NOT WORK, | |
# and you should use a different .gitignore (or none at all) | |
# This file is for SOURCE projects, where there are many extra | |
# files that we want to exclude | |
# | |
# For updates, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects | |
# and https://gist.github.com/adamgit/3786883 |
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { | |
// setup initial state (e.g. before animation) | |
cell.layer.shadowColor = [[UIColor blackColor] CGColor]; | |
cell.layer.shadowOffset = CGSizeMake(10, 10); | |
cell.alpha = 0; | |
cell.layer.transform = CATransform3DMakeScale(0.5, 0.5, 0.5); | |
cell.layer.anchorPoint = CGPointMake(0, 0.5); | |
// define final state (e.g. after animation) & commit animation | |
[UIView beginAnimations:@"scaleTableViewCellAnimationID" context:NULL]; |
@interface YourViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> { | |
UIImageOrientation scrollOrientation; | |
CGPoint lastPos; | |
} | |
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { | |
if (tableView.isDragging) { | |
UIView *myView = cell.contentView; | |
CALayer *layer = myView.layer; | |
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity; |
###Creating a REST API using Node.js, Express, and MongoDB
####Installing Node.js
Go to http://nodejs.org, and click the Install button. Run the installer that you just downloaded. When the installer completes, a message indicates that Node was installed at /usr/local/bin/node and npm was installed at /usr/local/bin/npm. At this point node.js is ready to use. Let’s implement the webserver application from the nodejs.org home page. We will use it as a starting point for our project: a RESTful API to access data (retrieve, create, update, delete) in a wine cellar database.
Create a folder named nodecellar anywhere on your file system. In the wincellar folder, create a file named server.js.
var db = mongoose.connect('mongodb://localhost:27017/DB'); | |
// In middleware | |
app.use(function (req, res, next) { | |
// action after response | |
var afterResponse = function() { | |
logger.info({req: req}, "End request"); | |
// any other clean ups |
This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.
I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.
Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.