I got this error for multiremote capabilities whre I want to use object model: Error: ReferenceError: $ is not defined

I need help on how to use object model when I have multiremote capabilities as below:
Fyi, this is webdriverio, and use multiremote appium and chromedriver

   capabilities: {

        myBrowser: {
            "host": "localhost",
            "port": 9515,
            "path": "/",
            capabilities: {
                browserName: 'chrome',
                //browserVersion: '122.0.6261.39'
            }
        },
        myMobile: {
            "host": "localhost",
            "port": 4723,
            capabilities: {
                platformName: 'Android',
                'appium:deviceName': 'Pixel 4',
                'appium:platformVersion': '11.0',
                'appium:automationName': 'UIAutomator2', //make sure it's in UIAutomator2, not UiAutomator2
                'appium:app': path.join(process.cwd(), 'app\android\ApiDemos-debug.apk')
            }
        }
    },

Let say, my screen object are as below:

class TestScreen{
    get firstText(){
        return $('//android.widget.TextView[@content-desc="Accessibility"]');
    }

    async clickText(){
        await this.firstText.click();
    }
}

module.exports = new TestScreen();

So I tried it in my spec file, but it failed:

const { firstText } = require("../screen/test-screen.spec");


describe('test run', () =>{
    it('test run', async () => {
        await myMobile.firstText.click();
        
    })
})

I want the code to be able to use object model with the multiremote capabilities

Why can’t typescript infer these correlated types?

Having the following code:

const foo = (flag: boolean) => {
  if (flag) {
    return {
       success: true,
       data: {
         name: "John",
         age: 40
       }
    }
  }

  return {
    success: false,
    data: null
  }
}    

const result = foo(true);

if (result.success) {
   console.log(result.data.name); // TS error: 'result.data' is possibly 'null'
}

Why can’t typescript infer that data always exists if flag is set to true?

I know I can fix this by defining a return type for the function, but it’d be good if TS automatically infers it.

Javascript: Change a function parameter that has a default value without having to change the preceding ones [duplicate]

How to modify a default parameter in a javascript function, knowing that the previous parameters must remain default?

function f(a = 'a', b='b', c='c') {
  return [a, b, c];
}

f( c ='some value here'); //must return ['a', 'b', 'some value here']

I want something similar to what can be done in python.

def f(a = 'a', b = 'b', c ='c'):
    return [a, b, c]

f(c = 'some value here') #will return ['a', 'b', 'some value here']

Is there any way to do this ?

Create Event on Teamup Calendar permissions error

I am attempting to create an event in my Teamup calendar from javascript.

I send:

{ 
  method: 'POST',
  contentType: 'application/json',
  headers: 
  {  
    Accept: 'application/json',
    'Teamup-Token': <api_token>,
    Authorization: 'Bearer <auth_code>' 
  },
  payload: '{"subcalendar_ids":[0],"start_dt":"2024-08-24T14:15:22Z","end_dt":"2024-08-24T14:15:22Z","all_day":false,"tz":"Europe/London","remote_id":"string","title":"Test Title","notes":"Test Desc\n","location":"Home, EX6 6LQ","who":"Test Organiser","signup_enabled":false,"comments_enabled":false}',
  muteHttpExceptions: true 
}
To: https://api.teamup.com/<mycalendarurl>/events

But get:

{"error":{"id":"no_permission","title":"No permission","message":"You do not have the required permissions to do this. This may be due to a change in permissions of your link since you loaded the calendar. Please refresh the calendar."}}

I have requested the <auth_code> authentication token immediately before posting this request.
I haven’t changed permissions, and dont understand what “Please refresh the calendar” means (have quit from my browser, gone back to my calendar, refreshed that webpage etc…)

I am using <mycalendarurl> generated specifically for api calls with modify permissions in the Sharing section of the Teamup dashboard.
I generated <api_token> from the Request Teamup API Key page on the Teamup website

I can find no documentation on the required subcalendar_ids key, and have used 0 as per the example code hoping that indicates the first calendar

This is very close to working because it complains about the dates ‘does not match any accepted ISO8601 date format.’ if I include the 000 millisecond part from toISOString() as opposed to the permissions issue.

MongoDB cross-server document update is not working

