ContentsContact

August 2019

24th August 2019

Have been looking at different Mapping solutions, tried Google Maps, it is very powerfull but probably to much for me, if I was doing this comercially then I can definitely see the benefits for some applications but as a hobby I dont want to sign up to the Google Cloud API's just for my simple use.

In the end I settled on using OpenStreetMap and Leaflet for my Favourite Pubs and using OS openspace for my Ancient UK Sites

I have recently moved to TypeScript using Node.js for my build processes rather than using the more common build tools for JavaScript.

My build scripts consisted of a number of syncronous functions which implementing in the generally asynchronous Node.js can leave you with some hard to read code with lots of nesting.

To overcome this and produce some readable code, I tried lots of different formats but in the end settled on using async/await.

The following example asks the user for some input, one question at a time, it uses readline which is an asyncronous function.

  
const fs = require('fs');

const readline = require('readline');

const readOneLine = (message) => {
    return new Promise((resolve, reject) => {
      var rl = readline.createInterface({
          input: process.stdin,
          output: process.stdout
      });
      rl.question(message, (answer) => {
        rl.close();
        resolve(answer);
      });
    });

}

var packageJSON;

const loadPackageJSON = () => {
    packageJSON = JSON.parse(
        fs.readFileSync('package.json')
        .toString());
}


// Main function
var main = async () => {
    console.log("Started");
    let server = 'n';
    try {

      // first load in package.json
      loadPackageJSON();

      // then ask user for setting for key main
      const appMainAnswer =
          await readOneLine(
                "main (" + packageJSON.main + ") >"
          );
      if (appMainAnswer !== "")
          packageJSON.main = appMainAnswer;

      // then ask the user for whether its a
      // server app or not
      const serverAnswer =
          await readOneLine(
                "server (" + server + ") y/n >"
          );
      if ( serverAnswer !== "")
          server = serverAnswer;

      // then output the settings
      console.log(
          "main set to: " + packageJSON.main
                          + " Server set to: "
                          + server);
    } catch (err) {
        // any error from the above will bubble up here
        console.log("failed: " + err);
    }
    console.log("Finished");
}

main();

  

16th August 2019

Have not posted anything for a year now, but have been doing lots of interesting (at least to me) stuff mostly with Golang and Javascript.

Have paused development on my archining system. I have something that works for me but it is still quite limited and not ready for general use. However out of making the command line client as well as a natural language interface I have drifted on to other projects.

© Jeremy Smith 2017, 2018, 2019