Splitting sheet text using an array to mantain unique ID

I’m using this: How to transpose and split in Google Apps Script?

Which works great in the first part (I use it to copy data an split it) but then I would need to redo it since I have 2 different separators, first time “;” second time “,”.

The issue and I’m guessing it’s more JS related than anything else, is that if I use the same for it splits the 2nd column vertically. I’ll post examples.

Column A has the ID, Column B has the comma separated text

If I use it again to reformat it gives this:

enter image description here

I would like it to be split into Column B and C.

I figured it was because the for loop only pushes 2 rows, but I can’t solve adding a third.

Passing an object to a component as prop

I’m very green at react, and I’m trying to learn the library by messing around a bit.

I’m having problems passing an object to another component.
Ive created an array of objects that holds 2 string variables, 1 function and 1 int.

I’m trying to populate this inside a Grid container(Material UI framework).

When I pass the object to the other react component, it arrives as undefined. Ive tried to check if I’m passing a valid object by logging it to the console first, and it is valid.

I’ve also tried to refer to the properties in the component that receives the object, but the browser console throws Uncaught TypeError: Cannot read properties of undefined (reading 'person').

Does anyone know why it is being sent as undefined?

PersonList.js:

const personListe = [
    {
        firstName:'testFirstname',
        lastName:'testLastName',
        getFullName:function()
        {
            return `${this.firstName} ${this.lastName}`
        },
        age:28
    }
]

export default function PersonList() {
    
  return (
      <>
        <Grid container spacing={3}>
            {personListe.map((person) => {
                 return(
                    <Grid item xs={3} key={person.firstName}>
                    <PersonCard person={person} />   
                    </Grid>
                )
            })}
        </Grid>
    </>
  );
}

PersonCard.js:

export default function PersonCard({props})
{
    return (<>
        {console.log(props)}
    </>)
}

One submit button works on my form the other one refreshes the website while updating the url

Im trying to make a quiz using forms and the top submit button works perfectly while the bottom button does not work it ends up refreshing the page and it says the field selected in the address bar this is for a project for college and im a beginner to JavaScript if someone could help me out and explain how it works that would be great I understand how the script works with one from and one button and what the code does but im confused when it comes to 2 forms

var form = document.querySelector("form");
var log = document.querySelector("#log");
var points = 0;
var q1QuizAns = 0;
var q2QuizAns = 0;

form.addEventListener("submit", function(event) {
  var data = new FormData(form);
  var output = "";
  for (const entry of data) {
    output = output + entry[0] + "=" + entry[1] + "r";
    q1QuizAns = entry[1];
    q2QuzAns = entry[1];
  };
  log.innerText = output;
  event.preventDefault();
  pointsAdd();
}, false);

function pointsAdd() {
  if (q1QuizAns == 1) {
    points = points + 1;
    logPoints.innerText = points;
  } else if (q2QuizAns == 1) {
    points = points + 1;
    logPoints.innerText = points;
  }
}
<header>
  <ul class="navbar">
    <li><a href="Home.html">Home</a></li>
    <li><a href="Poland.html" class="active">Poland</a></li>
    <li><a href="Russia.html">Russia</a></li>
    <li><a href="Uzbekistan.html">Uzbekistan</a></li>
  </ul>
</header>

<div class="testBody">
  <div class="bodyText">
    <h1>Poland Test</h1>

    <form>
      <p>Please select your preferred contact method:</p>
      <div>
        <input type="radio" id="contactChoice1" name="question1" value="1">
        <label for="contactChoice1">Warsaw</label>
        <input type="radio" id="contactChoice2" name="question1" value="2">
        <label for="contactChoice2">Krakow</label>
        <input type="radio" id="contactChoice3" name="question1" value="3">
        <label for="contactChoice3">Straszyn</label>
      </div>
      <div>
        <button type="submit">Submit</button>
      </div>
    </form>
    <!-------------------------------------------------------------------------->
    <form>
      <p>What is the national animal of Poland</p>
      <div>
        <input type="radio" id="Question2Choice1" name="question2" value="1">
        <label for="Question2Choice1">White-Tailed Eagle</label>
        <input type="radio" id="Question2Choice2" name="question2" value="2">
        <label for="Question2Choice1">Black-Tailed Eagle</label>
      </div>
      <div>
        <button type="submit">Submit</button>
      </div>
    </form>
    <!-------------------------------------------------------------------------->
    <pre id="log">
        </pre>
    <pre id="logPoints"></pre>
    <!-------------------------------------------------------------------------->

  </div>
