How to send a request inside Script/Post Response code of Bruno

Need to migrate the following code from Postman to Bruno. Into the Postman Post-response I have this request:

pm.sendRequest({
    url: `${lambdaUrl}/finxact/accountnumber/${psnNumber}`,
    method: 'GET',
    header: {
        'qa-test-id': 'pm-test-1',
        'x-api-key': `${qa_lambda_key}`
    },
}, function(err, res) {
    pm.expect(res).to.have.property('code', 200);
    const acctNbr = res.json().data[0].acctNbr
    console.log(acctNbr)
    pm.environment.set("acctNbr",acctNbr)
    pm.environment.set("accountNumber", acctNbr)
});

Tried with the following approach into the Bruno Post Response but it’s not working:

req.setUrl(`${lambdaUrl}/finxact/accountnumber/${psnNumber}`);
req.setMethod("GET")
req.setHeaders({ 
  "qa-test-id": "pm-test-1",
  "x-api-key": `${qa_lambda_key}`
});
const status = res.getStatus();
let responseBody = res.getBody();
console.log(responseBody)
// expect(responseBody).to.have.property('code', 200);
// expect(res.status).to.equal(200);
const acctNbr = responseBody.data[0].acctNbr
console.log(acctNbr)
bru.setEnvVar("acctNbr",acctNbr)
bru.setEnvVar("accountNumber", acctNbr)

Note: have commented the expect lines because it does not recognize expect function.

How to mask all the characters after the N-th in an ASP.NET textbox? [duplicate]

I’m using a TextBox in WebForms to get user input but at the same time one of my requirements dictates that all the characters after the 3rd one should be masked, thereby appearing as ‘*’ (ex. Nor**). Is there a way to achieve this and keep the text intact for server-side processing?

I tried replacing those characters in client-side Javascript and keeping a ‘clean’ version in a hidden-field but it becomes a problem once user tries to add a character in the middle or delete.

How can I use specific cells in a Google sheets range?

I’m creating a Discord bot. Whenever I use the command that this is linked to it works. However it displays all the data in all cells in the set range. How do I get a specific cell out of the range and use it?

The way I’ve been doing it is by replacing the range to a specific cell, but I feel like that isn’t the most practical way to do this.

Can anyone help? I’m pretty new to JS so any tips would be greatly appreciated.

async function readCerts() {
  const sheets = google.sheets({
    version: 'v4',
    auth
  });
  const spreadsheetId = 'myIdHere';
  const range = 'Overview!B5:H60';
  try {
    const response = await sheets.spreadsheets.values.get({
      spreadsheetId,
      range
    });
    const rows = response.data.values;
    return rows;
  } catch (error) {
    console.error('error', error);
  }
}

(async() => {
  const pcc = await readCerts();
  if (interaction.commandName === 'stats') {
    const maar = new EmbedBuilder()
      .setTitle('Statistics for Current Month')
      //.setDescription('cool description here')
      .setColor('Red')
      .setThumbnail('https://i.imgur.com/9GKhYQf.png')
      .setFooter({
        text: 'DroneOS',
        iconURL: 'https://i.imgur.com/9GKhYQf.png'
      })
      .setTimestamp()
      .addFields({
        name: `Total AARs: `,
        value: `${raar}`,
        inline: false,
      });
    interaction.reply({
      embeds: [maar]
    });
  }
})()

Issue with Custom Slider Component: Thumbs Not Moving on onValueChange Event

I have a custom slider component in my React application where I’ve added two thumbs using the SliderPrimitive from @radix-ui/react-slider. The issue I’m facing is that whenever I add the onValueChange event, the thumbs cannot be moved, although I can see the changed values in the console. Without the onValueChange event, the thumbs move as expected.

Below is the code for my Slider component:

"use client"

import * as React from "react"
import * as SliderPrimitive from "@radix-ui/react-slider"

import { cn } from "@/lib/utils"

