Integrating Redis with Nodered

 redisHandlerInstance.getRedisClient().get(`deviceIDStore:${IMEI}`, (err, reply) => {
      if (err) {
        node.error(err.message, msg);
        return;
      }
      if (!reply) {
    
      } else {
        // Data exist in Redis, 
          console.log("Data",reply)
      }
    });

Iam trying to integrate Redis with nodered with below versions
“redis”: “^3.1.2”,
“redis-cli”: “^2.1.2”,

Here i need to check whether data exist or not, if not need to do some operation
When i execute the flow , iam getting

UnhandledPromiseRejectionWarning: ReplyError: ERR wrong number of arguments for ‘get’ command
at parseError (/opt/dmsApps/SO_NODERED/dms-node-red-so-conversion-svc/node_modules/redis-parser/lib/parser.js:179:12)
at parseType (/opt/dmsApps/SO_NODERED/dms-node-red-so-conversion-svc/node_modules/redis-parser/lib/parser.js:302:14)
(node:3556828) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 322)

I tried the following approaches:

  1. Checked whethere redis is connecting or not
    2.’ deviceIDStore:${IMEI} ‘ is defined or not
  2. deleting the redis package and re installing
  3. Upgrading the version
  4. deleted the entire node modules and re installed

Still same error

jQuery calling the function twice [duplicate]

We have this jQuery code that handles tap and click. We need to do this since old ios version does not support click only.

The problem is with latest ios, the function is being execute twice. Once from the click event and one for the tap event.

