Script to fetch “range to sort” from google sheets not working (used to work)

I have data rows in multiple sections. I keep track of the start and end rows of each section in my google spreadsheet and they change dynamically as rows are inserted or deleted. I used App Script to fetch the current section X#:Y# from the spreadsheet and then run a script to sort it. This used to work perfectly, however, I recently did something that bricked it – and I cannot tell why…

Here’s an excerpt of the code:

function onEdit(){

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0];
  var editedCell = sheet.getActiveCell();
  var columnToSortBy = 5;
  var tableRange = [];
  tableRange[0] = sheet.getRange(2,32).getValue(); //A6:K17
  tableRange[1] = sheet.getRange(3,32).getValue(); //A59:K62
  var range0 = sheet.getRange(tableRange[0]);
  var range1 = sheet.getRange(tableRange[1]);

if(editedCell.getColumn() == columnToSortBy){   


    range0.sort( { column : columnToSortBy } )
    range1.sort( { column : columnToSortBy } )

}
}

undefined variable?!
*Note: I copied the script from another StackOverflow post. It has served me well for nearly 2 months.

I tried looking at the debugger and my variables all appear as undefined. I tried manually replacing tableRange[0] with (for example) “A2:K10” and the script works fine. But as soon as I try the old way it stops working… I’m thinking this is something to do with JS as I’m totally ignorant of the language. Could you please help me?

.setValue going to specific cell rather than the next row

For some reason, whenever I run this function, it first takes a very long time to execute but secondly always replaces in cell E9, rather than going to the next available cell (in this case E10).