I’m using microservice architecture where i have multiple servers. in first server i have user schema for users and when I’m trying to update something from different server, but it’s not updating anything, and also I’m not getting any error.

  //getting users collection without schema and i'm able to read the document with this but not             able to update anything
 `const mongoose = require("mongoose");
 const User = mongoose.model("User", {}, "users");
 module. Exports = User;`

i don’t know if there any policy for security, or any restriction to update from cross-server connection

i asked ChatGPT, Gemini: say’s i can update document, but i don’t know what I’m doing wrong

vue3: how to combine multiple computes

How to combine multiple compute value, like use functions, every compute value has get and set properties, and the code is too long.

let equipmentCode = computed({
    get: () => {
        return props.id ? itemData.value.equipmentCode : newData.value.equipmentCode;
    },
    set: (newValue) => {
        return props.id ? (itemData.value.equipmentCode = newValue) : (newData.value.equipmentCode = newValue);
    },
});
let equipmentName = computed({
    get: () => {
        return props.id ? itemData.value.equipmentName : newData.value.equipmentName;
    },
    set: (newValue) => {
        return props.id ? (itemData.value.equipmentName = newValue) : (newData.value.equipmentName = newValue);
    },
});
let classification = computed({
    get: () => {
        return props.id ? itemData.value.classification : newData.value.classification;
    },
    set: (newValue) => {
        return props.id ? (itemData.value.classification = newValue) : (newData.value.classification = newValue);
    },
});

Is there any way to combine these computes to reduce codes?

“NS_ERROR_NOT_AVAILABLE” error opening HTML with JS script inside GeckoView

I’m trying to make an Android app that shows the content of an HTML using GeckoView

//MainActivity.kt

class MainActivity : AppCompatActivity() {
    private lateinit var geckoView: GeckoView
    private val geckoSession = GeckoSession(GeckoSessionSettings.Builder().allowJavascript(true).build())

    private fun setupGeckoView() {
        // 1
        geckoView = findViewById(R.id.geckoview)

        // 2
        val runtime = GeckoRuntime.create(this)
        geckoSession.open(runtime)

        // 3
        geckoView.setSession(geckoSession)

        // 4
        val apkURI: URI = File(packageResourcePath).toURI()
        val assetsURL = "jar:$apkURI!/assets/"
        val myURL = assetsURL + "index.html"
        geckoSession.loadUri(myURL)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        setupGeckoView()
    }
}

In the assets I have the index.html, a bunch of .css and a .js script. The app launches, correctly displays the html (meaning that also css was correctly loaded), but the js script doesnt start and this error is returned:

[JavaScript Error: "NS_ERROR_NOT_AVAILABLE: " {file: "jar:file:///data/app/com.icp.firefox_app-2/base.apk!/assets/full-offline.iife.js" line: 3}]
                                                                                                    @jar:file:///data/app/com.icp.firefox_app-2/base.apk!/assets/full-offline.iife.js:3:4777
                                                                                                    @jar:file:///data/app/com.icp.firefox_app-2/base.apk!/assets/full-offline.iife.js:101937:101768

Doesn anyone have any idea what could be the problem?

Insert Data of a Table into an Input Field inside a Modal

I have a table with data inside. Every row contains a button that allows to modify that item and send a Put request.
I want to populate the form with the data of the row selected, so changes can be made a lot easier.
This is the modal

<div class="modal-body" id="modal-body-modify">
  <label for="Name">Name:</label>               <input id="NamePut" type="text" name="Name">
  <label for="Surname">Surname:</label>         <input id="SurnamePut" type="text" name="Surname">
  <label for="Birthday">Birthday:</label>       <input id="BirthdayPut" type="text" name="Birthday">
  <label for="Fiscal-Code">Fiscal Code:</label> <input id="Fiscal-CodePut" type="text" name="Fiscal-Code">
  <label for="Course">Course:</label>
  <select id="CourseSelectPut" name="Course">
    <option class="optionPut" value="nessuno" selected>nobody</option>
  </select>
</div>
<div class="modal-footer">
  <button type="button" class="btn btn-secondary" data-bs-dismiss="modal" onclick="eliminaMessaggioPut()">Close</button>
  <button type="button" class="btn btn-primary" onclick="Put()" id="modalModificaButton">Modify</button>
</div>

Normally, to take data from that table and write it on my page I do this:

