A list of useful commands for the FFmpeg command line tool.
Download FFmpeg: https://www.ffmpeg.org/download.html
Full documentation: https://www.ffmpeg.org/ffmpeg.html
| 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')); | |
| } | |
| }); |
| 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 => { |
A list of useful commands for the FFmpeg command line tool.
Download FFmpeg: https://www.ffmpeg.org/download.html
Full documentation: https://www.ffmpeg.org/ffmpeg.html
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,