const Slider = React.forwardRef(({ className, defaultValue = [0, 1000], max = 1000, step = 1, ...props }, ref) => {
  const [value, setValue] = React.useState(defaultValue);

  const handleChange = (newValue) => {
    setValue(newValue);
  };

  const shouldDisplayRangeTogether = value[1] - value[0] < 100;

  return (
    <div className="relative w-full">
      <SliderPrimitive.Root
        ref={ref}
        className={cn("relative flex w-full touch-none select-none items-center", className)}
        value={value}
        onValueChange={handleChange}
        max={max}
        step={step}
        {...props}>
        <SliderPrimitive.Track
          className="relative h-0.5 w-full grow overflow-hidden rounded-full bg-gray-200 dark:bg-slate-800">
          <SliderPrimitive.Range className="absolute h-full bg-dark-gray dark:bg-slate-50" />
        </SliderPrimitive.Track>
        {value.map((val, index) => (
          <React.Fragment key={index}>
            <SliderPrimitive.Thumb
              className="block h-3 w-3 rounded-full border border-dark-gray bg-white duration-700 hover:bg-green ring-offset-white transition-colors focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-slate-950 focus-visible:ring-offset-0 disabled:pointer-events-none disabled:opacity-50 dark:border-slate-50 dark:bg-slate-950 dark:focus-visible:ring-slate-300"
            />
            {!shouldDisplayRangeTogether && (
              <div
                className="absolute -top-8 w-10 text-center text-sm font-medium transform -translate-x-1/2"
                style={{
                  left: `${(val / max) * 95}%`
                }}
              >
                {props.currency}{val}
              </div>
            )}
          </React.Fragment>
        ))}
      </SliderPrimitive.Root>
      {shouldDisplayRangeTogether && (
        <div
          className="absolute -top-8 left-1/2 transform -translate-x-1/2 text-sm font-semibold"
        >
          {props.currency}{value[0]} - {props.currency}{value[1]}
        </div>
      )}
    </div>
  );
});
Slider.displayName = SliderPrimitive.Root.displayName;

export { Slider }

Here’s how I’m using the Slider component in my Price component:

import React, { Fragment, useEffect, useState } from "react";

// Components
import { Slider } from "@/components/ui/slider";

const Price = () => {
  const [prices, setPrices] = useState();
  const [searchByPrice, setSearchByPrice] = useState();

  async function getPrices() {
    let response = await fetch("/api/filters/get-prices", {
      method: "POST"
    });
    let data = await response.json();
    setPrices(data.data);
  }

  useEffect(() => {
    getPrices()
  }, [])

  const handleValueChange = (_prices) => {
    setSearchByPrice(_prices);
  };

  return (
    <Fragment>
      <div className="bg-light-gray px-5 pt-5 pb-7 rounded-2xl">
        <h6 className="text-base font-semibold mb-10">Price</h6>
        {prices &&
          <Slider
            defaultValue={[prices[0].default_min_price, prices[0].default_max_price]}
            max={prices[0].max_price}
            step={1} 
            currency="₹" 
            onValueChange={handleValueChange}
          />
        }
      </div>
    </Fragment>
  );
};

export default Price;

Script incompletely loading in WordPress [closed]

I have a script from HireTrakStar that displays available positions in my company. When you click on a position, it shows the job description along with a button for form submission. However, when you click the button, only input boxes without labels are displayed.
I used HTML box element inside Elementor(WordPress) to insert the script on the page.

I was expecting the labels to displayed with the input boxes. Script is working fine until it gets to this form.

Failed to resolve module specifier “@tauri-apps/api/http”

import { fetch } from '@tauri-apps/api/http';

document.addEventListener('DOMContentLoaded', async function() {
  const serverIP = 'http://185.221.21.49:30120/players.json';
  const playerCountElement = document.getElementById('player-count');

const response = await fetch(serverIP, {   method: 'GET', timeout: 1000, })
console.log("response:", response)
    .then(response => {
      if (!response.ok) {
        throw new Error(`Network response was not ok: ${response.statusText}`);
      }
      return response.data;
    })
    .then(data => {
      if (data && data.players) {
        playerCountElement.textContent = `Játékosok száma: ${data.players.length}`;
      } else {
        playerCountElement.textContent = "Játékosok száma: Nem sikerült lekérni";
      }
    })
    .catch(error => {
      console.error("Error fetching player count:", error);
      playerCountElement.textContent = "Játékosok száma: Nem sikerült lekérni";
    });
});

Error code:
Error code: TypeError: Failed to resolve module specifier “@tauri-apps/api/http”. Relative references must start with either “/”, “./”, or “../”.

I’ve tried everything, I’ve searched and searched for a solution but I can’t find it, please help me. I just can’t get it to work.

I’ve tried a lot of things, most of which I’ve saturated by search

Getting info about the Telegram bot in the Telegram web app

