The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.
Send messages to iframe using iframeEl.contentWindow.postMessage
Recieve messages using window.addEventListener('message')
| // FROM https://gist.github.com/IkarosKappler/d3c39db08115085bcb18#file-fix_by_ikaros-js | |
| import * as THREE from "https://cdn.skypack.dev/three"; | |
| function transformSVGPath(pathStr) { | |
| const DIGIT_0 = 48, DIGIT_9 = 57, COMMA = 44, SPACE = 32, PERIOD = 46, | |
| MINUS = 45; | |
| const DEGS_TO_RADS = Math.PI/180.0; | |
| var path = new THREE.Shape(); |
| // check version | |
| node -v || node --version | |
| // list locally installed versions of node | |
| nvm ls | |
| // list remove available versions of node | |
| nvm ls-remote | |
| // install specific version of node |
| function insertImage() { | |
| let sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); | |
| let lastRow = sheet.getLastRow(); | |
| for (let i = 0; i < lastRow-1; i++) { | |
| let url = sheet.getRange(2+i,1).getValue(); | |
| let image = SpreadsheetApp.newCellImage().setSourceUrl(url); | |
| sheet.getRange(2+i,2).setValue(image); | |
| } |
| export default class EventEmitter | |
| { | |
| constructor() | |
| { | |
| this.callbacks = {} | |
| this.callbacks.base = {} | |
| } | |
| on(_names, callback) | |
| { |
| import * as React from "react" | |
| import { useState, useEffect } from "react" | |
| // Hook | |
| let cachedScripts = [] | |
| export function useScript(src) { | |
| // Keeping track of script loaded and error state | |
| const [state, setState] = useState({ | |
| loaded: false, |
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
| /** | |
| * Making a spiral of size N x N and output the drawing out to the console. | |
| * For example, when n = 10, this is how the output spiral will look like: | |
| * * * * * * * * * | |
| * * | |
| * * * * * * * | |
| * * * * | |
| * * * * * | |
| * * * * * * |
| class Spiderman { | |
| lookOut() { | |
| alert('My Spider-Sense is tingling.'); | |
| } | |
| } | |
| let miles = new Spiderman(); | |
| miles.lookOut(); |