How does the BERT algorithm interpret the contextual relevance of synonyms in search queries?

Problem Introduction: Exploring how BERT impacts SEO for synonym usage in queries.

Technical Depth: Utilizing Google Analytics and SEMrush to analyze query relevance changes post-update; investigating potential shifts in SERP due to NLP algorithm adjustments.

What I Tried: Implemented semantic analysis tools to track how synonyms in search queries influenced page rankings before and after the BERT update.

What I Expected: Anticipated more nuanced understanding by BERT leading to improved rankings for contextually relevant but synonymously varied content.

What Actually Resulted: Saw no significant change in rankings for tested keywords, contrary to expectations. Analysis suggests potential oversight in synonym context integration within BERT’s framework.

How to add an array item inside array of objects of an object in react-redux toolkit?

I am trying to update the user object’s blockedUsers array, while keeping other data not changed. user object can have blockedUsers array or not, it is not certain. In slice I have:

    reducers: { CHANGE_USER: (state, action) => {
      state.user.push(action.payload)
    },
   }

And in component, I am trying to update this way:

dispatch(CHANGE_USER({blockedUsers: [...user?.blockedUsers, selectedUser] }))

where selectedUser is an object: {id: "xxxx", name: "yyyy"}. But error comes:

Possible unhandled promise rejection (id:2). 
TypeError: Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator()] method.

How can I solve this?

VueUse useIntersectionObserver causes initial flash before transition

I’m using useIntersectionObserver from VueUse to apply a fade-in transition on elements when they come into view. However, on initial page load, the elements briefly appear before the intersection observer triggers, causing a flash and applying the fade-in effect with a delay.

I want the elements to fade in smoothly as soon as the page loads, without this initial flash.
Here’s the reproduction:
https://stackblitz.com/edit/nuxt-starter-vd6hka?file=app%2Fpages%2Findex.vue

Observer component:

<template>
  <div>
    <div ref="observerRef">
      <div :class="{ 'fade-in': isVisible }">
        <img crossOrigin="anonymous" src="https://unsplash.it/600/400" />
      </div>
    </div>
  </div>
</template>

<script setup>
import { useIntersectionObserver } from '@vueuse/core';

const observerRef = ref(null);
const isVisible = ref(false);

const { stop } = useIntersectionObserver(
  observerRef,
  ([{ isIntersecting }]) => {
    isVisible.value = isIntersecting;
    if (isIntersecting) stop();
  }
);
</script>

Looking for a possible solution.

jquery disable arrow keys of keyboard on web page

I want to disable left and right arrows key of keyboard on a webpage, preventing the scroll to the previous or next slide.

I’ve this code:

jQuery(document).ready(function( $ ){  

document.onkeydown = function(e) {
  if (e.keyCode == 39 ) {
    alert('Not allowed');
     event.preventDefault();
    e.stop();
  }
    if (e.keyCode == 37 ) {
    alert('Not Allowed!');
    event.preventDefault(); 
    e.stop();
  } 
};
});

This is working: when I click on arrow key, the site shows alert, and then when I close it, its righty do anything (so I stay on the current slide).

The problem is when I disable the alerts: in this case, when I click on rigt or left key,the site goes to the next or to the previous slide, ignoring the block of the keyboard.

Any suggestion?
Thanks

Sending email upon document creation in firebase with cloud function

I’m currently building a flutter app that allows users to request meetings with others. When one user requests another user, the requested user should receive an email saying they got a request. when a new request is created, a new document is appended into the collection meeting_requests. Using the Google Cloud functions, I was able to write the following code with nodemailer to send an email upon creation of a request:

const transporter = nodemailer.createTransport({
  service: "gmail",
  auth: {
    user: <MY EMAIL HERE>
    pass: <MY APPS PASSWORD HERE>,
  },
});

