How to hide custom tab bar on specific stack/ screen in nested navigation?

My nav structure looks like this
App.js

      <Stack.Navigator initialRouteName="Auth">
        <Stack.Screen
          name="Auth"
          component={AuthLayout}
          options={{ headerShown: false }}
        />
        <Stack.Screen
          name="Tabs"
          component={Tabs}
          options={{ headerShown: false }}
        />
      </Stack.Navigator>

Tabs.js

    <Tab.Navigator
      tabBar={(props) => <CustomTabBar {...props} />}
      initialRouteName="Main"
      screenOptions={({ route }) => ({
        headerShown: false,
      })}
    >
      <Tab.Screen
        name="Main"
        component={HomeLayout}
        options={{ title: "My home"}}
      />
      <Tab.Screen
        name="Profile"
        component={ProfileLayout}
        options={{ title: "Profile"}}
      />
    </Tab.Navigator>

HomeLayout.js

<Stack.Navigator initialRouteName="Home">
      <Stack.Screen
        name="Home"
        component={Home}
        options={{
          header: ({ navigation, route, options, back }) => (
            <Header
              navigation={navigation}
              route={route}
              options={options}
              back={back}
            />
          ),
        }}
      />
      <Stack.Screen
        name="Screen A"
        component={ScreenA}
        options={{
          header: ({ navigation, route, options, back }) => (
            <Header
              navigation={navigation}
              route={route}
              options={options}
              back={back}
            />
          ),
        }}
      />
      <Stack.Screen
        name="Screen B"
        component={ScreenB}
        options={{
          header: ({ navigation, route, options, back }) => (
            <Header
              navigation={navigation}
              route={route}
              options={options}
              back={back}
            />
          ),
        }}
      />
    </Stack.Navigator>

My goal is to hide tab bar on Screen A, Screen B, and some other screens.
I searched for the solution and also tried implementing tabBarVisible, but I had no luck in my case, the custom tab bar still there. So, how can I hide it for the specific screen only? Why doesn’t tabBarVisible work?

How I need to make this request in sequelize, Here is the mysql syntax

I have three tables cours_homework, users and asset-cours.
the cours_homework table contains the foreign keys for the two other tables and I would like to find records with this mysql query in sequelize

select * from cours_homework 
inner join asset_course on cours_homework.assetId = asset_cours.id 
inner join users on cours_home.userId = user.id 
where cours_homework.id = '123ddssdjj54'; 

MongoDBAtlasVectorSearch: Operand type is not supported for $vectorSearch: objectId

I’m using a langchain script in order to make a similarity search of a query embedding in an embedding’s MongoDb collection but I want to pre filter the documents to search only in the documents that are $in an objectId array.

// Get the list of embeddings _ids to preFilter
const documentData =  await documentCollection.findOne(
  { "_id": documentId },
  { "embededings": 1 }
)
const documentEmbeddingsId = documentData.embeddings

// Embed query
const query = "What is this document about?"
const embeddings = new OpenAIEmbeddings({
  modelName:"XXX",
  openAIApiKey: "XXX"
})
const embeddedQuery = await embeddings.embedQuery(query)

// Similarity search
const vectorStore = new MongoDBAtlasVectorSearch(embeddings, {
  collection,
  indexName: "XXX",
  textKey: "XXX", 
  embeddingKey: "XXX", 
});
const preFilter = {
    preFilter: {
      _id: {
        $in: objIds
      },
    },
}
const storingResponse = await vectorStore.similaritySearchVectorWithScore(embeddedQuery,4,preFilter)

Running this code returns this error:
‘Error: MongoServerError: Operand type is not supported for $vectorSearch: objectId’.
Is the error in the preFilter? Or is this type of filter not supported by mongodb? Any ideas on how I can make this search?

create portfolio as in the image [closed]

I need help creating a web portfolio, taking into account that these are laboratory tests and there are too many, how could I create something like what I show in the images? enter image description here

I have looked at a search engine in js and that the tests appear according to the letter, but I do not understand how to create the number of tests and make the url change.

Is there a method of configuring triggers for multiple Apps Script projects?

