Hello {{name}} !!
{{! This is a comment, and it won't be rendered }}
# POST a JSON file and redirect output to stdout | |
wget -q -O - --header="Content-Type:application/json" --post-file=foo.json http://127.0.0.1 | |
# Download a complete website | |
wget -m -r -linf -k -p -q -E -e robots=off http://127.0.0.1 | |
# But it may be sufficient | |
wget -mpk http://127.0.0.1 | |
# Download all images of a website |
var matrix = [], | |
H = 4, // 4 rows | |
W = 6; // of 6 cells | |
for ( var y = 0; y < H; y++ ) { | |
matrix[ y ] = []; | |
for ( var x = 0; x < W; x++ ) { | |
matrix[ y ][ x ] = "foo"; | |
} | |
} |
const nodes = [ | |
{ | |
links: [ 1 ], // node 0 is linked to node 1 | |
visited: false | |
}, { | |
links: [ 0, 2 ], // node 1 is linked to node 0 and 2 | |
visited: false | |
}, | |
... | |
]; |
var nodes = [ | |
{ | |
links: [ 1 ], // node 0 is linked to node 1 | |
visited: false | |
}, { | |
links: [ 0, 2 ], // node 1 is linked to node 0 and 2 | |
path: [], | |
visited: false | |
}, | |
... |
var average = arr => arr.reduce( ( p, c ) => p + c, 0 ) / arr.length; | |
average( [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] ); | |
// 5 |
#!/usr/bin/env node | |
const http = require('http'); | |
const url = require('url'); | |
const fs = require('fs'); | |
const path = require('path'); | |
const [ runtime, scriptName, port = 3000, folder = process.cwd() ] = process.argv; | |
class Server { |
class Sheep { | |
constructor(name, weight) { | |
Object.assign(this, { name, weight }); | |
} | |
clone() { | |
return new Sheep(this.name, this.weight); | |
} |
class OrderStatus { | |
constructor(name, nextStatus) { | |
this.name = name; | |
this.nextStatus = nextStatus; | |
} | |
doSomething() { | |
console.log('Do nothing by default'); | |
} |
class ShoppingCart { | |
constructor(discount) { | |
this.discount = new discount(); | |
this.amount = 0; | |
} | |
checkout() { | |
return this.discount.apply(this.amount); | |
} |