Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.
I've tried to make it as lean and unobtrusive as possible.
errors/AppError.js
Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma
You can get the list of supported formats with:
ffmpeg -formats
Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:
CTRL + A — Move to the beginning of the lineCTRL + E — Move to the end of the lineCTRL + [left arrow] — Move one word backward (on some systems this is ALT + B)CTRL + [right arrow] — Move one word forward (on some systems this is ALT + F)CTRL + U — (bash) Clear the characters on the line before the current cursor positionCTRL + U —(zsh) If you're using the zsh, this will clear the entire lineCTRL + K — Clear the characters on the line after the current cursor positionESC + [backspace] — Delete the word in front of the cursor| 'use strict'; | |
| // The purpose of this example is to show | |
| // how you can block the event loop with JavaScript. | |
| // There is 3 routes | |
| // / respond with Hello, World text | |
| // /block uses JavaScript while for 5 seconds | |
| // /non-block uses setTimeout for 5 seconds | |
| // Do the following |
| { | |
| "version": "0.2.0", | |
| "configurations": [ | |
| { | |
| "name": "Node Inspector", | |
| "type": "node", | |
| "request": "launch", | |
| "args": ["${workspaceRoot}/src/service.ts"], | |
| "runtimeArgs": ["-r", "ts-node/register"], | |
| "cwd": "${workspaceRoot}", |
A quick overview of the node.js streams interface with basic examples.
This is based on @brycebaril's presentation, Node.js Streams2 Demystified
Streams are a first-class construct in Node.js for handling data.
Think of them as as lazy evaluation applied to data.
| #/bin/sh | |
| ffmpeg -i input -c:v libx264 -preset slow -profile:v high -crf 18 -coder 1 -pix_fmt yuv420p -movflags +faststart -g 30 -bf 2 -c:a aac -b:a 384k -profile:a aac_low output |
| const Benchmark = require('benchmark'); | |
| const axios = require('axios'); | |
| const superagent = require('superagent'); | |
| var suite = new Benchmark.Suite; | |
| const targetUrl = 'http://httpbin.org/ip'; | |
| suite | |
| .add('axios', { |
Translations: Korean (by Yongwoo Lee)
Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.
I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).