$(".test").on("click tap", function(){
  console.log("yey!");
})
.test {
  width: 100px;
  height: 100px;
  background-color: red;
  cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<div class="test"> CLICK HERE </div>

Question: How to prevent the lastest IOS from calling the function twice?

Thanks in advance.

Google Dataflow – MongoDB-to-BigQuery batch mode failing with filter on data

Related Template(s)

MongoDB-to-BigQuery

Template Version

v2

What happened?

I have function that checks if a field is true or not. If its true then it returns null to skip saving that document into BigQuery.

I have tried doing a return undefined, return “” and i keep getting the same issue which is

com.google.cloud.teleport.v2.common.UncaughtExceptionLogger - The template launch failed.
java.lang.IllegalArgumentException: schema can not be null

Below is a code snippet

function deliveries_transform(input_doc) {
  var doc = JSON.parse(input_doc)

  // Filters
  if (doc.has_parent) {
    return null;
  }

  //return after stringifying
  return JSON.stringify(doc);
}

I referred to the example stated in this link
https://cloud.google.com/dataflow/docs/guides/templates/create-template-udf#filter_events

The job was created using the google console and not via api or sdk.

Relevant log output

[
  {
    "insertId": "",
    "jsonPayload": {
      "line": "exec.go:66",
      "message": "com.google.cloud.teleport.v2.common.UncaughtExceptionLogger - The template launch failed.njava.lang.IllegalArgumentException: schema can not be nullntat org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkArgument(Preconditions.java:143)ntat org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.withSchema(BigQueryIO.java:2679)ntat com.google.cloud.teleport.v2.mongodb.templates.MongoDbToBigQuery.run(MongoDbToBigQuery.java:154)ntat com.google.cloud.teleport.v2.mongodb.templates.MongoDbToBigQuery.main(MongoDbToBigQuery.java:96)n"
    },
    "resource": {
      "type": "dataflow_step",
      "labels": {
        "region": "",
        "project_id": "",
        "step_id": "",
        "job_name": "mongodb-to-bigquery-batch",
        "job_id": ""
      }
    },
    "timestamp": "2024-02-12T21:45:00.037010Z",
    "severity": "ERROR",
    "labels": {
      "compute.googleapis.com/resource_name": "",
      "dataflow.googleapis.com/region": "us-east4",
      "dataflow.googleapis.com/job_id": "",
      "compute.googleapis.com/resource_id": "",
      "compute.googleapis.com/resource_type": "",
      "dataflow.googleapis.com/job_name": "mongodb-to-bigquery-batch"
    },
    "logName": "",
    "receiveTimestamp": "2024-02-12T21:45:02.855403339Z",
    "errorGroups": [
      {
        "id": "CPXppsbT8JP4nQE"
      }
    ]
  },
  {
    "insertId": "",
    "jsonPayload": {
      "message": "Error: Template launch failed: exit status 1",
      "line": "launch.go:80"
    },
    "resource": {
      "type": "dataflow_step",
      "labels": {
        "job_name": "mongodb-to-bigquery-batch",
        "job_id": "",
        "step_id": "",
        "project_id": "",
        "region": ""
      }
    },
    "timestamp": "",
    "severity": "ERROR",
    "labels": {
      "dataflow.googleapis.com/region": "",
      "dataflow.googleapis.com/job_id": "",
      "compute.googleapis.com/resource_id": "",
      "compute.googleapis.com/resource_type": "",
      "compute.googleapis.com/resource_name": "",
      "dataflow.googleapis.com/job_name": "mongodb-to-bigquery-batch"
    },
    "logName": "",
    "receiveTimestamp": "2024-02-12T21:45:02.855403339Z"
  },
  {
    "textPayload": "Error occurred in the launcher container: Template launch failed. See console logs.",
    "insertId": "xl5y9bd22ed",
    "resource": {
      "type": "dataflow_step",
      "labels": {
        "project_id": "",
        "job_id": "2024-02-12_13_43_46-15601135711795228441",
        "job_name": "mongodb-to-bigquery-batch",
        "step_id": "",
        "region": ""
      }
    },
    "timestamp": "2024-02-12T21:47:43.432514787Z",
    "severity": "ERROR",
    "labels": {
      "dataflow.googleapis.com/job_id": "2024-02-12_13_43_46-15601135711795228441",
      "dataflow.googleapis.com/region": ",
      "dataflow.googleapis.com/log_type": "",
      "dataflow.googleapis.com/job_name": "mongodb-to-bigquery-batch"
    },
    "logName": "",
    "receiveTimestamp": "2024-02-12T21:47:43.962727013Z"
  }
]

I tried these

function deliveries_transform(input_doc) {
  var doc = JSON.parse(input_doc)

  // Filters
  if (doc.has_parent) {
    return null;
  }

  //return after stringifying
  return JSON.stringify(doc);
}
function deliveries_transform(input_doc) {
  var doc = JSON.parse(input_doc)

  // Filters
  if (doc.has_parent) {
    return undefined;
  }

  //return after stringifying
  return JSON.stringify(doc);
}
function deliveries_transform(input_doc) {
  var doc = JSON.parse(input_doc)

  // Filters
  if (doc.has_parent) {
    return "";
  }

  //return after stringifying
  return JSON.stringify(doc);
}

I was expecting that during the dataflow job, it will skip inserting that current document and move to the next one

SAP Spartacus carousel supports for mobile?

SAP spartacus storefront carousel component will work for mobile?

Swiping left and right should navigate products in the carousel. below is the existing template which works for desktop.

    <cx-carousel #prp *ngIf="products$ | async as product" [title]="title" [hideIndicators]="true" [product]="product"
      [template]="carouselItem">
    </cx-carousel>
    
    <ng-template let-item="product" #carouselItem>
      <a class="product-image-link" tabindex="0" [routerLink]="['/', 'product', product.code]">
        <cx-media [container]="product.images?.PRIMARY" format="product"
          [attr.aria-label]="'prpref' | cxTranslate"></cx-media>
      </a>
      <div class="product-desc">
        // other code
      </div>
    </ng-template>

TypeError: render is not a function while calling and rendering data from API

So, I am creating a movie app in React JS and while rendering a component based on the data fetched from API, I am getting this error

render is not a function TypeError: render is not a function

error i am getting

Here’s my code, totally working for TvListProvider but getting error for TopRatedProvider

export const TvListProvider = ({ render }) => {
  const url_tv = `${BASE_URL}/3/trending/tv/day?api_key=${API_KEY}`;

  const { data: tv, isLoading, isError } = useDataProvider(url_tv);
  console.log(typeof render);

  return (
    <Suspense fallback={<div>Loading...</div>}>
      {render({ tv, isLoading, isError })}
    </Suspense>
  );
};

export const TopRatedProvider = ({ render }) => {
  const url_topRated = `${BASE_URL}/3/movie/top_rated?api_key=${API_KEY}`;

  const { data: topRated, isLoading, isError } = useDataProvider(url_topRated);

  return (
    <Suspense fallback={<div>Loading...</div>}>
      {render({ topRated, isLoading, isError })}
    </Suspense>
  );
};

and here is how i am using this

<TopRatedProvider
   render={({ topRated, isError }) => (
     <ListComponent data={topRated} isError={isError} />
   )}
/>

I tried all the search engines, all the AI but still couldn’t figure out the solution

Unable to resize blocks once height and width are set inside a containing square

I have a very unique issue that I am unable to solve. When setting a fixed width and height for two squares within a containing square, the resize functionality from the css tag ‘resize’: ‘both’; behaves strangely. I am unable to use percentages so am currently setting the width and height of the squares to vh and wh. For demonstration purposes I have put a code snippet below. If the squares are dragged to the left, no problem they can resize with ease. But if the squares are dragged to the right, it’s not easy, the width is not reset correctly.

/* style.css */
.resizable-square {
    resize: both;
    overflow: auto;
    border: 2px solid #000;
    box-sizing: border-box;
}

.container-square {
    width: 300px; /* Initial width of the container */
    height: 300px; /* Initial height of the container */
    display: flex; /* Use Flexbox for inner squares */
    align-items: center; /* Center inner squares vertically */
    justify-content: space-around; /* Space out inner squares */
    background-color: #90EE90; /* Light green background for container */
}

.inner-square {
    width: 100px; /* Initial width of inner squares */
    height: 100px; /* Initial height of inner squares */
    background-color: #6495ED; /* Light blue background for inner squares */
    margin: 10px; /* Space between inner squares and container border */
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Resizable Squares</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="resizable-square container-square">
        <div class="resizable-square inner-square"></div>
        <div class="resizable-square inner-square"></div>
    </div>
</body>
</html>

Changing data from API call before setState [duplicate]

I have a set of data generated during runtime (genSheets), an api call retrieved similar data(responseSheets.data), and I want to change the generated data according to the records I got from the api call, before I use setState(timesheets).

const getTimesheets = async () => {
  try {
    const responseSheets = await api.get(
      "/sheets/" + employeeEmail + "/" + month + "/" + year,
    );
    for (let j = 0; j < responseSheets.data.length; j++) {
      if (
        genSheets.find(
          (genSheet) => genSheet.date === responseSheets.data[j].date,
        )
      ) {
        for (let i = 0; i < genSheets.length; i++) {
          if (genSheets[i].date === responseSheets.data[j].date) {
            genSheets[i].dayType = responseSheets.data[j].dayType;
            genSheets[i].hoursWorked = responseSheets.data[j].hoursWorked;
            genSheets[i].hoursOvertime = responseSheets.data[j].hoursOvertime;
          }
        }
      }
    }
    setTimesheets(responseSheets.data);
  } catch (err) {
    console.log(err);
  }
  console.log(timesheets);
};

my jsx:

<tbody className="body">
  {
    timesheets.map((user, index) => {
      return (
        <tr key={index}>
          <td>{user.date}</td>
          <td>{user.dayType}</td>
          <td>{user.hoursWorked}</td>
          <td>{user.hoursOvertime}</td>
        </tr>
      )
    })
  }
</tbody>

the error:

Uncaught TypeError: Cannot read properties of undefined (reading 'map')
    at Modal (Modal.js:236:1)

(this is at the timesheet.map line I posted above)

I want to update the generated data (genSheets) with the dayType, hoursWorked, and hoursOvertime values from the API call (responseSheets.data) before using setState(timesheets). I was wondering if it would be better not to put the timesheets in state at all, or if there are any better ways to achieve this using js. Thanks.

a product has five different serial number how i add it Mern Stack

I want to make book keeping management where has a product lots of quantity and every unit has different identity number or serial number. I want to store products with each identity number or unique number

https://i.imgur.com/I5DFV.jpg
initialize state

array handle

Input Body

Output display

When I try insert new unique number previous number have been changed and all of the number being last entered number

how to prevent special charactors in ion-input .?

special characters are accepting in input field . i am using the field for storing the serial number.
serial number is alphanumeric

<ion-input [(ngModel)]="serial_number" (ngModelChange)="validation($event)" #serialno  id="serialno"  class="cac-input"></ion-input>
  validation(event) {
    const inputElement = document.getElementById('serialno') as HTMLInputElement;
    const pattern = /^[a-zA-Z0-9]*$/;
    console.log(event)
    console.log(pattern.test(event))
    let c = event.replace(/[^a-zA-Z0-9 ]/g, '');
    inputElement.value = '';
    inputElement.value = c;
    console.log(c)
    this.serial_number = c;
  }

i previously used regex for removing the special characters….but after removing also the value is shown in input field…

i need to prohibit special characters from entering in input field.

in browser , using (keypress) event working fine….but in android (keypress) event is not working

In app the field shows

consoling the ngmodel field shows

How to add Tailwind CSS in SvelteKit official demo application?

I have created sample application by following steps given at https://kit.svelte.dev/docs/creating-a-project

npm create svelte@latest my-app

So the project structure is

alok@alok-HP-Pavilion-Laptop-14-dv0xxx:~/exp/my-app$ tree -L 3 --gitignore
.
├── jsconfig.json
├── package.json
├── package-lock.json
├── playwright.config.js
├── README.md
├── src
│   ├── app.d.ts
│   ├── app.html
│   ├── lib
│   │   └── images
│   └── routes
│       ├── about
│       ├── Counter.svelte
│       ├── Header.svelte
│       ├── +layout.svelte
│       ├── +page.js
│       ├── +page.svelte
│       ├── styles.css
│       └── sverdle
├── static
│   ├── favicon.png
│   └── robots.txt
├── svelte.config.js
├── tests
│   └── test.js
└── vite.config.js

This project already have src/routes/styles.css file and import './styles.css'; inside src/routes/+layout.svelte file.

Now I want to add Tailwind CSS by following https://tailwindcss.com/docs/guides/sveltekit

In this page they are asking to create ./src/app.css and import it in src/routes/+layout.svelte

What I have to do with my existing src/routes/styles.css file?

What is right way to add Tailwind CSS in official demo app?

Remove an Element that not existed when page loaded (JavaScript)

In add new Phone number page in my website i wanna let users can have multiple phone numbers. here i have is HTML code:

<div class="d-flex align-items-center justify-content-between">
  <input class="textfield" placeholder="Phone Number..." type="number" />
  <button class="btn btn-primary me-1" id="addNewTelephone">
    <i class="fa-regular fa-plus fs-6"></i>
  </button>
</div>

<div class="d-flex align-items-center justify-content-between mt-2">
  <input class="textfield" placeholder="Phone Number..." type="number" />
  <button class="btn btn-danger me-1 deleteAddition">
    <i class="fa-regular fa-minus fs-6"></i>
  </button>
</div>

First one is the necessary number that always is visible in the page but second one is an addition number that is not exist in our page unless user click the #addNewTelephone button.

In all addition number containers we have a button with deleteAddition class that can remove its parent(the addition nubmer) form page but its just works when we added the addition container in out code and if user add them using #addNewTelephone button, .deleteAddition wont working for remove those added containers.

also here is my js(Jquery) code (#telephoneContainer is the main container for all numbers):

$('#addNewTelephone').click(function (e) { 
    $('#telephoneContainer').append($('<div>',{class:'d-flex align-items-center justify-content-between mt-2'}).append($('<input>', {class:"textfield", placeholder:"Phone Number...", type:"number"}),$('<button>',{class:"btn btn-danger me-1"}).append($('<i>',{class:"fa-regular fa-minus fs-6"}))),);    
  });
  $('.deleteAddition').click(function (e) { 
    $(this).parent().remove();
  });

I want users can add new number also can remove them using these two buttons

azure-active-directory-service-principal-secret node sequelize migrations

I’m connecting db with service principal by using below method in express using
link

but while running migrations it will establish connection from db.config file
where db.config file contains

  "development": {
"username": process.env.DB_USER,
"password": process.env.DB_PASSWORD,
"database": process.env.DB_DATABASE,
"host": process.env.DB_HOST,
"dialect": "mssql",
"logging": false

},

so how to configure the db.config file for service principal method

SharePoint Upload Files To Document Library Using Rest API

I have a form “developed by JS” and this form has two sections fields related to other 2 forms and each of them file input.
when the user clicks on submit the form should update the same request with specific status then take the value from the first section create an item in other document library then upload multiple files to the same item then take the new item id and update the current item with the URL then do the same to other section.
the issue is the files uploading sometimes upload all files and sometimes upload some of the files not all and sometimes doesn’t upload any of them.
Note: i tried to log or alert the response but not appear and sometimes appear.

This my code

for (var i = 0; i < files.length; i++) {
    var formData = new FormData();
    console.log(files[i]);
    formData.append('fileInput', files[i]);
    var branchName = KYCCompliance.getBranchNameFromCode(branchCode);
    var siteUrl = `${KYCCompliance.webUrl}/_api/web/GetFolderByServerRelativeUrl('/sites/KYC/${KYCCompliance.CardsUploadData.DocStorage.DocListInternalName}${branchName}/${onlineBankingObj.Title}')/files/add(url='${files[i].name}',overwrite=true)')`
    var headers = new Headers();
    headers.append('X-RequestDigest', $("#__REQUESTDIGEST").val());
    $.ajax({
        url: siteUrl,
        type: 'POST',
        async: true,
        data: formData,
        processData: false,

        contentType: false,
        headers: {
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
        },
        success:function (response) {
            // alert(`File ${files[i].name} uploaded successfully.`)
            return console.log('File uploaded successfully. Response: ' + response);
        },
        error: function (error) {
            // alert(`Error uploading file: ${files[i].name}`  + error.statusText)
            return console.log('Error uploading file: ' + error.statusText);
        }
    });
}

TypeError: Cannot read properties of undefined (reading ‘optionOne’)

I have tried many thing to solve this problem but I am not able to find the solution. My reducer function always giving same error. I don’t what’s wrong with my code . If some can help me in debugging It will be a great help. when I try to log (state) it gives proxy array but on other hand when I log current state it return data. I am adding the reducer code below and github link

import { createSlice ,current} from "@reduxjs/toolkit"; 
import {_saveQuestion,_saveQuestionAnswer} from '../_DATA';
 

const allQuestionSlice = createSlice({

    name:"allQuestion",
    initialState:{
        allQuestion:null
    },
    reducers:{
       allQuestionData :(state,action)=>{
            state.allQuestion = action.payload
         },  
         addNewAnswer(state  , action) {       

          if (action.payload.option === "optionOne") {
            state.allQuestion[action.payload.qid]["optionOne"].votes.push(action.payload.authedUser);
            } else if (action.payload.option === "optionTwo") {
            state.allQuestion[action.payload.qid]["optionTwo"].votes.push(action.payload.authedUser);
            }
             
 
          // const {allQuestion} = current(state)         
          // if (action.payload.option === "optionOne") {
          //   allQuestion.filter( x=> x.id == action.payload.id)[0].optionOne.votes.concat(action.payload.userid)    
          //   console.log(    allQuestion.filter( x=> x.id == action.payload.id)[0].optionOne.votes.concat(action.payload.userid)    )        
          // } else if (action.payload.option === "optionTwo") {
          //   allQuestion.filter( x=> x.id == action.payload.id)[0].optionTwo.votes.concat(action.payload.userid)
          //   console.log(  allQuestion.filter( x=> x.id == action.payload.id)[0].optionTwo.votes.concat(action.payload.userid) )
          // }
        },
  },

    extraReducers: (b) => {
        b.addCase("addQuestion", (state, action) => {             
            state.allQuestion.push( action.payload);        
          });
          
        
      },    
    })




export const saveQuestion=(saveQuestionData)=>async(d)=>{
    const data = await _saveQuestion(saveQuestionData);
    d({type:"addQuestion",payload:data});
};
  
// export const addNewAnswer =({ authedUser, qid, answer})=>async(d)=>{
//   debugger
//   const data = await _saveQuestionAnswer({ authedUser, qid, answer});
//   d({type:"addAnswer",payload:data});
// };
export const {allQuestionData ,addNewAnswer} = allQuestionSlice.actions;

export default allQuestionSlice.reducer;

Different code that I tried to implement but did not succeed.

import { createSlice ,current} from "@reduxjs/toolkit"; 
import {_saveQuestion,_saveQuestionAnswer} from '../_DATA';
 

const allQuestionSlice = createSlice({

    name:"allQuestion",
    initialState:{
        allQuestion:null
    },
    reducers:{
       allQuestionData :(state,action)=>{
            state.allQuestion = action.payload
         },  
         addNewAnswer(state , action) {   
          const { authedUser , qid ,option  } = action.payload
          // { authedUser: loggedInUser, qid: question_id, option: event };
          return {
            ...state.value,
            [qid]: {
              ...state.value[qid],
              optionOne: {
                votes:
                option === "optionOne"
                    ? state.value[qid].optionOne.votes.concat([authedUser])
                    : state.value[qid].optionOne.votes,
              },
              optionTwo: {
                votes:
                option === "optionTwo"
                    ? state.value[qid].optionTwo.votes.concat([authedUser])
                    : state.value[qid].optionTwo.votes,
              },
            },
          }



          // return {
          //   ...state,
          //   [qid]: {
          //     ...state[qid],
          //     optionOne: {
          //       votes:
          //         option === "optionOne"
          //           ? state[qid].optionOne.votes.concat([authedUser])
          //           : state[qid].optionOne.votes,
          //     },
          //     optionTwo: {
          //       votes:
          //         option === "optionTwo"
          //           ? state[qid].optionTwo.votes.concat([authedUser])
          //           : state[qid].optionTwo.votes,
          //     },
          //   },
 
          // };
        },
  },

    extraReducers: (b) => {
        b
        .addCase("addQuestion", (state, action) => {             
            state.allQuestion.push( action.payload);        
          })
        .addCase("ANSWER_QUESTION", (state, action) => {
            // const questions = {
            //   ...state.value,
            //   [action.payload.qid]: {
            //     ...state.value[action.payload.qid],
            //     [action.payload.answer]: {
            //       ...state.value[action.payload.qid][action.payload.answer],
            //       votes: state.value[action.payload.qid][
            //         action.payload.answer
            //       ].votes.concat([action.payload.authedUser]),
            //     },
            //   },
            // };
           // state.value = questions;

           console.log(current(state))


          })

         

      },  
        
    })




export const saveQuestion=(saveQuestionData)=>async(d)=>{
    const data = await _saveQuestion(saveQuestionData);
    d({type:"addQuestion",payload:data});
};
  
// export const saveQuestionAnswer = ({ authedUser, qid, answer }) =>
//   async (dispatch) => {
//     const data = await _saveQuestionAnswer({ authedUser, qid, answer });

//     dispatch({ type: "ANSWER_QUESTION", payload: { authedUser, qid, answer } });
//   };
export const {allQuestionData ,addNewAnswer} = allQuestionSlice.actions;

export default allQuestionSlice.reducer;