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
| General API Info | |
| How to authenticate as a user, URL schema, secure and unsecured access and access limitations. | |
| >> Authentication | |
| Users API | |
| API for accessing and modifying user information. | |
| >> Searching for Users | |
| >> Getting User Information |
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 reqs = require('smart'), | |
| skills = require('javascript_html_css_mongodb'), | |
| passion = require('change_the_world_of_storytelling'); | |
| /** | |
| We are looking for talented + well-rounded developers to | |
| join storify.com's core engineering team. We are young, | |
| funded and picking up a lot of momentum. We run a pure | |
| Javascript stack, from node.js on the server, mongodb on the | |
| backend and jQuery on the browser. We are also | |
| fanatics about HTML5 and CSS3. |
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 reqs, skills, passion; | |
| reqs = require('smart'); | |
| skills = require('javascript_html_css_mongodb'); | |
| passion = require('change_the_world_of_storytelling'); | |
| /** | |
| We are looking for talented + well-rounded developers to | |
| join storify.com's core engineering team. We are young, | |
| funded and picking up a lot of momentum. We run a pure | |
| Javascript stack, from node.js on the server, mongodb on the | |
| backend and jQuery on the browser. We are also |
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
| /* usage | |
| node get_elapsed_time.js -u localhost -p 8000 */ | |
| var start, elapsed, end, argv, http; | |
| argv = require('optimist').argv; | |
| http = require('http'); | |
| if (argv.u.length == 0) return console.log('need url'); | |
| start = new Date(); | |
| http.get({ host : argv.u , port: (argv.p) ? argv.p : 80}, function(res){ | |
| console.log('\nnget console util\n'); |
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
| [ | |
| { | |
| "name" : "Mike", | |
| "count" : 3 | |
| }, | |
| { | |
| "name" : "chris", | |
| "count" : 4 | |
| }, | |
| { |
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
| > db.users.find(); | |
| { "_id" : ObjectId("4d82e8e0a212e32240e91d49"), "name" : "Mike" } | |
| { "_id" : ObjectId("4d8393086a370e29032422ce"), "name" : "Mike" } | |
| { "_id" : ObjectId("4d83930a6a370e29032422cf"), "name" : "Mike" } | |
| { "_id" : ObjectId("4d83930f6a370e29032422d0"), "name" : "chris" } | |
| { "_id" : ObjectId("4d8393106a370e29032422d1"), "name" : "chris" } | |
| { "_id" : ObjectId("4d8393126a370e29032422d2"), "name" : "chris" } | |
| { "_id" : ObjectId("4d8393136a370e29032422d3"), "name" : "chris" } | |
| { "_id" : ObjectId("4d8393176a370e29032422d4"), "name" : "jenn" } | |
| { "_id" : ObjectId("4d83931e6a370e29032422d5"), "name" : "denise" } |
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
| db.users.group({ key: { name:true }, | |
| cond: { "created_at"}, | |
| initial: { count: 0 }, | |
| reduce: function(obj,out) { out.count ++ ; }}); | |
| /* | |
| Note1: make sure you put the initial declaration above reduce or else the count variable never gets set | |
| Note2: group() can't handle more than 10000 unique keys, so for large dbs you are better off using straight up map reduce. | |
| */ |
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
| #!/bin/bash | |
| #author: csanz | |
| pid=`ps afx | grep "node" | grep "$1" | grep "app.js" | awk '{print $1'}` | |
| if [ -z $pid ] | |
| then | |
| echo "the node instance doesn't exists" | |
| fi | |
| if [ "$pid" != '' ] | |
| then |
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
| from file: https://github.com/ry/node/blob/6eca6b1ec05c5b386121a992dc7f6502f001f052/doc/api/http.markdown | |
| issue: you are getting the body length, but you are not passing it anywhere. | |
| var body = 'hello world'; | |
| response.writeHead(200, { | |
| 'Content-Length': body.length, | |
| 'Content-Type': 'text/plain' }); |
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
| > use sampledb | |
| switched to db sampledb | |
| > a = {"name" : "chris"}; | |
| {"name" : "chris"} | |
| > b = {"name" : "jenn"}; | |
| {"name" : "jenn"} | |
| > db.users.save(a) | |
| > db.users.save(b); | |
| > db.users.find(); | |
| {"_id" : ObjectId( "4d2a3decdf59a32a1973e8d3") , "name" : "chris"} |