JavaScript Regex to capture multiple occurances of a pattern

I am trying to parse a string like this:

something[one][two]

into ['something', 'one', 'two]`. There may be zero or more expressions in square brackets.

The closest I have got to is:

^(.*?)(?:(?:[(.*?)])(?![))*$

That separates out the first part, and survives not having anything in square brackets. However, I can’t find a way of separating the two expressions in square brackets: ['something', 'one][two'].

I thought that:

  • the lazy match (.*?)]) would stop on the next closing bracket, but it seems to go on.
  • the negative lookahead ((?![)) would stop the expression going on to the next square brackets.

What do I need to pick up the mutliple square bracket expressions?

I’m doing this in JavaScript, though I think the regex would be very similar for PHP or Perl.

Project wont push on github [closed]

I tried making a repository then when i did my initial commit there is an error(photo1) Photo1

I finished my project and I tried making a repository then when i did my initial commit there is an error(photo1) Photo1 and I cant run npm run dev anymore and it looks like this(photo2) Photo2. I am using laravel 12, Inertia, Tailwind, and vue js.

Javascript – Returning value (string array) from async function

I was able to download the dropbox jason file and parse it into and array inside the async function shown below. However when I try to use it outside the async function it is either returned as undefined or a promise. Below are more detials.

Load file from dropbox and parse the array. Works fine within this async function.

enter image description here

Results : within function (listed as local) the array works fine, outside function (listed as global), a promise is returned and the array is undefined or returned as a promise. Any assistance with using this array outside of the async function would be greatly appreciated.

enter image description here

I was expecting to return the array from the async function that uploads the array and parses it in a useable javascript array. As you can see from the results it works fine within the async function, however I need to access the array outside of the async function.

react-native-dropdown-select-list extremely slow with a .map after

I have two sections, the first allows you to select a product, and the second displays all the treatments using that products.

using: react-native-dropdown-select-list

Section 1:
has a SelectList with about 10 items in it

Section 2:
treatments.map()

When tapping the SelectList, it opens up to show the list, but dreadfully slow (about 10 frames a sec). If I remove the section 2, it works just fine. If I move section 2 to be above section 1, it works just fine.

Any idea how to fix this? It seems like an animation issue? Minimal Code below. This still causes the error

    const testProducts = [
        {
          _id: "1",
          name: "Product 1",
          price: 100,
        },
        {
          _id: "2",
          name: "Product 2",
          price: 200,
        }, 
        {
          _id: "3",
          name: "Product 3",
          price: 300,
        },
      ]
    
    const testTreatments = [
      {
        _id: "1",
        product: {
          _id: "1",
          name: "Product 1",
          price: 100,
        },
        date: "2023-01-01",
        dosage: 1,
      },
      {
        _id: "2",
        product: {
          _id: "2",
          name: "Product 2",
          price: 200,
        },
        date: "2023-01-02",
        dosage: 2,
      },
      {
        _id: "3",
        product: {
          _id: "3",
          name: "Product 3",
          price: 300,
        },
        date: "2023-01-03",
        dosage: 3,
      },
    ]

    <SelectList
      save="key"
      data={products.map((product) => {
        return product.name;
      })}
      setSelected={()=>{}}
      placeholder={"select product"}
    />
    
    
    
    <View>
      {testTreatments
        .sort((a, b) => {
          return a.date > b.date ? 1 : -1;
        })
        .map((treatment, index) => {
      return (
        <View key={index} style={styles.treatmentContainer}>
          <Text style={styles.subheading}>
            {treatment.product.name}
          </Text>
          <Text>{moment(treatment.date).format("MM/DD/YYYY")}</Text>
          <Text>{treatment.product.price * treatment.dosage}</Text>
        </View>
      );
    })}
    </View>

Next.js – delay issues with onclick using data from useEffect

I’ve making a small flight tracker system, and I’m encountering an issue. Here’s the code for a “Choose your flight” page:

"use client"

interface MyPageProps {
  searchParams: Promise<FlightSearchPanelData>;
}

export default function SelectFlight( {searchParams} : MyPageProps ) {
  const params = React.use(searchParams);
  const router = useRouter();
  const [flightData, setFlightData] = useState<ResultingFlightDetail[]>([]);
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState<string | null>(null);
  const [selectedFlightData, setSelectedFlightData] = useState<ResultingFlightDetail>();  
  const isUsingFlightNumber = params.isUsingFlightNumber || "false";
  const flightFrom = params.flightFrom || "";
  const flightTo = params.flightTo || "";
  const flightNumber = params.flightNumber || "";
  const flightDate = params.flightDate || "";

  useEffect(() => {
    const fetchFlightData = async () => {
      try {
        setLoading(true);
        const params = await searchParams;        
        const url = new URL(`${BASE_API_URL}/api/flightsByFromTo`);
        url.searchParams.append('flightNumber', flightNumber);
        url.searchParams.append('flightFrom', flightFrom);
        url.searchParams.append('flightTo', flightTo);
        url.searchParams.append('flightDate', flightDate);

        const response = await fetch(url);
        
        if (!response.ok) {
          throw new Error(`HTTP error! status: ${response.status}`);
        }

        const result = await response.json();
        setFlightData(result);
      } catch (err) {
        setError(err instanceof Error ? err.message : 'An error occurred');
        console.log("error", err);
      } finally {
        setLoading(false);
      }
    };

    fetchFlightData();
  }, []);

  const handleClick = (event: React.MouseEvent) => {
    if (flightData.length > 0 && !loading) {
      const clickedId = parseInt(event.currentTarget.id);
      setSelectedFlightData(flightData[clickedId]);
      sessionStorage.setItem('individualFlightData', JSON.stringify(selectedFlightData));
      //router.push(`/flight/passenger_info`);
    }
  }
  
  if (error) {
    return (
      <div className="grid min-h-50 grid-cols-20 flex">
        <div className="col-start-2 col-span-18 flex flex-col mt-15 -mx-8 z-2">
          <div className="flex justify-center">
            Error: {error}
          </div>
        </div>
        <div className="fixed bottom-0 left-0 w-full">
          <FooterPanelWithBg />
        </div>
      </div>
    );
  }

  return (
    <div className="grid min-h-screen grid-cols-20 flex">
      <div className="flex flex-col col-start-2 col-span-18 mt-15">
        <div className="mx-60">
          {loading ? 
            <div className="flex justify-center">
              <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900" />
            </div>
            :
            <div className="space-y-10">
            {flightData.map((data: ResultingFlightDetail, idx: number) => {
              return (
                <div 
                  id={idx.toString()} 
                  key={idx} 
                  className={
                    selectedFlightData?.id === (idx + 1).toString() ? 
                    "w-full h-26 p-4 rounded-md shadow-md flight-details-card-selected" :
                    "w-full h-26 p-4 rounded-md shadow-md flight-details-card"
                  }
                  onClick={handleClick}>
                  <div className="col-start-2 flex justify-end">
                    <div>
                      <div className="flight-details-flight-num flex justify-end">
                        {data.airlineCode || "XX"} {data.flightNum || "000"}
                      </div>
                      <div className="flight-details-flight-time">
                        {formatTimeToLongString(data.departureDateTime)} - {formatTimeToLongString(data.arrivalDateTime)}
                      </div>
                    </div>
                  </div>
                </div>
              )
            })}
            </div>
          }
        </div>
      </div>
    </div>
  );
}

While this seemingly fetches and displays the data, I have an issue with the OnClick function of the resulting divs.

The first issue is that by the first click, the array flightData is empty (and logging it confirms that), so selectedFlightData ends up being undefined. I have to click again to actually see the flightData populated and to properly set a selectedFlightData.

The second issue is that clicking on a div retains the last ID. So, for example, I click on the first item, it returns an undefined, I click on it again, it grabs the index of the first object. If I change my mind and select, say, the second item, the selectedFlightData doesn’t change – it’s still the first item. I have to click the second item AGAIN to get it to be selected.

I’m not sure what I’m doing wrong here. Any help would be much appreciated.

JavaScript Time Problems [duplicate]

A bit new to JavaScript and was doing a time clock. It works however I obviously have a problem with the time zone not working and midnight shows up as 00:xx:xx. Any help would be great.

// Time Clock
function startTime() {
  const today = new Date();
  let targetTimeZone = 'America/Los_Angeles';
  let h = today.getHours();
  let m = today.getMinutes();
  let s = today.getSeconds();
  m = checkTime(m);
  s = checkTime(s);
  am_pm = "AM";

  // Setting time for 12 Hrs format
  if (h >= 12) {
    if (h > 12) h -= 12;
    am_pm = "PM";
  } else if (h == 0) {
    hr = 12;
    am_pm = "AM";
  }

  // Add Leading Zero's
  h = h < 10 ? "0" + h : h;
  m = m < 10 ? "0" + m : m;
  s = s < 10 ? "0" + s : s;

  // Parse Time to Format
  document.getElementById('fleet_time').innerHTML = h + ":" + m + ":" + s + " " + am_pm + " PDT";
  setTimeout(startTime, 1000);
}

function checkTime(i) {
  return i;
}

startTime();
<div id="fleet_time"></div>

Can anyone explain to make it to me?

Can anyone explain to make it to me? I don’t know how to do this

tentei só que não consegui nem iniciar esse projeto se alguém puder me ajudar eu ficaria muito grato áaaassaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaatentei só que não consegui nem iniciar esse projeto se alguém puder me ajudar eu ficaria muito grato áaaassaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaatentei só que não consegui nem iniciar esse projeto se alguém puder me ajudar eu ficaria muito grato áaaassaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaatentei só que não consegui nem iniciar esse projeto se alguém puder me ajudar eu ficaria muito grato áaaassaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaatentei só que não consegui nem iniciar esse projeto se alguém puder me ajudar eu ficaria muito grato áaaassaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaatentei só que não consegui nem iniciar esse projeto se alguém puder me ajudar eu ficaria muito grato áaaassaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaatentei só que não consegui nem iniciar esse projeto se alguém puder me ajudar eu ficaria muito grato áaaassaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaatentei só que não consegui nem iniciar esse projeto se alguém puder me ajudar eu ficaria muito grato áaaassaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaatentei só que não consegui nem iniciar esse projeto se alguém puder me ajudar eu ficaria muito grato áaaassaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaatentei só que não consegui nem iniciar esse projeto se alguém puder me ajudar eu ficaria muito grato áaaassaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaatentei só que não consegui nem iniciar esse projeto se alguém puder me ajudar eu ficaria muito grato áaaassaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

404 Automatic Requests in Supabase

I am developing an NextJS app with supabase, I use Google OAuth and realtime database. I’m having a problem in my app that do requests that I don’t want to. It was over 2000 requests, all them are 404.

log

log2

logs supabase

I was developing normally and then that happened, I tried looking in the documentation and following the examples but didn’t work, I tried to delete .next folder but nothing didn’t either. I only works when I built the whole app, in dev mode it doesn’t work.

Want to increase vertical scroll speed so it directly stop on next div (Open of other suggestion)

Slow, gradual vertical scrolling: Current scroll updates pixel-by-pixel and does not jump or snap directly to each full viewport section.

Scroll stuck on hover: preventDefault() is called on all wheel events inside the container, blocking native scroll behavior on child elements and causing scroll freeze.

Missing scroll snapping: CSS scroll snap properties are not used, so the browser does not automatically align scroll positions to section boundaries.

No snap logic in JavaScript: The wheel handler increases scrollTop incrementally without rounding or jumping to exact section start positions.

Potential ref or event listener issues: Without proper container height, overflow, or ref attachment, wheel events may not trigger as expected.

   <StickyContainer>
        <TextContainer  ref={containerRef}>
          <TextBlock>
            <h1>Get Comprehensive Subject-Wise CSVTU Notes Instantly </h1>
          </TextBlock>

          <TextBlock>
            <h1> Prepare Better with Quality Material</h1>
            <p>CSVTU Study Hub</p>
          </TextBlock>

          <TextBlock>
            <h1>Smarter Learning, Better Scores </h1>
            <p> Designed for CSVTU Students</p>
          </TextBlock>
        </TextContainer>

        <StickyImage src={girlImage} alt="Sticky" />
      </StickyContainer>


  const containerRef = useRef(null);

 useEffect(() => {
  const container = containerRef.current;

  const onWheel = (evt) => {
    console.log("ahrsh")
    // Trigger only if event target is container or any of its descendants
    if (container.contains(evt.target)) {
      evt.preventDefault();
      container.scrollTop += evt.deltaY * 10; // increase vertical scroll speed
      console.log("harsh");
    }
  };

  container.addEventListener("wheel", onWheel, { passive: false });

  return () => {
    container.removeEventListener("wheel", onWheel);
  };
}, []);





const StickyContainer = styled.div`
  position: relative;
  height: 330vh;
  display: flex;
  align-items: flex-start; /* important for sticky to work */
  justify-content: space-around;
  border: 3px solid #97c52c;
  scroll-snap-align: start;
  scroll-behavior: smooth;
`;

const TextContainer = styled.div`
  scroll-behavior: smooth;
  width: 45vw;
  
`;

const TextBlock = styled.div`
  color: white;
  height: 100vh;
  box-sizing: border-box;
  margin-bottom: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  padding: 20px;
  gap: 20px;

 animation: appear linear;
 animation-timeline: view();
 animation-range: entry 0% cover 40%;
`;

const StickyImage = styled.img`
  position: sticky;
  top: 40px;
  height: 700px;
  align-self: flex-start;
  object-fit: contain;
`;


Fast, precise vertical scrolling that jumps or snaps directly to the next full viewport section on each scroll input, improving navigation and user experience.

No scroll freeze or stuck behavior when hovering or scrolling inside the container or its child elements, ensuring smooth and uninterrupted scrolling.

CSS scroll snap enabled so the browser automatically aligns scroll positions to exact section boundaries, providing natural section-by-section scroll.

Robust wheel event handling that only hijacks scroll when appropriate and respects native behavior on child elements, avoiding event conflicts.

Reliable event listener attachment with properly configured scrollable container (fixed height, overflow-y set) so wheel events always trigger as expected.

How to render vue components as AgGrid icons?

I have the following AgGrid configuration in my VueJS project:

<template>
    <div>
      <AgGridVue
        class="ag-grid-theme"
        :rowData="rowData"
        :columnDefs="colDefs"
        :icons="icons"
        style="width: 100%; height: 500px"
      />
    </div>
</template>

<script setup>
  import { h } from 'vue'
  import {
    XIcon
  } from 'lucide-vue-next'
  import { AgGridVue } from 'ag-grid-vue3'
  import {
    AllCommunityModule,
    ModuleRegistry
  } from 'ag-grid-community'
  ModuleRegistry.registerModules([AllCommunityModule])

  const icons = {
    filter: () => h(XIcon)
  }

  const colDefs = [
    {
      field: 'symbol'
    },
    {
      field: 'currency'
    },
    {
      field: 'quantity'
    }
  ]

  const rowData = [
    { symbol: 'AAPL', currency: 'USD', quantity: 10 },
    { symbol: 'GOOGL', currency: 'USD', quantity: 5 },
    { symbol: 'AMZN', currency: 'USD', quantity: 2 }
  ]
</script>

I’m trying to add a custom filter icon by injecting the XIcon component as a custom icon, as shown in the icon object, but it’s not working.

How would I go about rendering a Vue component as a custom icon?

How to create a react flow where you have 2 nodes with multiple edges?

I am trying to create a react flow where you have 2 nodes with multipule edges. I have the following set up but it renders only 1 edge. How do I render all 3 edges?

enter image description here

import ReactFlow from 'reactflow';
import 'reactflow/dist/style.css';

function MyFlow() {
  const initialNodes = [
    { id: '1', position: { x: 0, y: 0 }, data: { label: 'Node 1' } },
    { id: '2', position: { x: 200, y: 100 }, data: { label: 'Node 2' } },
  ];

  const initialEdges = [
    { id: 'e1-2a', source: '1', target: '2', label: 'Edge A' },
    { id: 'e1-2b', source: '1', target: '2', label: 'Edge B' },
    { id: 'e1-2c', source: '1', target: '2', label: 'Edge C' },
  ];

  return (
    <div style={{ width: '100vw', height: '100vh' }}>
      <ReactFlow nodes={initialNodes} edges={initialEdges} fitView />
    </div>
  );
}

export default MyFlow;

Why does `Array(3).map(x => 42)` return an empty array instead of `[42, 42, 42]` in JavaScript?

I was brushing up on Array for an implementation and I stumbled on this discovery, I expected the following code to give me an array filled with the number 42:

Array(3).map(x => 42)

But instead, the result is:

[empty × 3]

console output

If I try the same with fill, which I normally use, it works as I expected:

Array(3).fill(42) // [42, 42, 42]

Or if I create the array explicitly:

[1, 2, 3].map(x => 42) // [42, 42, 42]

So clearly map works normally on an array with values as I’ve also known.

But why does Array(3).map(...) behave differently, and what does [empty × 3] actually mean in JavaScript? It’s my first time coming across this.

Struggling with QR scanner implementation [closed]

I am using React Native 0.68.5 and I implemented Qr Scanner from react-native-qr-scanner library which worked fine on my laptop where I am using complete Android no iOS but as soon as I implement it on my office project which of course on iOS Android it fails to run.

React Native permissions and qr-scanner library working fine on that but whenever I install React-native-camera my build got stuck in between and without this library the errors pops up that ‘RNCamera is not found in Ulmanager. I can’t provide the images though but I can completely explain error.

PayPal Subscription TRANSACTION_REFUSED for $199/month but works for $1/month

I’m implementing PayPal subscriptions using the JavaScript
SDK. Small subscription amounts ($1/month) work perfectly
fine, but when I try to change the subscription priceenter image description here with higher
amounts ($199/month), they immediately fail with a
TRANSACTION_REFUSED error. The strange part is that
one-time payments of $1000+ work without any issues on the
same PayPal business account. Users see a generic “Things
don’t appear to be working at the moment” error from
PayPal, and the console logs show TRANSACTION_REFUSED when
attempting to create the subscription.

When users attempt to subscribe, they immediately see
PayPal’s error page stating “Things don’t appear to be
working at the moment.” The network tab shows a redirect to
PayPal’s genericError endpoint with the parameter
code=TRANSACTION_REFUSED. The browser console shows the
subscription.create() promise is rejected before any
payment modal appears. Interestingly, the error URL also
contains flow:”one-time-checkout” in the event state, even
though I’m using intent:”subscription” in my SDK
configuration. No additional error details are provided by
the PayPal SDK beyond the generic failure.

enter image description here

How to come up with a unique AI plus web/mobile or real world problem solving project idea for final year? [closed]

I’m a 3rd-year software engineering student starting my final-year project, and I still have no idea. And I would like to do something unique, also solve a problem, and wanna give an impactful thing to the world. It should:

Use AI in a supporting role
Solve a real-world problem
Be doable in about 7 months

Question: What’s the best way to refine broad themes into a clear, practical, and unique project idea?

any ideas or suggestions