Remove lock file when Mongo unclean shutdown
rm mongod.lock
Mike Driver
Acquired Stardust
d e v o n

I'd rather be in outer space 🛸
Keni
YOU ARE THE REASON
Game of Thrones Daily
art blog(derogatory)

祝日 / Permanent Vacation

⁂

★
Today's Document
Alisa U Zemlji Chuda
Cosimo Galluzzi

❣ Chile in a Photography ❣
he wasn't even looking at me and he found me
2025 on Tumblr: Trends That Defined the Year

ellievsbear
Peter Solarz

seen from Canada
seen from United States
seen from United States

seen from United States
seen from United States

seen from Malaysia
seen from United States
seen from United States

seen from United States
seen from Malaysia
seen from United States
seen from United States
seen from United States

seen from Malaysia
seen from United States
seen from United States
seen from United States

seen from United States
seen from United States

seen from Germany
@varmab
Remove lock file when Mongo unclean shutdown
rm mongod.lock

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
ES6 Promises are so cool !!!
getLotteryTickets: function() { var sql="SELECT Id, UserId, ShiftId, Start, End, Amount, CreatedDate FROM LotteryTicket" return new Promise( function (resolve, reject) { var data = []; database.executeSQL( sql, [], (row) => { data.push(row); }, (error) => { if (error) { reject(error); } else { resolve(data); } }); } ) },
Setting up quick crontab for your console node app
You can use quick native ubuntu crontab command to setup schedule for your node app.
Make sure you have cron installed on your ubuntu server.
$ sudo apt-get update
$ sudo apt-get install cron
Now setup your crontab.
$ cronttab -e
It opens editor to enter your cron command. You can add command like below to run your node script. Then Contrl + O to save changes and Cntrl+X to exit editor.
Following command runs every one minute. You can change schedule by changing cron frequency format from * * * * * to desired. You can google for valid formats for other time periods. here is one example http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/
* * * * * cd /home/ubuntu/apps && sudo /usr/local/bin/node today.js >> 'today.log'
You can view current crontab info
$ crontab -l
Crontab can be removed quickly. Make sure to backup your command script before removing it.
$ crontab -r
Install latest Node.js on Ubuntu
1. Copy link to Node.js Linux binary tar file from https://nodejs.org/download/
2. You can download this file from the browser or from the console. The latter is shown below (note: the specific Node.js version might be different for you):
$ wget http://nodejs.org/dist/v0.12.3/node-v0.12.3-linux-x64.tar.gz
3. From a console window, go to the directory where the Node.js binary was downloaded to, and then execute the following command to install the Node.js binary package in “/usr/local/”:
sudo tar -C /usr/local --strip-components 1 -xzf node-v0.12.3-linux-x64.tar.gz
4. You should now have both node and npm installed in “/usr/local/bin”. You can check this typing:
$ node -v
v0.12.3
$ npm -v
2.9.1
Mongoose querying Sub Document using underscore map and $in
var getThreadPosts=function(postId){ var deferred = Promise.pending(); db.threadModel.findOne({ 'threadposts.postid': postId }, function (err, postThread) { if (err) return deferred.reject(err); if(postThread != null) { var postIds = _.map(postThread.threadposts,function (threadPost) { return threadPost.postid; }); db.postModel.find({_id: {"$in": postIds}}, function (err, posts) { if (err) return deferred.reject(err); deferred.resolve(posts); }).sort({created: -1}); } else { var posts=[]; deferred.resolve(posts); } }); return deferred.promise; }

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Install Mongo & Node.js on Amazon Ubuntu Instance
To access your instance:
Open an SSH client. (find out how to connect using PuTTY)
Locate your private key file (wonupit.pem). The wizard automatically detects the key you used to launch the instance.
Your key must not be publicly viewable for SSH to work. Use this command if needed:
chmod 400 myserver.pem
4. Connect to your instance using its Elastic IP:
11.111.111.11
Example:
ssh -i myserver.pem [email protected]
Install Mongo
>sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
>echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
>sudo apt-get update
>sudo apt-get install -y mongodb-org
>sudo service mongod start
>tail -f /var/log/mongodb/mongod.log
Install Nodejs
>curl -sL https://deb.nodesource.com/setup | sudo bash -
>sudo apt-get install nodejs
>sudo apt-get install build-essential
Make sure to open 80, 443, 22 and any Node instance ports in your firewall inbound rules.
Update Mongo Collection for single new field
db.jobs.update({},{$set : { "fav" : false}} , true, true);
Get data from Kaltura using Node.js & Promises
Here is my route require('dotenv').load(); var Promise=require('bluebird'); var KalturaConstants = require('../kaltura/KalturaTypes.js'); var Kaltura = require('../kaltura/KalturaClient.js'); var KalturaClient = null; var Session = null; var pager = new Kaltura.objects.KalturaFilterPager(); pager.pageSize=10000; pager.pageIndex=1; exports.initialize = function(callback) { var config = new Kaltura.KalturaConfiguration(parseInt(process.env.KALTURA_PARTNERID)); KalturaClient = new Kaltura.KalturaClient(config); KalturaClient.session.start(function(session) { KalturaClient.setKs(session); Session = session; callback(); }, process.env.KALTURA_ADMINSECRET, process.env.KALTURA_USERID, KalturaConstants.KalturaSessionType.ADMIN, parseInt(process.env.KALTURA_PARTNERID), '10000'); } exports.listMedia = function(userid) { var deferred = Promise.pending(); var filter = new Kaltura.objects.KalturaMediaEntryFilter(); if(userid != undefined) { filter.userIdEqual = userid; } filter.nameMultiLikeOr="hd_still_1"; KalturaClient.media.listAction(function(results) { if (results.objectType === 'KalturaAPIException') { return deferred.reject(results); } deferred.resolve(results.objects); }, filter, pager); return deferred.promise; } Here is my app.js
var routes = require('./routes'); var _ = require('lodash'); routes.kaltura.initialize(function(){ routes.kaltura.listUser().then(function(users){
users.forEach(function(user) { console.log(user); if(user.id != null) { console.log(user.name); routes.kaltura.listMedia(user.id).then(function(media){ console.log(media); }).catch(function(){ console.error('Error'); }); } }); }).catch(function(){ console.error('Error'); }); });
Web Socket connection in Node.js w/ RabbitMQ and Jade
I have been playing with RabbitMQ since heard about it from local Node meetup. AMQP very cool and powerful protocol to do your data exchange between applications can be either client server or web or mobile. They are very fast.
I developed sample for my own learning based on this blog article.
https://blog.appfog.com/tutorial-rabbitmq-node-js-on-appfog/
I had to make few corrections to it to make it work on my mac.
Install and Run RabbitMQ on your mac.
https://www.rabbitmq.com/install-standalone-mac.html
Create new project in Webstorm 9 and copy these files in to project to run.
https://github.com/varmab/testmq
Dockerize your Node.js application in Digital Ocean SSD VPS
It is so easy to spinoff quick server at Digital Ocean with Docker already installed and configured (simply choose docker pre installed droplet).
You simply write your Dockerfile and upload to your server root along with your node app and then run docker build and docker run commands on the server via SSH to quickly containerize your node application in Docker.
$docker build -t varmab/mynodejs-server .
$docker run -d --name mynodejs-server -p 80:80 varmab/mynodejs-server:latest
More adventures coming soon..

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Quick rest api built using loopback Node.js framework
Developing rest API is breeze now using StrongLoop's Loopback and Webstorm 9.
Assuming you have node.js and npm are installed already on your mac.
Create new Webstorm 9 empty project
Go to View > Tool Windows > Terminal
Type following commands
1. Install Strongloop
$ npm install -g strongloop
$ npm install -g strong-studio
2. Bootstrap loopback app
$ slc loopback
Enter key twice to answer default app name and location to bootstrap.
After it complete,
$ strong-studio
It opens Studio in web browser where you can create new models and setup database connection to mongodb.
$ slc run
This command starts the node server where you can check generated API with nicely formatted API documentation.
Browse your REST API at http://0.0.0.0:3000/explorer Web server listening at: http://0.0.0.0:3000/
RSS feed parser command line program using Node.js
Install both cli and feedparser
$ npm install cli
$ npm install feedparser
make sure your js file had permission to execute
$ chmod +x gigpost.js
Run your js file now
$ ./gigpost.js
Install Node.js and NPM on mac
You can install both npm and node.js by installing package below
http://nodejs.org/
Uninstall any previous versions before installing above package.
See following stackoverflow for more tips on how to uninstall previous versions.
http://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x