exports.sendMeetingNotification = functions.firestore
    .document("meeting_requests/{docId}")
    .onCreate(async (snap, context) => {
      const data = snap.data();
      const receiverId = data.receiverId;

      console.log("Fetching user data for receiverId:", receiverId);

      try {
        const userDoc = await admin.firestore().collection(
            "users").doc(receiverId).get();

        if (!userDoc.exists) {
          console.log("No user found with the given receiverId:", receiverId);
          return;
        }

        const email = userDoc.data().email;

        console.log("Found user with email:", email);

        const mailOptions = {
          from: ""ConnectEd" [email protected]",
          to: email,
          subject: "New Meeting Request from Teacher",
          html: `
        <div style="background-color: #f9f7cf; padding: 20px;
         font-family: Arial, sans-serif; color: #333;">
          <div style="text-align: center; margin-bottom: 20px;">
            <img src="https://your-logo-url.com/logo.png" alt="ConnectEd Logo" style="width: 100px; height: auto;" />
          </div>
          <div style="background-color: #fff; 
          padding: 20px; border-radius: 8px; 
          box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);">
            <h2 style="color: #2c3e50;
            ">New Meeting Request from ${data.senderName}</h2>
            <p style="font-size: 16px; line-height: 1.6;">
              <strong>Note from teacher:</strong> ${data.note}
            </p>
            <p style="font-size: 16px; line-height: 1.6;">
              Please click the link below to view the request:
            </p>
            <div style="text-align: center; margin: 20px 0;">
              <a href="yourapp://app/openRequest?requestId=${context.params.docId}" style="background-color: #f39c12; color: #fff; padding: 10px 20px; text-decoration: none; border-radius: 5px; font-size: 16px;">View Request</a>
            </div>
          </div>
          <div style="text-align: center; 
          margin-top: 20px; font-size: 12px; color: #999;">
            <p>© 2024 ConnectEd. All rights reserved.</p>
            <p>If you did not request this email, please ignore it.</p>
          </div>
        </div>
        `,
        };

        console.log("Sending email to:", email);

        await transporter.sendMail(mailOptions);
        console.log("Email sent successfully to:", email);
      } catch (error) {
        console.error("Error sending email notification:", error);
      }
    });


However, when I run it, no email is sent, and I get the following log error:

2024-09-07T14:37:34.038106Z ? sendMeetingNotification: Error sending email notification: Error: 7 PERMISSION_DENIED: Missing or insufficient permissions.
2024-09-07T14:37:34.038127Z ? sendMeetingNotification:     at callErrorFromStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call.js:31:19)

2024-09-07T14:37:34.038251Z ? sendMeetingNotification:   code: 7,
2024-09-07T14:37:34.038256Z ? sendMeetingNotification:   details: 'Missing or insufficient permissions.',
s.',
2024-09-07T14:37:34.038261Z ? sendMeetingNotification:   metadata: Metadata {
2024-09-07T14:37:34.038266Z ? sendMeetingNotification:     internalRepr: Map(1) { 'x-debug-tracking-id' => [Array] },
d' => [Array] },
2024-09-07T14:37:34.038270Z ? sendMeetingNotification:     options: {}
2024-09-07T14:37:34.038274Z ? sendMeetingNotification:   }
2024-09-07T14:37:34.038274Z ? sendMeetingNotification:   }
2024-09-07T14:37:34.038279Z ? sendMeetingNotification: }
2024-09-07T14:37:34.039269068Z D sendMeetingNotification: Function execution took 54 ms, finished with status: 'ok'

I’m new to this, so really did not understand what was going on.

I tried changing the firebase permissions, adding this gmail account to my cloud permissions, but nothing has worked. The odd thing was that it was working perfectly yesterday, and today it just doesn’t which is really confusing to me.

Thanks for the help!

How to change the clothes color of a JavaScript modal dynamically based on user selection?

I’m building a fashion stylist app in react naitve, and I want to add a feature where, when a user clicks on a specific color, the clothes color of a JavaScript modal changes dynamically. This would allow users to visualize how different colors look in real time.

I have no idea where to start with implementing this. Could someone guide me on how to achieve this functionality using JavaScript and react native?

