Skip to content

Instantly share code, notes, and snippets.

View melissamarima's full-sized avatar

melissamarima

View GitHub Profile
melissa@simba:~/meeth-app$ cat /etc/init.d/mongod
#!/bin/sh -e
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.
set -e
INITSCRIPT="$(basename "$0")"
JOB="${INITSCRIPT%.sh}"
melissa@simba:/$ sudo chmod -R /data mongodb
chmod: invalid mode: `/data'
Try `chmod --help' for more information.
melissa@simba:/$ cd /data/
melissa@simba:/data$ ls -alt
total 12
drwxr-xr-x 3 melissa root 4096 2015-09-24 19:14 db
drwxr-xr-x 23 root root 4096 2015-09-15 00:47 ..
drwxr-xr-x 3 root root 4096 2013-01-31 07:45 .
melissa@simba:/$ sudo chown -R mongodb /data
melissa@simba:/$ ls -alt /data
total 12
drwxr-xr-x 3 mongodb root 4096 2015-09-24 19:14 db
drwxr-xr-x 23 root root 4096 2015-09-15 00:47 ..
drwxr-xr-x 3 mongodb root 4096 2013-01-31 07:45 .
melissa@simba:/$ mongo
MongoDB shell version: 2.6.11
connecting to: test
melissa@simba:/$ cat /etc/mongod.conf
# mongod.conf
# Where to store the data.
# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/var/lib/mongodb
melissa@simba:/var/lib$ tail -100 /var/log/mongodb/mongod.log
2015-09-24T19:27:44.705+0000 [initandlisten] recover : no journal files present, no recovery needed
2015-09-24T19:27:44.705+0000 [initandlisten]
2015-09-24T19:27:44.705+0000 [initandlisten] ERROR: Insufficient free space for journal files
2015-09-24T19:27:44.705+0000 [initandlisten] Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles
2015-09-24T19:27:44.705+0000 [initandlisten]
2015-09-24T19:27:44.705+0000 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
2015-09-24T19:27:44.705+0000 [initandlisten] dbexit:
2015-09-24T19:27:44.705+0000 [initandlisten] shutdown: going to close listening sockets...
2015-09-24T19:27:44.705+0000 [initandlisten] shutdown: going to flush diaglog...
melissa@simba:~/meeth-app$ mongo
MongoDB shell version: 2.6.11
connecting to: test
> ^C
bye
melissa@simba:~/meeth-app$ npm start
> meeth-app@0.0.0 start /home/melissa/meeth-app
> node ./bin/www
// models/Post.js mongoose schema for mongoDB
PostSchema.methods.upvote = function(cb) {
this.upvotes += 1;
this.save(cb);
};
// Now we create the route in our index.js:
router.put('/posts/:post/upvote', function(req, res, next) {
req.post.upvote(function(err, post){
if (err) { return next(err); }
// models/Post.js mongoose schema for mongoDB
// I'd like this method to take in param1 and param2
PostSchema.methods.thisMethod = function(cb) {
this.upvotes += 1;
this.save(cb);
};
// Now we create the route in our index.js:
router.put('/posts/:post/upvote', function(req, res, next) {
var param1 = "hi";
var param2 = 33;
@melissamarima
melissamarima / Sorella's JS
Created October 18, 2015 16:47
Trying to understand JS concurrency
function sum(x, cc) {
setTimeout(function() {
cc(x.l + x.r);
}, 100);
}
var a = {
l: 1,
r: 3
},
@melissamarima
melissamarima / freendoe.irc chat record
Created October 18, 2015 16:48
Trying to understand JS concurrency and promises
10-16-2015 freenode.irc #javascript
22:24] <melissamm> I still don't understand why it's so bad to force synchronous functions in the async node.js MEAN stack. Sure it waits around, but wouldn't promises also have to wait around to get resolved?
[22:25] <melissamm> (sorry my internet died for a bit, I might have not caught the answers to my previous question.)
[22:25] <oojacoboo> melissamm: the async nature of js is important
[22:25] <oojacoboo> it's the nature of how people read and interpret it, it's also one of the key benefits of the language
[22:26] <oojacoboo> if you want sync, use another language
[22:26] <melissamm> I think I'm missing something. Promises still waits around to get resolved. So that also takes long.
[22:26] <melissamm> nono I have to use Async, I'm using the MEAN stack
[22:26] <oojacoboo> melissamm: yes, and promises are optional