This is my code:

    
    var RecruitRosterRange = RecruitRoster.getRange(1,1,RecruitRosterLastRow,7);

    var RecruitRosterRangeValues = RecruitRosterRange.getValues();
  
    var RecruitRosterRow = 8;
    while (RecruitRosterRow <= RecruitRosterLastRow)

      {
      if (RecruitRosterRangeValues[RecruitRosterRow-1][1] == "")        // Is Website ID cell blank?
      {
        RecruitRoster.getRange(RecruitRosterRow, 5).setValue(AutomationSheet.getRange(asFTAddWebID).getValue()); // Add Website ID to website ID column on Recruit Roster
        RecruitRosterRow = RecruitRosterLastRow+1;
      }
      //Repeats if not
      else 
      {
        RecruitRosterRow++;
      }
    }```

And this is my sheet:
[sheet][1]


  [1]: https://i.stack.imgur.com/k6kXm.png

If you need any additional screenshots or explanation, please let me know. Thank you!

error of Discord.js 13v “Syntax Error: agent ??= new https.Agent” on heroku

I recently tried to upload my new bot on 13v to heroku, but for my surprise it gives this error:

2021-12-24T19:32:08.411245+00:00 app[worker.1]: /app/node_modules/discord.js/src/rest/APIRequest.js:33
2021-12-24T19:32:08.411261+00:00 app[worker.1]: agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
2021-12-24T19:32:08.411262+00:00 app[worker.1]: ^^^
2021-12-24T19:32:08.411262+00:00 app[worker.1]:
2021-12-24T19:32:08.411262+00:00 app[worker.1]: SyntaxError: Unexpected token '??='
2021-12-24T19:32:08.411262+00:00 app[worker.1]: at wrapSafe (internal/modules/cjs/loader.js:1001:16)
2021-12-24T19:32:08.411263+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1049:27)
2021-12-24T19:32:08.411263+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2021-12-24T19:32:08.411263+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:950:32)
2021-12-24T19:32:08.411263+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:790:12)
2021-12-24T19:32:08.411264+00:00 app[worker.1]: at Module.require (internal/modules/cjs/loader.js:974:19)
2021-12-24T19:32:08.411264+00:00 app[worker.1]: at require (internal/modules/cjs/helpers.js:93:18)
2021-12-24T19:32:08.411265+00:00 app[worker.1]: at Object.<anonymous> (/app/node_modules/discord.js/src/rest/RESTManager.js:4:20)
2021-12-24T19:32:08.411265+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1085:14)
2021-12-24T19:32:08.411265+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2021-12-24T19:32:08.533679+00:00 heroku[worker.1]: Process exited with status 1
2021-12-24T19:32:08.589332+00:00 heroku[worker.1]: State changed from up to crashed
2021-12-24T19:34:09.000000+00:00 app[api]: Build started by user [email protected]
2021-12-24T19:34:22.000000+00:00 app[api]: Build succeeded
2021-12-24T19:34:22.191934+00:00 app[api]: Deploy b3f02b01 by user [email protected]
2021-12-24T19:34:22.191934+00:00 app[api]: Release v6 created by user [email protected]
2021-12-24T19:34:24.110959+00:00 heroku[worker.1]: State changed from crashed to starting
2021-12-24T19:34:26.145669+00:00 heroku[worker.1]: Starting process with command `node index.js`
2021-12-24T19:34:26.812717+00:00 heroku[worker.1]: State changed from starting to up
2021-12-24T19:34:27.250285+00:00 app[worker.1]: /app/node_modules/discord.js/src/rest/APIRequest.js:33
2021-12-24T19:34:27.250299+00:00 app[worker.1]: agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
2021-12-24T19:34:27.250299+00:00 app[worker.1]: ^^^
2021-12-24T19:34:27.250300+00:00 app[worker.1]:
2021-12-24T19:34:27.250300+00:00 app[worker.1]: SyntaxError: Unexpected token '??='
2021-12-24T19:34:27.250300+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1049:27)
2021-12-24T19:34:27.250301+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2021-12-24T19:34:27.250301+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:950:32)
2021-12-24T19:34:27.250301+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:790:12)
2021-12-24T19:34:27.250301+00:00 app[worker.1]: at Module.require (internal/modules/cjs/loader.js:974:19)
2021-12-24T19:34:27.250302+00:00 app[worker.1]: at require (internal/modules/cjs/helpers.js:93:18)
2021-12-24T19:34:27.250302+00:00 app[worker.1]: at Object.<anonymous> (/app/node_modules/discord.js/src/rest/RESTManager.js:4:20)
2021-12-24T19:34:27.250303+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1085:14)
2021-12-24T19:34:27.250303+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

but it runs perfectly from my pc, I tried things like delete the whole index.js except the scensials things, nothing worked

React render HTML from Object [duplicate]

I am building a react website. As part of the site, I have a cards which are rendered using a JS map function. It looks like this:

return (
  <div className="cards">
     {HomeCard.map((item) => (
        <Card image={item.image} heading={item.heading} text={item.text} />
     ))}
  </div>
)

This gets data from another file which contains this object:

const homeCardsText = [
    {
        id: 1,
        image: web_design,
        heading: "Web Design",
        text: "<strong>Lorem ipsum</strong> dolor sit amet, consectetur adipiscing elit. Maecenas leo arcu, sagittis eget varius vel, fringilla nec metus. Nullam ultrices felis nec fermentum tincidunt. Maecenas tincidunt commodo ante a dapibus"
    },
    {
        id: 2,
        image: web_dev,
        heading: "Web Development",
        text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas leo arcu, sagittis eget varius vel, fringilla nec metus. Nullam ultrices felis nec fermentum tincidunt. Maecenas tincidunt commodo ante a dapibus."
    },
    {
        id: 3,
        image: web_accessibility,
        heading: "Web Accessibility",
        text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas leo arcu, sagittis eget varius vel, fringilla nec metus. Nullam ultrices felis nec fermentum tincidunt. Maecenas tincidunt commodo ante a dapibus."
    },
];

export default homeCardsText;

Note very specifically in id:1 there are HTML tags. When this is rendered to the front end, the HTML becomes sanitized and renders as plaintext. How do I get this to render as HTML?

Showing data on an ag-grid using Flask

I’m a newbie at this and would appreciate some guidance. I’m trying to show some data from Python in an ag-grid on HTML, using Flask and JS, but don’t seem to getting anywhere. Could someone please help me ?

This is the Python code with the rowData that I want to show in an ag-grid:

from flask import Flask, render_template, request
import pandas as pd

app = Flask(__name__)

@app.route('/')
def settings():
    rowData = [{ make: "Toyota", model: "Celica", price: 35000 },
    { make: "Ford", model: "Mondeo", price: 32000 },
    { make: "Porsche", model: "Boxter", price: 72000 }]

    return render_template('settings.html', rowData=rowData)

I’ve put the ag-grid into a JS function and wanted to call it from the HTML:

function myFunc(rowData) {
      
     const columnDefs = [
        { field: "make" },
        { field: "model" },
        { field: "price" }
       ];

      // let the grid know which columns and what data to use
      const gridOptions = {
        columnDefs: columnDefs,
        rowData: rowData
      };
      
      // setup the grid after the page has finished loading
      document.addEventListener('DOMContentLoaded', () => {
          const gridDiv = document.querySelector('#myGrid');
          new agGrid.Grid(gridDiv, gridOptions);
      });
}

The HTML code:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Ag-Grid Basic Example</title>
    <script src="https://unpkg.com/ag-grid-community/dist/ag-grid-community.min.js"></script>
    <script src="app.js" type="text/javascript">
        myVar = myFunc({{rowData|tojson}})
    </script>
</head>
<body>
    <div id="myGrid" style="height: 200px; width:500px;" class="ag-theme-alpine"></div>
</body>
</html>

Convert React native BLE response from device

I’m writing to you as I need help converting a reply from BLE device, and I want to convert it to comprehensible data, but I’m failing to. I’m using React native BLE manager library, and the documentation for the bluetooth device Is like this.

"peripheral": "D6:AD:15:67:4A:A5", "service": "XXXXX-XXXXX-XXXXXX", "value": [85, 0, 255, 0, 0, 13, 0, 96, 93, 0, 0, 0, 0, 0, 49, 0, 0, 0, 1, 0]

enter image description here

Error: transaction underpriced while deploying to rinkeby

The below code just stops working at the line “Attempting to deploy from account: ..” in console and after sometime it gives “Trnsaction was not mined within 750s, please make sure your transaction was sent properly”, Earlier it was giving the error “transaction underpriced”, I tried adding gasPrice and increasing the gas price but still got the same result. can anyone help me out ?

const hdWalletProvider = require('@truffle/hdwallet-provider')
const Web3 = require('web3')
const { interface, bytecode } = require('./compile')

const provider = new hdWalletProvider(
  'fee brass payment tiny edge spoon control trophy provide rather harbor course',
  'https://rinkeby.infura.io/v3/53ed6ca9c43446a98fb1f9f799d2ca8f'
)

const web3 = new Web3(provider)

const deploy = async () => {
  const accounts = await web3.eth.getAccounts()

  console.log('Attempting to deploy from account:' + accounts[0])

  const result = await new web3.eth.Contract(JSON.parse(interface))
    .deploy({
      data: bytecode,
      arguments: ['hello there!'],
    })
    .send({ gas: '1000000', from: accounts[0] })

  console.log('Contract deployed to:' + result.options.address)
  provider.engine.stop()
}
deploy()

TypeError: null is not an object (evaluating ‘daysData.map’) – Trying to map over array of objects

Hope you’re all doing good, I’ve tried looking around for a specific answer regarding this issue I’m having in ReactJS where I’m trying to map over an array I’m fetching via my local system and I keep getting this error in the console:

TypeError: null is not an object (evaluating 'daysData.map')

Here is a snapshot of my bit of code where I’m initializing the array from fetch:
Fetched data to Array

And here it is in text format:

// Here I initalize the array with useState
  const [daysData, setDaysData] = useState(null);

  // Here is the port I'm fetching my array from.
  useEffect(() => {
    fetch('http://localhost:5001/chocolates')
      .then((resp) => resp.json())
      .then((data) => setDaysData(data));
  }, []);

  // Console logging is sending back the array with no issues
  console.log(daysData);

And here is the map function where I’m trying to render a with the ‘id’ key from the array:

Array.map not working

Here is the bit of code in text format:

{/* Here I'm getting the error " TypeError: null is not an object (evaluating 'daysData.map') " */}
      {daysData.map((day) => (
        <div>{day.id}</div>
      ))}

And here is an example of the array where I’ve fetched data from in which I’m trying to map over:
Array and Objects Within

Thanks for any help in advance

Why it doesn’t change colours? It’s JavaScript

Why doesn’t it change colours? Why do I have error: ts(1003)?

<html>
   <head>
       <script>
           var peso = prompt("Dime tu peso en kg")
           var altura = prompt("Dime tu altura en metros")
           var IMC = parseFloat(peso) / parseFloat(altura)**2
           if (IMC < 19) {
               document.write("Estás por debajo de tu peso ideal")
           } else {
               document.write("Obesidad")
           }
       </script>
   </head>
</html>

Flutter web with wcf service

I’m trying to call wcf service from flutter
Using https

It’s working from android emulator
But when I’m trying to call it from flutter web I get XMLhttprequest error

Any solution?????

JS Project to Teach kids alphabet

the prof. ask us to make aproject to tech alphabet and i doesnot know how to do it
can some one help with it
this is the description of the project :

In this project, you are required to implement a simple web application that allows kids in
schools to learn the basic English Alphabet. The basic idea is that, the user will choose
the number of letters he wants to learn, and when clicking on each letter, another page is
opened showing an image of something that begins with that letter. In addition, some user
interaction events are collected and stored in the localStorage object of the browser to be
used in subsequent versions of the project.
The application should look something like the following:

• It has an index.html page contains a number input and a button. The user chose
how many letters (from 1 up to 26) he wants to learn, then he presses OK.
A randomly chosen letters should be selected. For example, if the user wants to
learn 3 letters, he uses the number input field and chose 3, then presses OK and
after that he will get 3 randomly chosen letters from the English alphabet.

• The next step is for the user to click on one of the letters and then an Image is
displayed showing something that begins with that letter. Images are stored in a
folder for created for each letter (You should download some images from the
internet to use them in the project).


please guys i need your help the project has 25% of the Dgree of the course.

How to create a simple word fragmenter for English words?

I am working on a conlang (a fantasy language basically), and I would like to automatically translate various English words into the fantasy language. I already have a huge list of word bases which I have manually collected (words like “create”, “dig”, “house”, “cat”, “sophisticated”, etc.). Now I would like to take advantage of the fact that I have these word “bases” and use them to automatically translate/transcribe English words that are “derivatives” of the base words. So I am wondering basically how to construct a simple system in JavaScript to do that.

The goal for this question is just to do the first step in the transformation. That is, to split a word into its parts. Then given the word parts, I can easily convert it to my fantasy language with all its quirks no problem. I won’t distract you with those details. Instead, all I need to know how to do is effectively split an English word into its parts. It seems easy at first but then getting into the weeds a little I am not sure if I need to build a full-fledge character-by-character parser, or if I can do something a little more clunky and simple. It doesn’t really need to be the most efficient, just needs to get the job done.

I am just beginning, stuck at what to do for the first step. I have basically just captured the prefixes and suffixes I am considering for this small project.

const prefixes = [
  //  'con', // words starting with con aren't really prefixes they are part of the base word.
  'de', // "defrost"
  'un', // "unsatisfactory"
  'dis', // "discontinuation"
  'il', // not "illustrate" but "illegal"
  'in', // not "interesting" but "incomplete"
  'im', // "immortal"
]

// don't have every possible suffix, but here are the key ones I am considering.
const suffixes = [
  'ion', // "attribute" vs. "attribution" (drops the "e") or "compression" vs. "compress"
  'ify', // "dehumidify"
  'some', // "awesome"
  'ship', // "friendship"
  'hood', // "neighborhood"
  'ist', // "artist"
  'or', // "creator" but not "doctor"
  'er', // "interpreter" but not "mother"
  'ed', // "created"
  's', // "creates"
  'ing', // "creating"
  'ism', // "creationism"
  'ive', // "creative",
  'ity', // "creativity"
  'ible', // "responsible" but not "feasible"
  'able', // "knowledgeable"
  'ry', // "pleasantry"
  'ly', // "excitedly"
  'ily', // "fuzzily"
  'dom', // "kingdom"
  'ish', // "reddish" (doubles the "d")
  'ful', // "careful"
  'less', // "fearless"
  'est', // "tallest"
  'ness', // "cleverness"
  'ence', // "correspondence"
  'ance', // "resemblance"
]

/**
* Rules/facts:
*
* - if base word ends in '-e', then drop the 'e' to look for suffixes.
* - don't always drop the '-e', like "knowledgeable".
* - some words have multiple prefixes and suffixes, like "creationism" or "carefully".
* - some words are based off derived words, like "creativity" from "creative" from "create".
* - can try adding an extra letter to get to the prefix (adding "d" to "red" for "reddish")
*/

function convert(baseWord, testWord) {
  
}

The convert function should take a base word, and a “test” word (input), and first figure out if it matches, then if it does match, split it into its appropriate parts. Here is some desired input and output.

convert('knowledge', 'knowledgeable') // => { base: 'knowledge', suffixes: ['able'] }
convert('fearlessly', 'fear') // => { base: 'fear', suffixes: ['less', 'ly'] }
convert('glaring', 'glare') // => { base: 'glare', suffixes: ['ing'] }
convert('unsure', 'sure') // => { base: 'sure', prefixes: ['sure'] }
// this next one might be too hard, if so, can be skipped
convert('undeniable', 'deny') // => { base: 'deny', prefixes: ['un'], suffixes: ['able'] }
convert('random', 'knowledgeable') // => undefined
convert('knowledge', 'other') // => undefined

So then, I will simply iterate through my word list and desired words to split, and then split them into their parts. I will then take that metadata and use it to construct the final fantasy word. I am just not sure really where to begin on how to check for all these prefixes and suffixes in a word. Let’s walk through “undeniable” to see.

First, iterate through each prefix and check if it is there. I think we can assume for this project that there is only one prefix possibly attached. However (edge case), the word might begin with a prefix, but that prefix is part of the word! As in “illustrate”, so we can’t consume the prefix until we subsequently check if the full word follows. Which is why it starts to get confusing/convoluted. Then we check the main word, but if it ends in a vowel can try dropping the vowel and check that too. Or try changing a trailing y into i. Then if that matches, try matching the suffixes. If our suffix starts with a vowel, maybe try adding back the last letter from the main word to see if we can get a match (i.e. glare + glared). That seems like about it. But again I am not sure how to approach this from a parsing perspective, it seems quite hard.

how to log [ 1, 2 ,3] not [1.0,2.0,3.0] as my array? [closed]

I’m am very new to programming and trying to salve a programing puzzle/game.
It’s a Spiral Matrix and the result is correct but
my array is outputting .0 at the end of my arrays.

example

input is [ 1, 2, 3],
         [ 4, 5, 6],
         [ 7, 8, 9]

output is [1.0,2.0,3.0,6.0,9.0,8.0,7.0,4.0,5.0]

looking for [ 1, 2, 3, 6, 9, 8, 7, 4, 5]

the code I am using is from this youtube video.
LeetCode 54 Spiral Matrix in javascript

how do I Logger.log(result) without the .0?


    function myFunction() {
    matrix = [
    [ 1, 2, 3], 
    [ 4, 5, 6], 
    [ 7, 8, 9]
             ];
    // result array
    const result = [];
    // boundry varibals
    let left = 0;
    let top = 0;
    let right = matrix[0].length - 1;
    let bottom = matrix.length - 1;
    // starting direction clock wise
    let direction = 'right';
    // start loop
    while (left <= right && top <= bottom) {

    if (direction === 'right') {
      for (let i = left; i <= right; i += 1) {
        result.push(matrix[top][i]);
      }
      top += 1;
      direction = 'down';
    }

    else if (direction === 'down') {
      for (let i = top; i <= bottom; i += 1) {
        result.push(matrix[i][right]);
      }
      right -= 1;
      direction = 'left';
    }

    else if (direction === 'left') {
      for (let i = right; i >= left; i -= 1) {
        result.push(matrix[bottom][i]);
      }
      bottom -= 1;
      direction = 'up';
    }

    else if (direction === 'up') {
      for (let i = bottom; i >= top; i -= 1) {
        result.push(matrix[i][left]);

      }

      left += 1;
      direction = 'right';
    }
    }
    Logger.log(result);
    return result;
    }

I hope this question is simple I don’t know what else I should add the puzzle is from an indie game BitRunner it got me more into programming than I use to be in adding this info at the end because the post won’t submit if it has more code then words

download csv file in js display timestamp is not same with database

my Program is connection with firebase,in firebase the sensor timestamp is utc+8.but in my program to download csv file the time is display utc+0.how can i improve my program to let that csv file the time is UTC+8.

    default: {
        let csv = `uFEFF${['Timestamp'].concat(dataFields).join(',')}n`;
        for (const dataDocSnap of dataQrySnap.docs)
            if(dataDocSnap.get('object.data')) {
                csv += [dataDocSnap.get('timestamp').toDate().toISOString()]
                    .concat(dataFields.map((dataField) => dataDocSnap.get(`object.data.${dataField}`)))
                    .join(',') + 'n';
            }
        res.header('Context-Type', 'text/csv');
        res.attachment(`${sensorDocSnap.get('name') ?? sensorDocSnap.id}-${date.toFormat('yyyy-MM')}.csv`);
        res.send(csv);
        return;
    }

unable to use id of dynamically created cards using JS

i displayed some songs from firebase database to cards, i assigned the id of the cards dynamically, i want to use the id to play song on clicking it. But i am unable to use the playsong.addeventlistener. Error shows : playsong is undefined. what am i doing wrong?

onChildAdded(dbRef, (snapshot) => {

    var childKey = snapshot.key;
    console.log(childKey);
    var childData = snapshot.val();
    console.log(childData.SongName);
    
    let card = document.createElement("div");

    card.className = 'card';
    card.id = 'playsong';
   
   card.style.backgroundImage =  "url('https://firebasestorage.googleapis.com/v0/b/soundemic-4f707.appspot.com/o/"+childData.SongName+"%2FThumbnail?alt=media&token=c34ebabe-4bbd-4659-b4e4-ff22221376cb')";
 

  document.querySelector(".fresh-album-cards").appendChild(card);
  
  
   }), {
  onlyOnce: true     
};