I’m having difficulty solving a challenge, I need to know what tools I need to know how to use to solve my problem. To summarize the challenge, I need to configure triggers in several app script projects associated with spreadsheets. Supposing I have a list with all the IDs of the projects in which I want to add triggers for the “text_treatment” function that will be triggered with each edit made to the spreadsheet, how could I add the triggers to all the projects contained in the list? Which API should I use?

Why is my jesk.mock not work, the theme is undefined

My logo component, based on my next-theme’s theme I change the logo and src url for the svg:

import { useEffect, useState } from 'react';
import Image from 'next/image';
import { useTheme } from 'next-themes';

function MainLogo() {
  const [themeClass, setThemeClass] = useState('');
  const [weight, setWeight] = useState(200); // Default weight
  const [height, setHeight] = useState(40); // Default height

  const { theme } = useTheme() || {}; // Prevents destructuring from undefined

  useEffect(() => {
    let newThemeClass = '';

    if (theme) {
      switch (theme) {
        case 'acme':
          setWeight(100);
          setHeight(30);
          newThemeClass = 'acme';
          break;
        case 'bitcoin':
          setWeight(144);
          setHeight(30);
          newThemeClass = 'bitcoin';
          break;
        case 'bounty':
        default:
          setWeight(200);
          setHeight(40);
          newThemeClass = 'bounty';
          break;
      }
      setThemeClass(newThemeClass);
    }
  }, [theme]); // Run the effect whenever the theme changes

  return (
    <div>
      <Image
        src={`/internal/logo_${themeClass}.svg`}
        alt="Logo"
        width={weight}
        height={height}
        title={themeClass}
      />
    </div>
  );
}

export default MainLogo;

The test

Before each test I clearAllMocks, and inside of each test I use jest.mock to change the theme.

The theme is undefined.

import React from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom';

import MainLogo from './logo';

jest.mock('next-themes');

describe('MainLogo Component', () => {
  beforeEach(() => {
    jest.clearAllMocks();
  });

  it('renders the logo properly with the "bounty" theme', async () => {
    jest.mock('next-themes', () => ({
      useTheme: () => ({
        theme: 'bounty', // Set the desired theme value for testing with bounty theme
      }),
    }));

    render(<MainLogo />);

    // Wait for the state to be updated
    await waitFor(() => {
      // Ensure that the image element with the correct alt text is rendered
      const logoElement = screen.getByAltText('Logo');
      expect(logoElement).toBeInTheDocument();

      // Ensure that the image element has the correct width and height attributes
      // expect(logoElement).toHaveAttribute('width', '200');
      // expect(logoElement).toHaveAttribute('height', '40');

      // Ensure that the image element has the correct title attribute
      expect(logoElement).toHaveAttribute('title', 'bounty');
    });
  });

  it('renders the logo properly with the "bitcoin" theme', async () => {
    jest.mock('next-themes', () => ({
      useTheme: () => ({
        theme: 'bitcoin', // Set the desired theme value for testing with bitcoin theme
      }),
    }));

    render(<MainLogo />);

    // Wait for the state to be updated
    await waitFor(() => {
      // Ensure that the image element with the correct alt text is rendered
      const logoElement = screen.getByAltText('Logo');
      expect(logoElement).toBeInTheDocument();

      // Ensure that the image element has the correct width and height attributes
      // expect(logoElement).toHaveAttribute('width', '144');
      // expect(logoElement).toHaveAttribute('height', '30');

      // Ensure that the image element has the correct title attribute
      expect(logoElement).toHaveAttribute('title', 'bitcoin');
    });
  });
});

The Error:

  ● MainLogo Component › renders the logo properly with the "bitcoin" theme

    expect(element).toHaveAttribute("title", "bitcoin") // element.getAttribute("title") === "bitcoin"

    Expected the element to have attribute:
      title="bitcoin"
    Received:
      title=""

    Ignored nodes: comments, script, style
    <html>
      <head />
      <body>
        <div>
          <div>
            <img
              alt="Logo"
              data-nimg="1"
              decoding="async"
              height="40"
              loading="lazy"
              src="/internal/logo_.svg"
              style="color: transparent;"
              title=""
              width="200"
            />
          </div>
        </div>
      </body>
    </html>
    ```


OpenAi API Error: “Configuration is not a constructor”

I’m trying to build a discord bot that generates image but I faced this problem.. I’m following a toturial on YouTube I hope someone helps me resolve this matter.

`const { SlashCommandBuilder, EmbedBuilder} = require(`discord.js`);
const { Configuration, OpenAIApi } = require("openai");