I have a common server and backend (written in Python) for several Telegram bots, each bot has access to a mini-application. When opening this web application, a backend request must be executed, and database entries corresponding to a specific bot must be selected – this data will be displayed in the web application. The problem is that it is not entirely clear how it can be determined which bot is opening the mini-application. The only way seems to be to make a request to the backend via the bot id. But according to the Telegram Mini Apps documentation, it is impossible to get information about the bot through the object window.Telegram.WebApp. So, the question is: is there any other possible way to get information about the bot, including its ID, from the Telegram mini-application? Or is this possible only when executing the getMe method via the Telegram Bot API on the server? And if so, is it possible to somehow transfer information from the server to the mini-application when it is opened from the bot (that is, without making requests to the server from the mini-application)?

In search of a solution, I studied the documentation on Telegram Mini Apps and Telegram Bot API, and also searched on stackoverflow and github, but did not find anything that would help to find the answer to the question.

R shiny app – rendering is much slower when run on remote server compared to local server

I made an R shiny app which runs perfectly in my local browser on my local server, however the rendering is noticeably slower when I run the same app from my local browser on a remote server. A quick Chrome performance check indicates this has to do with Animation and not Networking (see figure), but noticeably more time is spent on Animation when the app is run from the remote server compared to the local server?

The app consists of a reactable and 3 ggplots which get re-rendered when the table is filtered on a specific value.

I expected the app to perform similarly on the local and the remote server respectively. Do you know why this is not the case, and what can be done so that the app will be as snappy on the remote server as it is on my local server?

Figure of R shiny app performance on remote server

Change Face-api.js landmarks pointColor

This is my code and i want to Change pointColor and lineColor but i don’t know how?
I am using fast-api.js library and i don’t found any sample with customized Landmarks Styles.

