🚩 TODO Explain some ES6 language features
Node 5 is awesome! <3 By default, it comes with lots of ES6 features.
Among them are, for example, arrow functions. And there's the spread operator which, in combination with the arguments object, makes writing a promisify()
function beautifully simple:
function promisify (foo) {
return function () {
Live example: http://codepen.io/abk955/pen/YwQmMJ
1. Creating the clock structure (in Jade
)
- The countdown clock is supposed to display seconds, minutes, hours and days.
Expands on Handling required parameters in ECMAScript 6 by Axel Rauschmayer.
The idea (which is credited to Allen Wirfs-Brock) is, in essence, to use default parameter values to call a function which throws an Error if the parameter is missing:
const throwIfMissing () => { throw new Error('Missing parameter') }
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
#!/usr/bin/env node | |
/* Usage: node file-gen [mb] | |
* | |
* Example: Generate a 1 GB file | |
* $ node file-gen 1024 | |
* time: 9163.383ms | |
*/ | |
const fs = require('fs') |
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
let | |
BaseUrl = "https://fake-odata-api.com/v1/Entities?", | |
Token = "F4K3-T0K3N-D0NT-U5E-L0L", | |
EntitiesPerPage = 1000, | |
GetJson = (Url) => | |
let Options = [Headers=[ #"Authorization" = "Bearer " & Token ]], | |
RawData = Web.Contents(Url, Options), | |
Json = Json.Document(RawData) | |
in Json, |
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
@ECHO off | |
:: delete all upgrade logs | |
:: >nul 2>&1 = drop stdout and stderr output | |
DEL UpgradeLog*.htm >nul 2>&1 | |
:: loop over all backup directories | |
FOR /d %%G IN (Backup*) DO ( | |
:: /s = remove all sub directories, too | |
:: /q = remove quietly, without confirmation |
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
@ECHO off | |
SET downloadUrl=https://api.github.com/users/marktiedemann | |
SET tempFile=%cd%\.%random%-tmp | |
BITSADMIN /transfer /download %downloadUrl% %tempFile% >nul | |
TYPE %tempFile% | |
DEL %tempFile% |
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 http = require('http') | |
const url = require('url') | |
const apiPort = 3000 | |
const proxyPort = 3001 | |
const apiResStatus = 200 | |
const apiResBody = `"Hi, I'm the API!"` | |
const clientReqMethod = 'GET' |
OlderNewer