const configuration = new Configuration({
  apiKey: 'My Key'
});
const openai = new OpenAIApi(configuration);`


# I think this is a tough one since its a command building integrated with openai Api

Css animation in ios devices

I added this custom html, css and js in my website. It’s an hamburger menu with animation which i have to insert in my website.
The transformation works in android devices, not in ios ones.
What can i do to fix it?
I tried to insert webkit prefix in each part of css part but nothing happens.

Html:

<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 20" id="icon">
    <path id="mypath" d="M 1 1 L 16 1 M 16 1 L 31 1 M 1 11 L 16 11 M 16 11 L 31 11 M 1 21 L 16 21 M 16 21 L 31 21" fill="none" stroke="white" stroke-width="1" />
</svg>

CSS:


  .shape1 {
  -webkit-animation: webkit-apertura 800ms ease-in-out forwards;
    animation: apertura 800ms ease-in-out forwards;
  }

  .shape2 {
       -webkit-animation: webkit-chiusura 800ms ease-in-out forwards;
       animation: chiusura 800ms ease-in-out forwards;
  }
  
  @-webkit-keyframes webkit-apertura {
    0% {
      d: path("M 1 1 L 16 1 M 16 1 L 31 1 M 1 11 L 16 11 M 16 11 L 31 11 M 1 21 L 16 21 M 16 21 L 31 21");
    }
    50% {
      d: path("M 1 11 L 16 1 M 16 1 L 31 11 M 1 11 L 16 11 M 16 11 L 31 11 M 1 11 L 16 21 M 16 21 L 31 11");
    }
    100% {
      d: path("M 16 11 L 6 1 M 26 1 L 16 11 M 16 11 L 16 11 M 16 11 L 16 11 M 16 11 L 6 21 M 26 21 L 16 11");
    }
}

  @keyframes apertura {
    0% {
      d: path("M 1 1 L 16 1 M 16 1 L 31 1 M 1 11 L 16 11 M 16 11 L 31 11 M 1 21 L 16 21 M 16 21 L 31 21");
    }
    50% {
      d: path("M 1 11 L 16 1 M 16 1 L 31 11 M 1 11 L 16 11 M 16 11 L 31 11 M 1 11 L 16 21 M 16 21 L 31 11");
    }
    100% {
      d: path("M 16 11 L 6 1 M 26 1 L 16 11 M 16 11 L 16 11 M 16 11 L 16 11 M 16 11 L 6 21 M 26 21 L 16 11");
    }
}

@keyframes chiusura {
    0% {
      d: path("M 16 11 L 6 1 M 26 1 L 16 11 M 16 11 L 16 11 M 16 11 L 16 11 M 16 11 L 6 21 M 26 21 L 16 11");
    }
    50% {
      d: path("M 1 11 L 16 1 M 16 1 L 31 11 M 1 11 L 16 11 M 16 11 L 31 11 M 1 11 L 16 21 M 16 21 L 31 11");
    }
    100% {
      d: path("M 1 1 L 16 1 M 16 1 L 31 1 M 1 11 L 16 11 M 16 11 L 31 11 M 1 21 L 16 21 M 16 21 L 31 21");
    }
}

@-webkit-keyframes webkit-chiusura {
    0% {
      d: path("M 16 11 L 6 1 M 26 1 L 16 11 M 16 11 L 16 11 M 16 11 L 16 11 M 16 11 L 6 21 M 26 21 L 16 11");
    }
    50% {
      d: path("M 1 11 L 16 1 M 16 1 L 31 11 M 1 11 L 16 11 M 16 11 L 31 11 M 1 11 L 16 21 M 16 21 L 31 11");
    }
    100% {
      d: path("M 1 1 L 16 1 M 16 1 L 31 1 M 1 11 L 16 11 M 16 11 L 31 11 M 1 21 L 16 21 M 16 21 L 31 21");
    }
}

Javascript:

var state = 0;
var icona = document.getElementById("icon");
var path = document.getElementById("mypath");

icona.addEventListener("click", function(event){
 event.preventDefault();
    
    if(state==0){
        path.classList.remove('shape2');
        path.classList.add('shape1');
        state = 1;
        console.log("shape1");
    } else{
        path.classList.remove('shape1');
        path.classList.add('shape2');
        state = 0;
        console.log("shape2");
    }
});


icona.addEventListener("touchstart", function(event){
 event.preventDefault();
    
    if(state==0){
        path.classList.remove('shape2');
        path.classList.add('shape1');
        state = 1;
        console.log("shape1");
    } else{
        path.classList.remove('shape1');
        path.classList.add('shape2');
        state = 0;
        console.log("shape2");
    }
});

How to send encrypted requests to an API in a way so an internet provider couldn’t block them neither by IP nor by DNS records?

I have a web app that makes calls to the API. Due to governmental mass media censorship, some internet providers block requests to that API. To bypass this, I’ve already put my API behind Cloudflare, so the provider can’t block the API by IP address anymore, but they still can block it by domain name as most users use a default DNS controlled by internet provider.

I know there is an option to ask users to use VPN or to change their web browser’s DNS settings to 1.1.1.1 which supports the DoH feature (DNS over HTTPS). Or, in case of a mobile app, I would just use there a custom WebView to override default DNS settings.

I know there are some npm packages to perform encrypted DSN queries (like dohjs or dns-over-https) from a web browser. But I need to not just make DNS queries.

So the the question is: How to send encrypted requests from a web app to an API in a way so an internet provider couldn’t block (or even detect) them neither by IP nor by DNS records (except blocking the entire Cloudflare network) without requiring any actions from users.

P.S. As for the UI part of the web app, it (almost) can’t be blocked by internet provider as it’s hosted on a widely used domain – but that option was available for UI html+js part only, but not for the backend part, so I’m looking for some solution to make queries to the API without being blocked by internet providers.

how to give a condition in the .min() in Yup validation .?

I’m using a input field of type number..so I have to set the error msg when user enter only 2 numbers…so the condition is…if user didn’t enter any number then error will show “Mobile number is required” , if user enter more than 2 but less than 15 numbers, then error will show “Mobile number is too short” and if the number length is more than 15 then error will show like “Mobile number is too large”.

I try a null number value in the input field ..but its not showing me error like “Mobile number is required” but instead of that error it’s showing me “Mobile number is too short” …is there any method to give condition in the .min() of Yup validation..?

Why does the webpage work on my PC but not on Github? [closed]

I have a page, you can see it on github. The strange thing is that the page works fine locally on my computer but it does not work online after I uploaded on to github.

This is the page
https://vyha18.github.io/video/van2.html#

All css, javascript and html are in the van2.html#, you can see the source code by viewing source or you can click here “view-source:https://vyha18.github.io/video/van2.html#”

You can copy all the source code to a html file on your PC and try to test it.

Make sure you change 'van.mp3' to 'https://vyha18.github.io/video/van.mp3' on your own html file.

Note: To test the page, click on “Tong Hop Van“, then click OK. If you can hear some sound, then it works.

Note: I saved the html file using UTF-8 before uploading it to github.

What is causing the problem?

Additional CSS classes not being added in Gutenberg editor

When we add additional classes to our custom block they are not being added in the editor. When we save the block and view the front-end the additional classes are showing. But in the editor they won’t show up.

Here is the code of our block:

import { useBlockProps } from '@wordpress/block-editor';


export default {
    name: 'erik-dekker/button',
    title: 'Knop',
    icon: 'button',
    category: 'erik-dekker',
    edit: () => {
        const blockProps = useBlockProps();

        return (
            <div { ...blockProps }>hello world!</div>
        );
    },
    save: () => {
        const blockProps = useBlockProps.save();

        return (
            <div { ...blockProps }>hello world!</div>
        );
    }
}

Thanks for your time!

How to add Google Ads Manager Ads units (Banners) using NuxtJs/VueJs frameworks?

I have this Ads unit


<script type="text/javascript">
google_ad_client = "ca-pub-2158343444694791";/* AD7 */
google_ad_slot = "AD7";
google_ad_width = 300;
google_ad_height = 250;
</script>
<script type="text/javascript" src="//pagead2.googlesyndication.com/pagead/show_ads.js"></script>

I would like to place a script on my website’s homepage and show the banner 5 times in deffrent places.

The website is developed using NodeJs, NuxtJs3, and VueJs3 with both SSR and SPA.

However, as you know, I can not place script tags inside the vuejs template.

Can you please guide me on how to render this correctly?
So far, I have attempted the following:

**Tempalte **

<div class="my_div"></div>

Javascript


nuxt.hook("page:loading:end", () => {
  loaderLoading.value = false
  setTimeout(() => {
    var div = document.querySelector('.my_div');

    // Create a script element
    var script = document.createElement('script');

    // Set the type attribute
    script.type = 'text/javascript';

    // Set the source (src) attribute
    script.src = '//pagead2.googlesyndication.com/pagead/show_ads.js';

    // Create an inline script element for the ad parameters
    var inlineScript = document.createElement('script');
    inlineScript.type = 'text/javascript';
    inlineScript.innerHTML = `
    google_ad_client = "ca-pub-2158343444694791";
    /* AD7 */
    google_ad_slot = "AD7";
    google_ad_width = 300;
    google_ad_height = 250;