export const drawResults = async (image, canvas, results, type) => {
      if (image && canvas && results) {
        const imgSize = image.getBoundingClientRect();
        const displaySize = { width: imgSize.width, height: imgSize.height };
        faceapi.matchDimensions(canvas, displaySize);
        canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height);
        const resizedDetections = faceapi.resizeResults(results, displaySize);
    
        switch (type) {
          case 'landmarks':
            faceapi.draw.drawFaceLandmarks(canvas, resizedDetections);
            break;
          case 'expressions':
            faceapi.draw.drawFaceExpressions(canvas, resizedDetections);
            break;
          case 'box':
            faceapi.draw.drawDetections(canvas, resizedDetections);
            break;
          case 'boxLandmarks':
            faceapi.draw.drawDetections(canvas, resizedDetections);
            faceapi.draw.drawFaceExpressions(canvas, resizedDetections);
            faceapi.draw.drawFaceLandmarks(canvas, resizedDetections);
            break;
          default:
            break;
        }
      }
    };
    ```

Why doesn’t my for loop wait for setTimeout in JS? [duplicate]

I wanted to make a simon game. This is the website if you want to have a look at https://ozankrds.github.io/simon-game/ . I want the colors that showed up so far to pop up followingly. This is the code I’ve written:

for (let i = 0; i < gamePattern.length; i++) {
        setTimeout(function () {
            $("#" + gamePattern[i]).fadeIn(100).fadeOut(100).fadeIn(100);
            
            // Adds the sound corresponding to the color
            playSound(gamePattern[i]);
        }, 500);
    }

But the different colors poped up simultaneously.

I asked chatgpt about how to do that and it told me to assign the time to be 500 * i. But I didn’t exactly understand why? Why doesn’t one sequence wait 500 ms and then iterate i?

dateRangePicker js maxSpan when I select the second date the time automatically becomes 00:00 as it will solve

$(dateRangePicker).daterangepicker({
    opens: 'center',
    drops: 'down',
    autoUpdateInput: false,
    timePicker: true,
    timePicker24Hour: true,
    maxSpan: {
        days: 6
    },
    startDate: moment().startOf('day'),
    endDate: moment().endOf('day'),
    alwaysShowCalendars: true,
    applyButtonClasses: "btn-success",
    locale: {
        cancelLabel: 'Clear',
        format: 'DD-MM-YYYY HH:mm'
    }
});

$(dateRangePicker).on('apply.daterangepicker', function (ev, picker) {
    this.value = picker.startDate.format('DD-MM-YYYY HH:mm') + ' - ' + picker.endDate.format('DD-MM-YYYY HH:mm');
});

$(dateRangePicker).on('cancel.daterangepicker', function (ev, picker) {
    this.value = '';
    picker.setStartDate(moment().startOf('day'));
    picker.setEndDate(moment().endOf('day'));
});

moment().endOf(‘day’) here the time is set to 23:59 but maxSpan when you select the last day of the week the time automatically becomes 00:00

minDate maxDate tried and didn’t work

Integrate third party API in Angular [closed]

I have one library that gives pharmacy related data and I want to integrate in Angular, they have simple JavaScript code as below:

$('div#rxContainer').WebRefill({
    PharmacyId: "SOMEID",
    PharmacyPhone: '555-555-5555',
    AuthServiceUrl: 'https://auth.apps.scriptpro.com/', // url for authorization service
    RefillServiceUrl: 'https://webrefill.apps.scriptpro.com/', // url for refill service
    PaymentServiceUrl: 'https://payment.apps.scriptpro.com/', // url for payment service
    ColorTheme: {
        TitleBar: '#333300',
        Background: '#D4D5C6',
        BreadCrumb: '#6D6D4A',
        BreadCrumbActive: '#4A4A21',
        MainButton: '#333333',
        SecondaryButton: '#6D6D4B',
        RxContainerHeader: '#6D6D4A',
        RxContainer: '#CD853F',
        Title: '#333300',
        EmphasisText: '#330000'
    }
});

HTML: <div id="rxContainer"></div>

I’ve added required script in index.html file:

<script src="scriptpro/Scripts/ScriptPro.WebRefill.js"></script>

NOTE: “SOMEID” in PharmacyId will be dynamic.

I have tried as below:

HTML: <div id="rxContainer"></div>

.ts file:

const element = document.getElementById('rxContainer');
    if (element) {
        element.innerHTML = 'Content Updated!';
        element.WebRefill({
            PharmacyId: '2215b3ae-3ad7-4c47-9bed-a7da9c4aa561',
            RefillServiceUrl: 'https://webrefill.apps.scriptpro.com/',
            AuthServiceUrl: 'https://auth.apps.scriptpro.com/',
            PaymentServiceUrl: 'https://payment.apps.scriptpro.com/',
            ColorTheme: {
                TitleBar: '#333300',
                Background: '#D4D5C6',
                BreadCrumb: '#6D6D4A',
                BreadCrumbActive: '#4A4A21',
                MainButton: '#33333',
                SecondaryButton: '#6D6D4B',
                RxContainerHeader: '#6D6D4A',
                RxContainer: '#CD853F',
                Title: '#333300',
                EmphasisText: '#33000'
            }
        });
        this.cdRef.detectChanges();
    }

But it shows an error

Property ‘WebRefill’ does not exist on type ‘HTMLElement’.

Rendering UI Component at onclick

I am just working on a project, I just wanted to ask that can we do ui component rendering at onclick.

Example:

<div name="log-in" onclick={<Login/>}>                  
</div>

suppose that login component is created

I am just expecting a concise explanation, opinion regarding good practices or alternative in compare to what I was trying to do.

How do i fix this issue with long decimals? [duplicate]

Im adding two variables, “giveMoney” and “money”, but they result in a number with like 15 decimals.
The code is referenced below.

giveMoney = users; // Users is equal to one in this scenario
giveMoney /= 10;
money += giveMoney;

Im not sure on how to fix this…
For context, this is for a Incremental Clicker game im working on, and the output is going to a <p> element with the id “money”.
Any ideas?

giveMoney = users; // Users is equal to one in this scenario
giveMoney /= 10;
money += giveMoney;

Im not sure on how to fix this…
I’ve tried doing a .toFixed(1); on it, but i dont want it to constantly have a decimal.

For context, this is for a Incremental Clicker game im working on, and the output is going to a <p> element with the id “money”.

I know how to get rid of the decimals entirely, but i dont want to do that, because its adding 0.1 every 100ms. How do i make it so when it has decimals, it just has 1 decimal, but when it doesn’t, it just doesn’t?
I know why it has a long bit of decimals, but i dont know HOW TO FIX IT.
Can anyone help?
I dont just want a response that is just money = money.toFixed(1);, because than money will always have a decimal, even when its a whole number, making an error. How do i make it so when it DOES have a decimal, it only has one, but then it can also be a whole number without having a decimal?

I did all of this because for every user, it gives +1 money a second, but i didn’t like the counter just going up by 1 every second, i want it so u can see it go up every 100 ms. So im making it go up by 0.1 every 100 ms.