var name           = document.getElementById(`name-${id}`);
var surname        = document.getElementById(`surname-${id}`);
var divTitle       = document.getElementById("nomeStudente");
divTitle.innerText = name.innerHTML + " " + surname.innerHTML;

I’ve tried many things to be able to write inside that input field, but nothing succeeds.

var NamePut   = document.getElementById("NamePut");
NamePut.value = Name.innerHTML;

var name    = document.getElementById(`name-${id}`);
var NamePut = document.getElementById("NamePut");
NamePut.append(name);
// document.getElementById(`NamePut`).setAttribute('value', Name);
// NamePut.value = document.getElementById(`name-${id}`).value;

I know a solution could be transforming it into a form, but it would change all the css style and I prefer it to solve it maintaining it like this.

HTML Color Input to Image

I am trying to write a simple html document that returns a downloadable square image of a color defined by the user input of a single color. Any help would be much appreciated.

No code yet, any source code is appreciated.

Why in javascript [] != [] [duplicate]

As a new learner of JavaScript, it’s really confusing that undefined == null and [] != [], and [0] == 0.
And I even can’t search it.

As I before said,

const a1 = [1, 2, 3, 4]
const a2 = Array.from(a1)


console.log(a1 === a2);
console.log([0] == 0)

I expected: false, true

remove consecutive duplicate products in an Array of object and sum their quantity in JavaScript

The array contains a list with products that are consecutive duplicated. I need to remove the consecutive duplicate products in the array and sum their quantities.

In this list of objects we have four values of (D) and two values of (U). If the values are repeated and consecutive, I want to remove prev value and sum qty in last duplicate value.

let books = [
  { id: "1", type: "D", price: 25, qty: 27},// *
  { id: "2", type: "D", price: 22, qty: 75},// *
  { id: "3", type: "D", price: 21, qty: 19},// *
  { id: "4", type: "D", price: 19, qty: 62},

  { id: "5", type: "U", price: 23, qty: 19},
  { id: "6", type: "D", price: 20, qty: 22},

  { id: "7", type: "U", price: 25, qty: 14},// *
  { id: "8", type: "U", price: 29, qty: 14}
]

The result will be like this:

[
  { id: "4", type: "D", price: 19, qty: 121},
  { id: "5", type: "U", price: 23, qty: 19},
  { id: "6", type: "D", price: 20, qty: 22},
  { id: "8", type: "U", price: 29, qty: 28}
]

and Thank you in advance.

Custom Code To Disable All Non Essential Cookies On Clickfunnels

I am facing a pretty big challenge. I have build a website/funnel system on Clickfunnels and now I figured out the Program is setting tracking cookies and Google Fonts, and many more. In order to be DSGVO compliant I have to use a cookie consent banner what I absolutely do not want. Is there any way to write a piece of code what disables all tracking cookies withinpicture to explain the system I want to build the Clickfunnels system?

Your help would be much appreciated.

A little about the system I want to build, there may be a different solution or different program.

A URL that randomly leads to 32 different pages what functions as a kind of raffle game, all of them have a button to click that lead towards a different page with a cal to action button.

And Ideally I want to be able to clone the whole system, change the subdomain and the raffle prices.

Therefor a cookie banner will absolutely kill the experience for the attendee. I struggle to find the right system to build this on as I have zero coding experience and all funnel builder are setting cookies that requires a cookie banner.

Thanks heaps for your help

contacted support team without any solution, read all different articles on different funnel builders if they have the functionality to disable cookies

Auth works correctly in Firebase Web but Analytics does not work

The code below uses Auth and Analytics. Auth successfully generates anonymous accounts, but Analytics dashboard always show 0 for new users.
I referred to the official documentation.

    private firebaseConfig = {
      // ............
    };
    
    private app = initializeApp(this.firebaseConfig);
    public analytics = getAnalytics(this.app);
    public auth = getAuth(this.app);

    public async loginAnonymous() {
        await signInAnonymously(this.auth)
        .then(() => {
        })
        .catch((error) => {
            console.log(error);
        });
    }

Some answers on StackOverflow say that it will be reflected in a few days, but I have been waiting for 3 days.
My understanding is that calling getAnalytics() counts as one user, is this correct? The dashboard doesn’t work no matter how long…