`;
    console.log("test")
    // Append the inline script to the div
    div.appendChild(inlineScript);

    // Append the script to the div
    div.appendChild(script);

  }, 2000);
}) 

The problem i have a lot of console errors such as :

Uncaught TagError: adsbygoogle.push() error: Ad client is missing from the slot.
Uncaught TypeError: Cannot read properties of null (reading 'appendChild')
Unchecked runtime.lastError: The message port closed before a response was received.

Please advise on the correct placement of ad units. Is there a library that supports Google Ads Manager ad units? Please note that this is different from Google AdSense.

Regards

Browser is doing JavaScript code in wrong order (probably)

I have a container (with a background image) and inside this container there is some text (chosen by reading value from a text input). To fit the text I’m using textFit script. User can also choose the font and there is the major problem.

For reference I’m putting some code:

<input type="text" id="ChosenText" autocomplete="off" placeholder="Type text here" oninput="refreshPicture()">

<select id="ChosenFont" onchange="changeFontFamily(true)">/*options are generated by JS*/</select>

<div id="slide-container">
        <span id="textOnPicture" class="textOnPicture textFitted">/*here JS puts text from an input*/</span>
</div>
const resultContainer = document.querySelector("#slide-container");
const chosenText = document.querySelector("#ChosenText");
const chosenFont = document.querySelector("#ChosenFont");
const textOnPicture = document.querySelector(".textOnPicture");

function refreshPicture() {
  textOnPicture.textContent = chosenText.value;
  textFit(resultContainer);
}

async function reloadPicture(manualChoose) { //function is called by pressing "Reload" button and it is async because when it isn't, picture doesn't display for unknown reason
  await changeFontFamily(manualChoose); //here is the thing, I want to change font family
  refreshPicture();
}

function changeFontFamily(manualChoose) {
  let fontFamily;
  if (!!manualChoose) {//when triggered by changing value of input
    fontFamily = chosenFont.value;
    textOnPicture.style.setProperty("--font-family", fontFamily); //in css this property is obviously assigned to font-family of textOnPicture
    textFit(resultContainer);
  } else {//when triggered by "Reload" button, then random picture, font and color are chosen
    fontFamily = fonts[Math.floor(Math.random() * fonts.length)].name;
    textOnPicture.style.setProperty("--font-family", fontFamily);
    chosenFont.value = fontFamily;
  }
}

The problem is when I change font family (by pressing the button and choosing it randomly or manually by changing value) font size doesn’t change and sometimes text is outside of the container. But when I call textFit function again it fixes.

“await” before changeFontFamily function should wait until funtion finish its work, right? So why it isn’t? textFit is called after that but it seems like browser is doing it in wrong order or textFit ignores that font has been changed.

Due to every font family basically has its own size the text is sometimes too small or too big after change of font family and it looks terrible. Of course I would like to my text always have correct size.