restore snapshot shell !#/bin/bash wget tar xvf node-v12.13.1-linux-x64.tar.xz export PATH=/home/ubuntu/node-v12.13.1-linux-x64/bin:$PATH wget sudo apt update sudo apt install unzip unzip mv Final\ Source\ Code/ sls sudo apt install python-pip pip install awscli which aws_completer cp ~/.bashrc ~/.bashrc_orig tee -a ~/.bashrc <<-'EOF' complete -C '/home/ubuntu/.local/bin/aws_completer' aws export PATH=/home/ubuntu/node-v12.13.1-linux-x64/bin:$PATH EOF aws configure npm install claudia -g claudia -v 5.11.0 cd chapter-03 npm install claudia create \ --region ap-northeast-1 \ --api-module api packaging files npm install -q --no-audit --production npm WARN pizza-api@1.

Gatsby Debug

Debugging the Build Process Gatsby’s build and develop steps run as a Node.js application which you can debug using standard tools for Node.js applications. Debugging with Node.js’ built-in console console.log(args) VS Code Debugger (Auto-Config) Preferences: Type node debug into the search bar. Make sure the Auto Attach option is set to on. launch.json launch.json { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes.

Gatsby Notes

bind eip gatsby develop -- --host= Prettier VS Code plugin JSX The hybrid “HTML-in-JS” is actually a syntax extension of JavaScript, for React, called JSX In pure JavaScript, it looks more like this: src/pages/index.js import React from "react" export default () => React.createElement("div", null, "Hello world!") Now you can spot the use of the ‘react’ import! But wait. You’re writing JSX, not pure HTML and JavaScript. How does the browser read that?

Nodejs Xpath名字空间

如果xml文件带有名字空间,XPATH支持 还不够完善。下面介绍两种可以工作的方式 namespace for XML documents http.get("", function(res) { useNamespaces const select = xpath.useNamespaces({"ns0": ""}); const nodes = select("//ns0:loc", doc); nodes.forEach((value) => console.log("ns0:"+value)); Implementing a Default Namespace Resolver const nsResolver = function nsResolver(prefix) { const ns = { 'ns0' : '', 'mathml': '' }; return ns[prefix] || null; }; nsResolver.lookupNamespaceURI = nsResolver; var result = xpath.evaluate( "//ns0:loc", // xpathExpression doc, // contextNode nsResolver, // namespaceResolver xpath.XPathResult.ANY_TYPE, // resultType null // result ) node = result.


与回调函数的区别 不用写错误条件if (err) return callback(err) Promise能被作为对象返回并被后期调用 回调 function successCallback(result) { console.log("Audio file ready at URL: " + result); } function failureCallback(error) { console.error("Error generating audio file: " + error); } createAudioFileAsync(audioSettings, successCallback, failureCallback); promise const promise = createAudioFileAsync(audioSettings); promise.then(successCallback, failureCallback); or createAudioFileAsync(audioSettings).then(successCallback, failureCallback); 状态 Promise有三种状态 pending: Initial Case where promise instantiated. fulfilled: Success Case which means promise resolved. rejected: Failure Case which means promise rejected.


对象创建有如下几种方式 使用{} let animal = {} = 'Leo' = 10 = function (amount) { console.log(`${} is eating.`) += amount } animal.sleep = function (length) { console.log(`${} is sleeping.`) += length } = function (length) { console.log(`${} is playing.`) -= length } 构造函数 function Animal (name, energy) { let animal = {} = name = energy = function (amount) { console.

Nodejs Notes

set registry npm config set registry= npm config ls -l userconfig = "C:\\Users\\Administrator\\.npmrc" declare variables ES6 comes with two more options to declare your variables: const and let. In JavaScript ES6, you will rarely find var anymore. A variable declared with const cannot be re-assigned or re-declared. It cannot get mutated (changed, modified) Immutability is embraced in React and its ecosystem. That’s why const should be your default