git remote -v
# View existing remotes
git remote set-url origin https://github.com/user/repo2.git
# Change the 'origin' remote's URL
git remote -v
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
function isOdd(x) { | |
return new Promise((resolve, reject) => { | |
if (x == 11) throw new Error('11 is not allowed!'); | |
if (x % 2) { | |
resolve(x.toString() + ' is odd') | |
} | |
else { | |
reject(new Error(x.toString() + ' is even')); | |
} | |
}); |
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
const got = require('got'); | |
const stream = require('stream'); | |
const fs = require('fs'); | |
const { promisify } = require('util'); | |
const pipeline = promisify(stream.pipeline); | |
// instantiate the download stream - use options to set authorization header etc. if needed | |
let downStream = got.stream('https://example.com/download'); | |
downStream.on('response', response => { |
Encrypting text fields in Mongoose is easy using Node's built-in crypto module. You might want to do this if you're using MongoDB as a service (see the recent MongoHQ security breach); or, if you're storing OAuth tokens that could, in the wrong hands, screw with somebody's account on a 3rd party service. (Of course, you should never encrypt passwords: those should be hashed.)
Imagine you have a Mongoose model like that shown below, which is modified only slighly from the example on the MongooseJS homepage.
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var User = mongoose.model('User', {
name: String,