</div>

How to add Markes to a Leaflet-map with coordinates from Supabase database?

i want to add some Markers from coordinates stored in a supabase database colomn.
Here is my vue code:

<l-marker v-for="(marker, index) in markers" :key="index" ref="markersRef" :lat-lng="marker.position"></l-marker>

im script:

  export default {
   async created() {
    const { data: events, error } = await this.$supabase
     .from('events')
     .select('coordinates')
    this.markers = events
    this.loaded = true
    console.log(this.markers)
    
   },
  data: () => ({
   markers: [],
  }),
 }

if i output markes, the rusult is:

[ { “coordinates”: “lat: 59.339025, lng: 18.065818” }, { “coordinates”: “lat: 59.923043, lng: 10.752839” } ]

i hope you can help me. thanks.

Safari jquery select option .hide() alternative

I have a jquery script which at first hide all select options:

$('option[data-start="1"]').hide();

and then shows options based on user select of other input.

$('option[data-variable1="' + variable1x + '"][data-variable2="' + variable2x + '"]').show();

Everything works great, but on Safari .hide() doesn’t work.
I know about workaround:

$('option[data-start="1"]').prop('disabled', true);
$('option[data-variable1="' + variable1x + '"][data-variable2="' + variable2x + '"]').prop('disabled', false);

But this only turns off some options. I have dozens of options, so there is long list of inactive options.
I tried hiding inactive options, but Safari probably ignores this code:

select option[disabled="disabled"]{display:none !important;width:0;height:0;visibility: hidden;opacity:0;}
select option:disabled { display:none !important;height:0;width:0;visibility: hidden;opacity:0;}

Could you help me with some workaround for Safari?

Getting an error when trying to run my test in webdriverio

I have been having an issue when trying to run my webdriverio tests after trying to upgrade my node version. I am now getting the following error

2022-01-11T12:45:05.628Z DEBUG @wdio/config:utils: Couldn't find ts-node package, no TypeScript compiling
2022-01-11T12:45:05.729Z ERROR @wdio/config:ConfigParser: Failed loading configuration file: /Users/eoincorr/Downloads/coding/DSI_UI_TESTS/wdioTest.conf.js: Cannot find module 'csv-stringify/sync'

Can someone please advise me on why this is happening and what to do?

Capture text inside multiple header tags with regex [duplicate]

Given a string with multiple html tags inside (headers and other), I’d like to extract all text inside multiple header tags.

A given string : '<h1>Header 1</h1> <p>blabla</p> <h2>Header 2</h2>'

Expected result : ['Header 1', 'Header 2']

I came up with this : /<h[1-9]>(.*)</h[1-9]>/g; but it works only for a single occurrence.

Javascript arrow funtions with a function as parameter

I am trying to understand this arrow function declaration but I can’t. Someone can explain what is getFooOfImpl in this funtion and why there’s several async declarations? Thank you

const getFooOfId = (getFooOfIdImpl = async (fooId) => { throw new Error(`Can't retrieved foo of id ${fooId} : missing implementation`) }) => async fooId => {
 try {
    const fooData = await getFooOfIdImpl(fooId);
    return FooData(fooData);
  } catch (err) {
    throw new Error(`Unable to retrieve Foo with id ${fooId}`);
  }
}

Chrome extension – storage change listener in popup

I’m creating both web app and react chrome extension. I want the extension to show current web app auth status (stored in cookies). The following code below works (background script listens to cookies changes and store current value in storage, and popup script pulls every 1s the current value from storage), but I wonder whether this pulling is a right way to do it. I tried using chrome.storage.onChanged in popup script, but it was fired only once.

background.js

const domainName = 'localhost' // address of my web app
const cookieName = 'user'

chrome.cookies.onChanged.addListener(({ cookie, removed: isBeingRemoved }) => {
    if (cookie.domain === domainName && cookie.name === cookieName) {
        chrome.storage.sync.set({
            [cookieName]: !isBeingRemoved
                ? cookie.value
                : null,
        })
    }
})

popup.jsx

const [user, setUser] = useState(null)