Looking for a Calendar Package for Basic Calculations instead of Events

I’m looking for a calendar package / library in React Native or Flutter that allows me to do basic calculations rather than just adding events. For example, instead of creating events, I want to be able to add numbers—like if I add 100 every Tuesday, I want the calendar to total these entries at the end of the month automatically.

Ideally, it would be something I could use for recurring entries and basic math calculations on dates.

ASP.net code web app (MVC) retrieving data from sql is bringing the old data to the first columns

I am retrieving alot of data from the datatabse which bring it into a paged list and datatable. I would like to reverse the order so my new transactions are displayed on the first page and not last page.Everything works good except i need to bring the latest to the first page
Controller Code

using Deadfiles.Data;
using Deadfiles.Models;
using Deadfiles.ViewModels;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.EntityFrameworkCore;


namespace Deadfiles.Controllers
{
    public class DeadfilesController : Controller
    {


        private readonly ApplicationDbContext _context;

        public DeadfilesController(ApplicationDbContext context)
        {
            _context = context;
        }


        // GET: Deadfiles
        [Authorize(Roles = "Admin,User,Viewer")]
        public Task<IActionResult> Index(int pg = 1)

        {
            List<Deadfile> deadfiles = [.. _context.Deadfiles];

            const int pageSize = 10;
            if (pg < 1)
                pg = 1;

            var recsCount = deadfiles.Count;
            var pager = new Pager(recsCount, pg, pageSize);

            int recSkip = (pg - 1) * pageSize;

            var data = deadfiles.Skip(recSkip).Take(pageSize).ToArray();
            this.ViewBag.Pager = pager;
            // return Task.FromResult<IActionResult>(View(data));
            if (User.Identity.IsAuthenticated)
            {
                return Task.FromResult<IActionResult>(View(data));
            }
            else
            {
                return Task.FromResult<IActionResult>(this.Redirect("~/identity/account/login"));
            }


        }

Index Code

 @using Microsoft.AspNetCore.Identity                                                                                                                                                                                                                                                                                                                             @using Microsoft.AspNetCore.Identity
@model IEnumerable<ApplicationUser>
@{
    ViewData["Title"] = "Users";

}
<h1>Registered Users</h1>

<p>
    <a asp-action="Create" class="btn btn-primary"> <i class="fa fa-plus"></i> Add New User</a>
</p>


<div class="card">
    <div class="card-header">
        <h3 class="card-title">User List</h3>
    </div>
    <!-- /.card-header -->
    <div class="card-body">

        <table id="rolesTable" class="table table-bordered table-striped">
            <thead> 
                <tr>
                    <th>Name</th>
                    <th>Surname</th>
                    <th>Email Address</th>
                    <th>User Role</th>
                    <th>Action</th>
                </tr>
            </thead>    
            <tbody>
                @foreach (var item in Model)
                {
                    <tr>
                        <td>@Html.DisplayFor(modelitem => item.FirstName)</td>
                        <td>@Html.DisplayFor(modelitem => item.LastName)</td>
                        <td>@Html.DisplayFor(modelitem => item.Email)</td>
                        <td>@Html.DisplayFor(modelitem => item.Role.Name)</td>
                        <td><a asp-action="Edit" asp-controller="Account" asp-route-id="@item.Id" class="btn btn-primary"><i class=" fa fa-pencil"></i>Edit</a></td>
                        <td><a asp-action="Delete" asp-controller="Account" asp-route-id="@item.Id" class="btn btn-danger"><i class=" fa fa-edit"></i>Delete</a></td>
                  
                    </tr>
            
                }
            </tbody>
        </table>
    </div>
</div>                                                                  

Paging Model

namespace Deadfiles.Models
{
    public class Pager
    {
        public int TotalItems { get; private set; }
        public int CurrentPage { get; private set; }
        public int PageSize { get; private set; }
        public int TotalPages { get; private set; }
        public int StartPage { get; private set; }
        public int EndPage { get; private set; }

