This file contains 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
// Start MongoDB service | |
launchctl start org.mongodb.mongod | |
// Stop MongoDB service | |
launchctl stop org.mongodb.mongod | |
// Make alias, for easier future | |
alias mongostart="launchctl start org.mongodb.mongod" | |
alias mongostop="launchctl stop org.mongodb.mongod" |
This file contains 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
// Minimal code to execute unix command using Node.js | |
// require the native `exec` module | |
var exec = require('child_process').exec | |
// run the exec command | |
exec("mkdir Musics"); |
This file contains 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
scp -i /path/to/key.pem <username>@<server ip address>:/path/to/file /path/to/file.txt |
This file contains 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
mongoexport --host dbhost --port 27017 --collection coll --csv --fields field1,field2 --out filename.csv --db dbname --query '{}' |
This file contains 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
# Get new tags from the remote | |
$ git fetch --tags | |
# Get the latest tag name | |
$ latestTag=$(git describe --tags `git rev-list --tags --max-count=1`) | |
# Checkout the latest tag | |
$ git checkout $latestTag |
This file contains 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
// Extracted from https://gentlenode.com/journal/node-3-restify-cheatsheet/44 | |
server.on( 'uncaughtException', function ( request, response, route, error ) { | |
// Emitted when some handler throws an uncaughtException somewhere in the chain. | |
// The default behavior is to just call res.send(error), and let the built-ins in restify handle transforming, | |
// but you can override to whatever you want here. | |
if ( process.env.NODE_ENV == 'production' ) { | |
var responseMessage = { |
This file contains 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 moment = require('moment') | |
// get this midnight and next moment object and convert into unix timestamp | |
// this midnight (1 minute after last midnight) | |
var thisMidnight = moment( moment().format('YYYY-MM-DD') + ' 00:01:00' ).unix() | |
// next midnight (1 minute before next midnight) | |
var nextMidnight = moment( moment().format('YYYY-MM-DD') + ' 23:59:00' ).unix() | |