const pullVariablesFromStorage = () => {
        chrome.storage.sync.get(['user'], function ({ user }) {
            setUser(user)
        })
}

 useEffect(() => {
        pullVariablesFromStorage()

        const intervalId = setInterval(() => {
            pullVariablesFromStorage()
        }, 1000)

        return () => clearInterval(intervalId)
 }, [])

return (
   <div>{user ? `Hi ${user}` : 'sign in using web app'}</div>
)

Test if Child components exist and render correctly inside Parent component in react native

I’m trying to test a Parent component that contains three child components

my parent component look like this:

<SafeAreaView
        testID="welcome-screen"
        edges={['left', 'right', 'top']}
        style={[styles(colors).container]}>
        <StatusBar barStyle={'light-content'} backgroundColor={'black'} />
        <Animatable.View
            animation={isAnimationsFinish ? upTopBar : absoluteScreen}>
            <ShowInitialUserDetails />
        </Animatable.View>
        <View style={styles(colors).scroll_and_button}>
            <ScrollView
                contentContainerStyle={styles(colors).userDetailsContainer}>
                <RegularTextStyle color={colors.SOFT_BLACK} size={14}>
                    To proceed, Please fill up the following fields.
                </RegularTextStyle>
                <Animatable.View
                    animation={upUserDetailsScreen}
                    style={styles(colors).userDetailsViewContainer}>
                    {}
                    <TitleAndTextInput
                        title="Your phone number"
                        placeHolder="Phone number"
                        inputType=""
                    />
                </Animatable.View>
            </ScrollView>
            <SimpleButton
                title="Continue"
                isVisible={isAnimationsFinish ? true : false}
                onPress={() => resetTo(HOME_NAVIGATOR)}
            />
        </View>
    </SafeAreaView>

and my test file look like this:

import { render, waitFor } from '@testing-library/react-native';
import { Provider } from 'react-redux';
import store from '../../../state/store';
import React from 'react';
import WelcomeScreen from '../WelcomeScreen';
import RegularTextStyle from '../../../components/texts/RegularTextStyle';
import { View } from 'react-native';
import TitleAndTextInput from '../../../components/TitleAndTextInput';
import ShowInitialUserDetails from '../components/ShowInitialUserDetailsComponent';
import * as Animatable from 'react-native-animatable';
import { shallow } from 'enzyme';
import Enzyme from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
Enzyme.configure({ adapter: new Adapter() });

jest.mock('react-native-animatable', () => {
   const ReactRef = jest.requireActual('react');
   return {
       // ...actual,
       View: class extends ReactRef.Component {
           render() {
               return <></>;
           }
       },
   };
});

jest.mock('../../../components/texts/RegularTextStyle', () =>
   jest.fn().mockReturnValue(null),
);
jest.mock('../../../components/TitleAndTextInput', () =>
   jest.fn().mockReturnValue(null),
);
jest.mock('../components/ShowInitialUserDetailsComponent', () =>
   jest.fn().mockReturnValue(null),
);

