This file contains hidden or 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
# 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 |
This file contains hidden or 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
.container{ | |
display: flex; | |
flex-direction: row | row-reverse | column | column-reverse; | |
flex-wrap: nowrap | wrap | wrap-reverse; | |
flex-flow: <‘flex-direction’> || <‘flex-wrap’>; | |
justify-content: flex-start | flex-end | center | space-between | space-around; // horizontally | |
align-items: flex-start | flex-end | center | baseline | stretch; // vertical-align | |
align-content: flex-start | flex-end | center | space-between | space-around | stretch; //multi line repartition | |
} |
This file contains hidden or 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
var a = [ -2, 1, -3, 4, -1, 2, 1, -5, 4 ], | |
now = 0, | |
prev = 0; | |
for ( var i = 0; i < a.length; i++ ) { | |
prev = Math.max( 0, prev + a[ i ] ); | |
now = Math.max( prev, now ); | |
} | |
console.log( now ); // 6 |
This file contains hidden or 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 rgbToLab( R, G, B ) { | |
R = ( R / 255 ); | |
G = ( G / 255 ); | |
B = ( B / 255 ); | |
if ( R > 0.04045 ) R = Math.pow( ( R + 0.055 ) / 1.055, 2.4 ); | |
else R = R / 12.92; | |
if ( G > 0.04045 ) G = Math.pow( ( G + 0.055 ) / 1.055, 2.4 ); | |
else G = G / 12.92; | |
if ( B > 0.04045 ) B = Math.pow( ( B + 0.055 ) / 1.055, 2.4 ); |
This file contains hidden or 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
var arr = "The quick brown fox jumps over the lazy dog".split( '' ); | |
arr.reduce( ( countMap, item ) => { | |
countMap[ item ] = ( countMap[ item ] || 0 ) + 1; | |
return countMap; | |
}, {} ); |
This file contains hidden or 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
var factorial = ( i, a ) => i < 2 ? a || 1 : factorial( i - 1, ( a || 1 ) * i ); | |
console.log( factorial( 5 ) ); // 120 |
This file contains hidden or 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 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 | |
}, | |
... | |
]; |
This file contains hidden or 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
var nodes = [ | |
{ | |
links: [ 1, 3 ], // node 0 is linked to node 1 and 3 | |
weightLinks: [ 5, 15 ], // the distance between node 0 and 1 is 5, between 0 and 3 is 15 | |
distance: Infinity | |
}, { | |
links: [ 0, 2 ], // node 1 is linked to node 0 and 2 | |
weightLinks: [ 5, 5, ], // the distance between node 1 and 0 is 5, between 1 and 2 is 5 | |
distance: Infinity | |
}, |
This file contains hidden or 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
var rgbToHex = ( r, g, b ) => "#" + ( ( 1 << 24 ) + ( r << 16 ) + ( g << 8 ) + b ).toString( 16 ).slice( 1 ); | |
var hexToRgb = ( hex ) => [ parseInt( hex.substring( 1, 3 ), 16 ), parseInt( hex.substring( 3, 5 ), 16 ), parseInt( hex.substring( 5, 7 ), 16 ) ]; | |
rgbToHex( 175, 25, 70 ); // #af1946 | |
hexToRgb( "#af1946" ); // [ 175, 25, 70 ] |
This file contains hidden or 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
'#' + Math.floor( Math.random() * 16777215 ).toString( 16 ); |