Notes2Share: Redis

node.js logo
123456
As explained on Wikipedia:

"Node.js is an open-source, cross-platform JavaScript run-time environment for executing JavaScript code server-side.

Notebook contents

Some of My Favorite Modules

Here is a ❓ about
the 🚧.

Take NoteπŸ”‘
This is how it typically works, but not always. We need to make this text bigger to see how it will respond for long notes. We need to make this text bigger to see how it will respond for long notes.

We need to make this text bigger to see how it will respond for long notes.

Warning
Be careful when performing this operation.

Beware
Be careful when performing this operation.

more text

module.exports = function (handlebars) {

    handlebars.registerHelper('note', function (text) {
        const c = callout('Note', '#1e73be', text);
        return new handlebars.SafeString(c);
    });

    handlebars.registerHelper('warning', function (text) {
        const c = callout('Warning', 'orange', text);
        return new handlebars.SafeString(c);
    });

    handlebars.registerHelper('danger', function (text) {
        const c = callout('Danger', 'red', text);
        return new handlebars.SafeString(c);
    });

    return handlebars;
}

dd

module.exports = function (handlebars) {

    handlebars.registerHelper('note', function (text) {
        const c = callout('Note', '#1e73be', text);
        return new handlebars.SafeString(c);
    });

    handlebars.registerHelper('warning', function (text) {
        const c = callout('Warning', 'orange', text);
        return new handlebars.SafeString(c);
    });

    handlebars.registerHelper('danger', function (text) {
        const c = callout('Danger', 'red', text);
        return new handlebars.SafeString(c);
    });

    return handlebars;
}
module.exports = function (handlebars) {

    handlebars.registerHelper('note', function (text) {
        const c = callout('Note', '#1e73be', text);
        return new handlebars.SafeString(c);
    });

    handlebars.registerHelper('warning', function (text) {
        const c = callout('Warning', 'orange', text);
        return new handlebars.SafeString(c);
    });

    handlebars.registerHelper('danger', function (text) {
        const c = callout('Danger', 'red', text);
        return new handlebars.SafeString(c);
    });

    return handlebars;
}

I am using Node v9.3.0 for all current development.

Tables2 Are Cool
col 1 is left-aligned $1600
col 2 is centered $12
col 3 is right-aligned $1

Sample code


var fetch = require('node-fetch');

// if you are on node v0.10, set a Promise library first, eg.
fetch.Promise = require('bluebird');

// plain text or html

text


fetch('https://github.com/')
.then(function(res) {
return res.text();
}).then(function(body) {
console.log(body);
});

JSON Modules πŸš€

json module

node-fetch


var fetch = require('node-fetch');

// if you are on node v0.10, set a Promise library first, eg.
// fetch.Promise = require('bluebird');

// plain text or html

more stuff


const got = require('got');
const geolib = require('geolib');

const delaySeconds = 3;
const url = 'http://api.open-notify.org/iss-now.json';
const myPosition = { latitude: 32.715738, longitude: -117.161084 };

function loop() {
got(url, { json: true })
.then(iss => {
const position = iss.body.iss_position;
const distanceFromIss = geolib.getDistance(myPosition, position);
const distanceFromIssMiles = geolib.convertUnit('mi', distanceFromIss, 2);
console.log(${distanceFromIssMiles} miles);
})
.catch(error => {
console.log(error.response.body);
});
setTimeout(loop, delaySeconds * 1000);
}

loop();

Tools

Section 2

Conclusion

Change Log

  • Jan 03 2018 hello

Last updated Jan 08 2018

Follow @thisDaveJ (Dave Johnson) on Twitter to stay up to date with the latest tutorials and tech articles.

Share