        public Pager()
        {

        }
        public Pager(int totalItems, int page, int pageSize = 30)
        {
            int totalPages = (int)Math.Ceiling((decimal)totalItems / (decimal)pageSize);
            int currentPage = page;

            int startPage = currentPage - 5;
            int endPage = currentPage + 4;

            if (startPage <= 0)
            {
                endPage = endPage - (startPage - 1);
                startPage = 1;
            }

            if (endPage > totalPages)
            {
                endPage = totalPages;
                if (endPage > 10)
                {
                    startPage = endPage - 9;
                }
            }

            TotalItems = totalItems;
            CurrentPage = currentPage;
            PageSize = pageSize;
            TotalPages = totalPages;
            StartPage = startPage;
            EndPage = endPage;

        }


    }
}

I have spent days trying to get this to work

Nodemailer – Emails send but i do not recieve them

I am working on a project that uses nodemailer, when i submit the form, i get a 200 sucess and no errors from nodemailer but i don not recieve the email in my mail.

import nodemailer from "nodemailer";


const Email = (options) => {
    let transporter = nodemailer.createTransport({
        name: '[email protected]',
        service: "gmail",
        host: "smtp.gmail.com",
        port: 587,
        secure: false,
        auth:{
            user:'user',
            pass:'password',
        }
    })
     
    transporter.sendMail(options, (err, info) => {
        if (err) {
            console.log(err);
            return;
        }
        console.log("Email sent: " + info.response); // Log success message
    });
};

//SEND EMAIL
const EmailSender = ({firstName, lastName, email, companyName, typeOfDeveloper, recruitmentType}) => {
    const options = {
        from: `Darcia⚜️`,
        to: `[email protected]`,
        subject: "Message from Darcia",
        html:`
    <div style="width: 100%; background-color: #f3f9ff; padding: 5rem 0">
        <div style="max-width: 700px; background-color: #feffe1; margin: 0 auto; background-image: url('https://res.cloudinary.com/dlxrzazn6/image/upload/v1725041898/jepdinustkmgor5cltdp.png'); background-repeat: no-repeat; background-size: 50%; background-position: 130% 300%;">
          <div style="width: 100%; background-color: #2b2b2b; padding: 20px 0">
          <a href="https://darcia-frontend.vercel.app" >
            <img
              src="https://res.cloudinary.com/dlxrzazn6/image/upload/v1725043148/mmciecekert56v0xc3y9.png"
              style="width: 100%; height: 70px; object-fit: contain"
            />
        </a> 
          
          </div>
          <div style="width: 100%; gap: 10px; padding: 30px 0; display: grid">
            <p style="font-weight: 800; font-size: 1.2rem; padding: 0 30px">
              Darcia hiring agnecy
            </p>
            <div style="font-size: .8rem; margin: 0 30px">
                <p>FullName: <b>${firstName}</b> <b>${lastName}</b></p>
                <p>Email: <b>${email}</b></p>
                <p>CompanyName: <b>${companyName}</b></p>
                <p>Type of Developer: <b>${typeOfDeveloper}</b></p>
                <p>Recruitment type: <b>${recruitmentType}</b></p>
            </div>
          </div>
        </div>
      </div> 
        `

    };
    Email(options)
}

export default EmailSender;

i have tried using a different mailing service and even changing the host and port but nothing

Vue 3 reliably binding values from data-driven elements

I am a long-time backend engineer trying to get my head around Vue 3. In order to do this I am developing a small cover letter generator app, with the intent of allowing people to manage their own cover letter templates (defined as a json object containing metadata, a Mustache string for the template text, and a variable number of sections which can be toggled on or off depending on whether or not they are relevant for the job the candidate is applying to) and then quickly and easily substitute in information like job title and employer name.

To support this, I’ve created a Pinia store as follows to manage templates (with the default template initialized by default):

import { defineStore } from 'pinia'

export const useTemplateStore = defineStore({
    id: 'template',
    state: () => ({
        templates: {
            default: {
                id: 'default',
                name: 'Default Template',
                templateText: `To whom it may concern,


I am interested in joining {{companyName.value}} as a {{jobTitle.value}}. In addition to my great admiration of {{companyName.value}}'s brand, I feel my skills and experience would make me an ideal member of the {{companyName.value}} team.
{{#managementExperience.isSelected}}

{{managementExperience.value}}
{{/managementExperience.isSelected}}

Thank you,
Wile E. Coyote`,
                sections: [
                    {
                        key: 'managementExperience',
                        label: 'Line Management Experience',
                        text: 'I am an experienced line manager, having managed teams for 10 years.',
                        isSelected: false
                    }
                ]
            }
        }
    }),
    actions: {
        addTemplate(template) {
            this.templates[template.id] = template
        }
    }
})

I’ve implemented a view which allows the user to select a template, enter some global params (companyName and jobTitle), and which has a checkbox and label generated for each ‘section’ defined as part of the template. This looks as follows:

<script setup>
import { computed, ref } from 'vue'
import Mustache from 'mustache'
import { useTemplateStore } from '../stores/template'
import { storeToRefs } from 'pinia'

const templateStore = useTemplateStore()
const { templates } = storeToRefs(templateStore)
const selectedTemplateKey = ref('')
const selectedTemplate = computed(() => {
    return templates.value[selectedTemplateKey.value]
})

const companyName = ref('')
const jobTitle = ref('')

const globalTemplateParams = computed(() => {
    return {
        jobTitle: {
            isSelected: Boolean(jobTitle.value),
            value: jobTitle.value
        },
        companyName: {
            isSelected: Boolean(companyName.value),
            value: companyName.value
        }
    }
})
const letterContent = computed(() => {
    let template = ''
    if (selectedTemplate.value) {
        template = selectedTemplate.value['templateText']
    }
    const params = {
        ...globalTemplateParams.value
    }
    return Mustache.render(template, params)
})
</script>

<template>
    <div id="home-view-content" class="row p-1 pt-4">
        <div class="col">
            <div class="row">
                <div class="col"><h1>Generate Cover Letter</h1></div>
            </div>
            <div class="row">
                <div id="options-column" class="col-4 primary-bordered">
                    <div class="row pt-2">
                        <div class="col"><h2 class="text-center">Template Selection</h2></div>
                    </div>
                    <div id="template-selection-row" class="row pt-2 align-items-center">
                        <div class="col-auto">
                            <label for="templateSelector" class="col-form-label">Select a Template</label>
                        </div>
                        <div class="col">
                            <select
                                id="templateSelector"
                                v-model="selectedTemplateKey"
                                class="form-control form-select"
                            >
                                <option
                                    v-for="(template, index) in templates"
                                    :key="template.id"
                                    :value="template.id"
                                    :selected="index === 0"
                                >
                                    {{ template.name }}
                                </option>
                            </select>
                        </div>
                    </div>
                    <div class="row pt-4">
                        <div class="col"><h2 class="text-center">Template Options</h2></div>
                    </div>
                    <div id="template-options-row" class="row pt-2">
                        <div class="col form-check form-switch">
                            <template v-if="selectedTemplate">
                                <template v-for="section in selectedTemplate.sections" :key="section.key">
                                    <input :id="`${section.key}-input`" class="form-check-input" type="checkbox" />
                                    <label class="form-check-label" :for="`${section.key}-input`">
                                        {{ section.label }}
                                    </label>
                                </template>
                            </template>
                        </div>
                    </div>
                </div>
                <div id="letter-area" class="col">
                    <form class="row gx-3 align-items-center">
                        <div class="col-auto">
                            <label for="company-name" class="col-form-label-lg">Company Name:</label>
                        </div>
                        <div class="col">
                            <input
                                id="company-name"
                                v-model="companyName"
                                type="text"
                                class="form-control form-control-lg"
                            />
                        </div>
                        <div class="col-auto">
                            <label for="job-title" class="col-form-label-lg">Job Title:</label>
                        </div>
                        <div class="col">
                            <input
                                id="job-title"
                                v-model="jobTitle"
                                type="text"
                                class="form-control form-control-lg"
                            />
                        </div>
                    </form>
                    <div class="row pt-3">
                        <div class="col">
                            <div id="letter-output" class="card">
                                <div class="card-body vh-85">{{ letterContent }}</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<style lang="scss" scoped>
#letter-output {
    div {
        white-space: preserve;
    }
}
</style>

The result of the above is as follows:
Screenshot of generated UI

I am struggling to wrap my head around how to reliably capture the state of the dynamically generated checkboxes so I can package them into the same json structure the global params are in and send them to Mustache for use in the template.

Any help that could be provided (including tips on improving what I’ve already implemented) would be greatly appreciated.

Rendering criteria specific 3d tiles of underground pipe utitlity in cesium

I am trying to showcase only those 3d tiles from b3dm format using cesium that satisfies the specific criteria regarding attribute/property of the pipeline data, I have used shapefile data having various attribute values about the pipeline to generate 3d tiles in b3dm format & trying to render it using cesium, I am using following code.

pipe_line.tileLoad.addEventListener(function (tile) {  

            const content = tile.content;
            
            let featuresLength = content.featuresLength;
            
            for (let j = 0; j < featuresLength; j++) {
              let feature = content.getFeature(j);
              if (feature instanceof Cesium.Cesium3DTileFeature) {
                let pipeLengthValue = feature.getProperty("Shape_Leng");

               if(pipeLengthValue==length1){
                   pipe_line.style = new Cesium.Cesium3DTileStyle({
                     show: `${feature['Shape_Leng']} == ${length1}`
                   });
                }
             }

}

“shape_leng” is the column name in the attribute table, whereas length1 is the length value we will get dynamically from the user. Although somehow this code is working but not correctly because sometimes it shows other features apart from those that satisfy the criteria, what can be done in this regard.

Why Isn’t the Virtual Keyboard Appearing on Mobile Devices for My Keyboard Tester?

I’m a beginner working on my third or fourth project, and I’m encountering an issue with my keyboard tester application. The project is named KeyMaster, and it works perfectly fine on PC browsers for testing keyboard events. However, I am having trouble getting the virtual keyboard to appear on mobile browsers.

Here’s a brief overview of my setup:

  • Repository Link: GitHub – CASIOmax/Keyboard-Tester

  • index.html Code:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="style.css">
        <link rel="icon" href="favicon.png" type="image/x-icon"> 
        <title>KeyMaster</title>
    </head>
    <body id="Sudo-Body">
        <div class="maindiv">
        <div id="insert"> Press any Keyboard key to see the magic!</div>
        </div>
        <input type="text" id="hiddenInput" style="position: absolute; top: -100px;" />
    </body>
        <script src="spirit.js"></script>
    </html>
    
  • spirit.js Code:

    const colorGen = function() {
        const hex = '0123456789ABCDEF';
        let color = '#';
        for (let i = 0; i < 6; i++) {
          color += hex[Math.floor(Math.random() * 16)];
        }
        return color;
    }
    
    const insert = document.getElementById('insert');
    const hiddenInput = document.getElementById('hiddenInput');
    
    document.body.addEventListener('touchstart', function() {
      hiddenInput.focus();
    });
    
    window.addEventListener('keydown', function(e) {
        const rand = colorGen();
        insert.innerHTML = `
        <table style="border: 1px solid ${rand};">
        <tr>
          <th style="border: 1px solid ${rand};">key</th>
          <th style="border: 1px solid ${rand};">keyCode</th>
          <th style="border: 1px solid ${rand};">Code</th>
        </tr>
        <tr>
          <td style="border: 1px solid ${rand};">${e.key === " " ? "Space" : e.key}</td>
          <td style="border: 1px solid ${rand};">${e.keyCode}</td>
          <td style="border: 1px solid ${rand};">${e.code}</td>
        </tr>
      </table>`;
      insert.style.color = "white";
    });
    

Issue:
The virtual keyboard does not appear on mobile browsers when the user touches the screen. I’ve included an invisible input field to trigger the keyboard, but it seems not to work as expected on mobile devices.

What I’ve Tried:

  • Ensuring the input field is focused when the screen is touched.
  • Using contenteditable as an alternative.
  • Checking for any CSS or JavaScript that might be interfering.

Any suggestions or solutions would be greatly appreciated. Thanks!

Div not showing with JavaScript

I’m currently improving my website for the use with mobile devices. Therefore I’m trying to open a menu with a click onto a equiv button. The menu is a fixed div with scrollable content and should appear and disappear with a click onto the button. Either option is working if set through the display property in CSS, but I’m not able to toggle the visibility through JavaScript.

function ToggleDiv() {
  var v = document.getElementById('equiv-submenu');

  if (v.style.display == '' || v.style.display == 'none') {
    v.style.display = 'block';
  }
  else {
    v.style.display = 'none';
  }
}
<div id="equiv" onclick="ToggleDiv()">
  <p>&equiv;</p>
</div>

<div id="equiv-submenu">
  <div id="equiv-submenu-content">
    ...
  </div>
</div>

How do I achieve GenericIdGenerator pattern with a Typescipt Express app?

For context my code is in Typescript, Express framework, database in postgres, using drizzleORM for database mapping, and I need to achieve something like the below code (Java/Hibernate) to create purchaseId’s when adding new records to the purchase table,

I don’t want solutions like getting the last record and incrementing +1, I want it to sync with the native database sequence so that even if I delete the last record (lets say P0000000010), the next record should be P0000000011 unless I reset the sequence manually

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generic-generator")
@GenericGenerator(name = "generic-generator",
        parameters = {
                @org.hibernate.annotations.Parameter(name = "prefix", value = "P"),
                @org.hibernate.annotations.Parameter(name = "digits", value = "9"),
                @org.hibernate.annotations.Parameter(name = "initial_id", value = "100000000"),
        },
        strategy = "com.myapp.example.backend.persistance.jparepository.generators.GenericIdGenerator")
String id;

Why is new Date() giving wrong date for other time zone users?

I have a hotel booking website ,so the problem is when the users who are residing in India and have IST time zone tries to book any hotel then the date they’re seeing is correct but when users who are outside IST time zone for example Eastern Daylight time zone they’re not able see correct date when they select it from calendar
I have set my laptop to EST time zone and when I select 7th of september 2024 from calendar and I can see props.checkin also has the same date but when it is passed to new Date(props.checkin) then the date automatically changes to 6th of september 2024 and this only happen in time zone other then IST

 useEffect(() => {
    console.log(
      "props.checkin>>>>>",
      new Date("Sat Sep 07 2024 00:00:00 GMT+0530 (India Standard Time)"),
    );
    dispatch(
      updateBookingDateRange({
        checkInDate: new Date(props.checkin),
        checkOutDate: new Date(props.checkout),
        searchedRoomCount: Number(props.num_rooms),
        searchAdultCount: Number(props.num_adults),
        searchedChildrenCount: Number(props.num_children),
        searchGuestCount: Number(props.num_guests),
      }),
    );

    if (
      totalRoomCount === 0 &&
      props.planStatus &&
      router.query.roomId &&
      router.query.planId
    ) {
      dispatch(
        addFirstRoom({
          roomInfo: props.roomDetails,
          planInfo: props.planDetails,
          roomCount: props.num_rooms,
          guestCount: Number(props.num_guests),
          adultCount: Number(props.num_adults),
          childCount: Number(props.num_children),
        }),
      );
    }
  }, [
    router.query.hotelInfo,
    router.query.checkin,
    router.query.checkout,
    router.query.num_guests,
    router.query.num_children,
    router.query.num_rooms,
  ]);

I’m expecting that when users that are in different time zone chooses some date then they too should see correct date instead of wrong date.