describe('Welcome Screen test', () => {
   //TEST NUMBER 1 -WORKING
   it('Should render currectly', async () => {
       const { getByTestId } = render(
           <Provider store={store}>
               <WelcomeScreen />
           </Provider>,
       );
       await waitFor(() => {
           const welcomeContainer = getByTestId('welcome-screen');
           expect(welcomeContainer).toBeDefined();
       });
   });
    //TEST NUMBER 2 - WORKING
   it('should render RegularTextStyle currectly ', () => {
       (RegularTextStyle as jest.Mock).mockReturnValue(
           <View testID="mock-regular-textStyle" />,
       );

       const { getByTestId } = render(
           <Provider store={store}>
               <WelcomeScreen />
           </Provider>,
       );
       getByTestId('mock-regular-textStyle');
   });

    //TEST NUMBER 3 -  NOT WORKING!
   it('should render TitleAndTextInput  currectly ', async () => {
       (TitleAndTextInput as jest.Mock).mockReturnValue(
           <Animatable.View testID="test" />,
       );
       const { getByTestId } = render(
           <Provider store={store}>
               <WelcomeScreen />
           </Provider>,
       );
       getByTestId('test');
   });

    //TEST NUMBER 4 -  NOT WORKING!
   it('should render ShowInitialUserDetails currectly', () => {
   const wrapper = shallow(
       <Provider store={store}>
           <WelcomeScreen />
       </Provider>,
   );
   expect(wrapper.find(<ShowInitialUserDetails />)).toHaveLength(1);
});

as you can see test number 1 and 2 working fine
but test number 3 that look the same as test number 2 exepct that he is insdie Animated.View, throw Error:

    Unable to find an element with testID: test

For test number 4 I received this error when I used the Enzyme library

expect(received).toHaveLength(expected)

Expected length: 1
Received length: 0
Received object: {}

Could someone please tell me what I am doing wrong with this test or how I should test my child component?
thanks!

UI automation with Protractor – promise handling with async await

We have taken Page Object Model (POM) approach. It works perfectly fine when ‘Control Flow’ is enabled.
But when we disable ‘Control Flow’ in conf.js file by flag SELENIUM_PROMISE_MANAGER: false
and apply Async/Await we are getting following error message:-

    S D:oldcode> protractor Conf.js
    [15:37:02] I/launcher - Running 1 instances of WebDriver
    [15:37:02] I/direct - Using ChromeDriver directly...
     DevTools listening on ws://127.0.0.1:64832/devtools/browser/1d68c5dc-5b58-495a-9db9- 
     c1d45c531723
     Started
     .
     
     1 spec, 0 failures       
     Finished in 0.018 seconds
     
     [15:37:07] E/launcher - Error while waiting for Protractor to sync with the page: "both 
     angularJS testability and angular testability are undefined.  This could be either 
     because this is a non-angular page or because your test involves client-side navigation, 
     which can interfere with Protractor's bootstrapping.  See http://git.io/v4gXM for 
     details"
     [15:37:07] E/launcher - Error: Error while waiting for Protractor to sync with the page: 
     "both angularJS testability and angular testability 
     are undefined.  This could be either because this is a non-angular page or because your 
     test involves client-side navigation, which can interfere with Protractor's 
     bootstrapping.  See http://git.io/v4gXM for details"
     at C:UsersDbindalAppDataRoamingnpmnode_modulesprotractorbuiltbrowser.js:461:23
     at processTicksAndRejections (node:internal/process/task_queues:96:5)Error
     at ElementArrayFinder.applyAction_ 
     (C:UsersDbindalAppDataRoamingnpmnode_modulesprotractorbuiltelement.js:459:27)
     at ElementArrayFinder.<computed> [as click] 
     (C:UsersDbindalAppDataRoamingnpmnode_modulesprotractorbuiltelement.js:91:29)        
    at ElementFinder.<computed> [as click] 
    (C:UsersDbindalAppDataRoamingnpmnode_modulesprotractorbuiltelement.js:831:22)
    at demoPage.submit (D:oldcodepage.js:34:18)
    at UserContext.<anonymous> (D:oldcodedemo13_spec.js:13:16)
    at 

C:UsersDbindalAppDataRoamingnpmnode_modulesprotractornode_modulesjasminewd2index.js:112:25
at new Promise ()
at SimpleScheduler.promise
(C:UsersDbindalAppDataRoamingnpmnode_modulesprotractornode_modulesselenium-
webdriverlibpromise.js:2242:12)
at schedulerExecute

(C:UsersDbindalAppDataRoamingnpmnode_modulesprotractornode_modulesjasminewd2index.js:95:18)
at C:UsersDbindalAppDataRoamingnpmnode_modulesprotractornode_modulesselenium-
webdriverlibpromise.js:2232:22
[15:37:07] E/launcher – Process exited with error code 199
PS D:oldcode> [7160:14332:0111/153709.074:ERROR:device_event_log_impl.cc(214)]
[15:37:09.074] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node
connection: A device attached to the system is not functioning. (0x1F)
[7160:14332:0111/153709.077:ERROR:device_event_log_impl.cc(214)] [15:37:09.077] USB:
usb_device_handle_win.cc:1048 Failed to read descriptor
from node connection: A device attached to the system is not functioning. (0x1F)
[7160:21072:0111/153709.120:ERROR:chrome_browser_main_extra_parts_metrics.cc(226)]
crbug.com/1216328: Checking Bluetooth availability started. Please report if there is no
report that this ends.
[7160:21072:0111/153709.128:ERROR:chrome_browser_main_extra_parts_metrics.cc(229)]
crbug.com/1216328: Checking Bluetooth availability ended.
[7160:21072:0111/153709.129:ERROR:chrome_browser_main_extra_parts_metrics.cc(232)]
crbug.com/1216328: Checking default browser status started. Please report if there is no
report that this ends.
[7160:21072:0111/153709.143:ERROR:chrome_browser_main_extra_parts_metrics.cc(236)]
crbug.com/1216328: Checking default browser status ended.
[2632:18876:0111/153905.755:ERROR:gpu_init.cc(457)] Passthrough is not supported, GL is
disabled, ANGLE is

We have used two .js files. One for locators and action methods is page.js and its code is as below
let demoPage = function () {

      let prefix = element(by.xpath("//input[@value = 'Mr']"));
      let firstname = element(by.id('first-name'));
      let lastname = element(by.id('last-name'));
      let subject = element(by.xpath("//input[@value = 'Computers']"));
      let street = element(by.id('street'));
      let city = element(by.cssContainingText('option', 'Delhi'));
      let zip = element(by.id('zip'));
      let submit = element(by.xpath("//button[@type = 'submit']"));
      let link = element(by.partialLinkText('Link'));
      let hover = element(by.xpath('//*[contains(text(), "Mouse Over")]'))

      this.get= async function(url){
           await browser.get(url);
           await browser.manage().window().maximize();
           expect(await browser.getCurrentUrl()).toBe('http://localhost:4200/');
         }

     this.submit= async function(fn, ln, str, zp){
     await prefix.click();
     await firstname.click().sendKeys(fn);
     await lastname.click().sendKeys(ln);
     await subject.click();
     await street.click().sendKeys(str);
      await city.click();
     await zip.click().sendKeys(zp);
    await browser.actions().mouseMove(hover).perform();
    text= await browser.driver.switchTo().alert().getText();
    console.log(text);
    await browser.driver.switchTo().alert().accept();
    await submit.click();
    }
    };
    module.exports = new demoPage();

The other test file is testspec.js and its code is as follow –

       let demoPage = require('./page');
      describe('mySuite', function () {
     it('Test case', function () {
       demoPage.get("http://localhost:4200/");
       demoPage.submit("John", "Smith", "CP", "110001");
      });
    });

It would be great if the community here guide me in finding a solution. I am thankful in advance for the invaluable advice from fellow members.

How to fetch Amazon Cognito Identity ID (user_identity_id) for the user from the lambda function?

In the Amplify documentation, under the Storage/File access levels section there is a paragraph that states:

Files are stored under private/{user_identity_id}/ where the user_identity_id corresponds to the unique Amazon Cognito Identity ID for that user.

How to fetch user_identity_id from the lambda function?

Request to the lambda is authorized, the event.requestContext.authorizer.claims object is available, I can see the user data, but not the user_identity_id.

Not able to save object value in Angular component

This is component class for example:

export class AppComponent {

  categories = {
     country: [],
     author: []
  }

  constructor(){}

  getOptions(options) {
     options.forEach(option => {
        const key = option.name;
        this.categories[key].push(option.value);
     })
  }
  
}

On clicking a button, I am calling getOptions(options) from different component. The structure of options looks like:

options = [
  {name: 'country', value: 'Germany'},
  {name: 'author', value: 'Franz Kafka'}
]

So now the value of this.categories will get updated, so now:

this.categories[country] = ["Germany"]
this.categories[author] = ["Frank Kafka"]

Value of options changes every time on clicking the button. When I am sending new options value such as:

options = [
  {name: 'country', value: 'Japan'},
  {name: 'author', value: 'Masashi Kishimoto'}
]

Old value for this.categories[country] is not getting saved for some reason. The new value for this.categories[country] should be ["Germany, "Japan"] but I am getting only ["Japan"] in the array.

What is the purpose of @next/react-dev-overlay

I am working on a NextJs project. In it, I have found this piece of code inside next.config.js:

const withTM = require('next-transpile-modules')([
    'some package',
    'some package',
    'emittery',
    '@next/react-dev-overlay'
]);

I was wondering what is the purpose of this @next/react-dev-overlay and was not able to find anything online. The only thing was this unanswered question in the nextjs github issues. When I remove it, it seems that the project is working as expected. My question is what is the purpose of this @next/react-dev-overlay package and should I remove it?