Aligning two set of data of different lengths

I’ve never posted on here before and I’m an amatuer when it comes to using Excel and Google Sheets so if this problem has a very simple solution thats why I’ve not seen it. And yes I also know Excel is probably the better choice for trying to solve this problem, if it can be done in sheets it’s easier for me but if not then it will have to be done in excel.

Long story short, I work in an RDC for a supermarket and I have a very long list of stores with a product ID (PIN) they’ve ordered and an associated demand for that PIN. But it comes from head office in 2 different “tags”. I need to be able to compare both lists, only list 1 has stores that list 2 doesn’t, and list 2 has stores that list 1 doesn’t. Which means side by side they are ofset and don’t line up for an easy comparison.

I should add that the whole list is about 80 stores long and has about 64,000 rows of data. I’ve shared a sheet publicly of just 3 products if anyone would like to play around with it then feel free to. I’ve also manually gone through the first 3 products and lined them up and highlighted the stores that don’t have a record in both lists of data. I’ve only done that for a visualisation, at the end of the day I’m only interested in the data that’s in both lists. Anything highlighted in red (Bold on here) or any blank spaces can be deleted.

Store 1 PIN 1   Total Demand 1      Store 2 Pin 2   Total Demand 2
1   100274252   8       1   100274252   10
12  100274252   33      12  100274252   10
140 100274252   19      140 100274252   10
205 100274252   39      205 100274252   10
276 100274252   5       276 100274252   10
278 100274252   10      278 100274252   10
284 100274252   6       284 100274252   10
290 100274252   8       290 100274252   10
293 100274252   8       293 100274252   10
294 100274252   7       294 100274252   10
295 100274252   8       295 100274252   10
296 100274252   32      296 100274252   10
298 100274252   8       298 100274252   10
299 100274252   20      299 100274252   10
302 100274252   81      302 100274252   30
305 100274252   18      305 100274252   10
307 100274252   112     306 100274252   10
309 100274252   112     307 100274252   10
313 100274252   18      309 100274252   30
314 100274252   6       313 100274252   10
316 100274252   31      314 100274252   10
345 100274252   10      315 100274252   30
353 100274252   8       316 100274252   10
355 100274252   8       345 100274252   10

Store 1 PIN 1   Total Demand 1      Store 2 PIN 2   Total Demand 2
1   100274252   8       1   100274252   10
12  100274252   33      12  100274252   10
140 100274252   19      140 100274252   10
205 100274252   39      205 100274252   10
276 100274252   5       276 100274252   10
278 100274252   10      278 100274252   10
284 100274252   6       284 100274252   10
290 100274252   8       290 100274252   10
293 100274252   8       293 100274252   10
294 100274252   7       294 100274252   10
295 100274252   8       295 100274252   10
296 100274252   32      296 100274252   10
298 100274252   8       298 100274252   10
299 100274252   20      299 100274252   10
302 100274252   81      302 100274252   30
305 100274252   18      305 100274252   10
                      **306 100274252   10**
307 100274252   112     307 100274252   10
309 100274252   112     309 100274252   30
313 100274252   18      313 100274252   10
314 100274252   6       314 100274252   10
                      **315 100274252   30**
316 100274252   31      316 100274252   10
345 100274252   10      345 100274252   10

Raw data
Aligning the data manually

https://docs.google.com/spreadsheets/d/1QQ_69oSTm92tak9Zqpekbkkb2gLxLi1kmaoJj3lAE-s/edit?usp=sharing

I have no idea where to start with this, but I need to find a way of writing a script or formula that can be repeated for the whole 64,000 rows of data. I could probably ask someone in IT but get this feeling I’ll learn more on here and will get a quicker response.

TOPdesk API error 401, I inserted the API key but doesn’t seem to be working

I am trying to connect to TOPdesk’s API but I keep getting error 401, so it’s about authentication. I have an API key though and my account is authorized to see the API data. When I try to see the data on Postman it works, but I am unable to retrieve it from the API and store in on my own database. This is a snippet of my code, with a few alterations due to privacy reasons, and also to keep it shorter:

...
dotenv.config();
...
// Function to fetch data from the API and store it in the database
const fetchDataFromAPI = async () => {
    const apiUrl = 'https://mycompany.topdesk.net/tas/api/....';

    try {
        // Make HTTP request to the API
        const response = await axios.get(apiUrl, {
        headers: {
            'Authorization': `Bearer ${apiKey}` //API Key is stored on a .env file.
        }
    });

        // Extract relevant data from the API response
        const incidents = response.data.incidents;

        // Insert data into the SQLite database
        incidents.forEach(async (incident) => {
            const { id, status, closedDate } = incident;

            const insertQuery = `
                INSERT INTO ticketsIT (id, status, closedDate)
                VALUES (?, ?, ?, ?, ?);
            `;

            // Execute the insert query
            db.run(insertQuery, [id, status, closedDate], (err) => {
                if (err) {
                    console.error('Error inserting data into the database:', err);
                } else {
                    console.log('Data inserted into the database successfully.');
                }
            });
        });
    } catch (error) {
        console.error('Error fetching data from the API:', error.message);
    }
};

// Schedule the data fetch to happen when the server starts
fetchDataFromAPI();

I get an error on the terminal saying Request failed with status code 401.

I tried using the API key PLAIN on the code (lmao) but now it’s inside a different file. Not sure about what to do, my link works on Postman as I said but not on my code.

Why can’t I access React Context variables and states changes inside onClick function of a button in a custom Autodesk extension?

I Have a Viewer component wich uses context variables and works fine. I want to implement some custom extensions to this viewer, and I placed their declaration inside useEffect hook running just once, they’re being registred.

Inside these extensions I have some buttons, that are loaded in onToolbarCreated, and onClick function uses React Context variables but they return undefined or the initial value, how to make them recognize these variables?

Code:

function Viewer() {
const {
    setMainViewer,
    isTreeActive,
    isIssuesListActive,
    isBlueprintsListActive,
    isIssueDatailsActive,
    setCurrentIssueSelected,
    currentIssueSelected,
} = useContext(AppContext);

useEffect(() => {
    const auxinitViewer = async () => {
        setMainViewer(
            await initViewer(document.getElementById("mainViewerDiv"))
        );
    };
    initExtensions();
    auxinitViewer();
}, []);

const initExtensions = async () => {

    // TOOLBAR EXTENSION
    function UpperViewPanel(viewer, options) {
        //... code
    }

    UpperViewPanel.prototype = Object.create(
        Autodesk.Viewing.UI.DockingPanel.prototype
    );
    UpperViewPanel.prototype.constructor = UpperViewPanel;

    function ToolbarExtension(viewer, options) {
        Autodesk.Viewing.Extension.call(this, viewer, options);
    }

    ToolbarExtension.prototype = Object.create(
        Autodesk.Viewing.Extension.prototype
    );
    ToolbarExtension.prototype.constructor = ToolbarExtension;

    ToolbarExtension.prototype.load = function () {
        this.viewer.fitToView();
        return true;
    };

    ToolbarExtension.prototype.unload = function () {
        if (this.subToolbar) {
            this.viewer.toolbar.removeControl(this.subToolbar);
            this.subToolbar = null;
        }
    };
    var button3 = new Autodesk.Viewing.UI.Button("enable-upper-view");

    ToolbarExtension.prototype.onToolbarCreated = async function (toolbar) {
        var mainViewer = this.viewer;
        const upper_view_panel_div =
            document.getElementById("upper-view-panel");
        if (upper_view_panel_div) {
            upper_view_panel_div.remove();
        }
        
        let panel;
        if (mainViewer.model.is3d()) {
            panel = new UpperViewPanel(this.viewer, null);
            panel.initViewer();
        }

        button3.onClick = function (e) {
            // HERE IS THE PROBLEM, currentIssueSelected is always undefined
            console.log("CURRENT ISSUE SELECTED", currentIssueSelected);
            if (!currentIssueSelected) {
                showErrorToasty(
                    "Não é possível ver planta sem um problema selecionado"
                );
            } else {
                if (!currentIssueSelected.linkedDocuments[0]) {
                    showErrorToasty(
                        "Este problema não contém posicionamento"
                    );
                } else {
                    if (
                        panel.getVisibility().display === "block" &&
                        panel.getVisibility().zIndex === "-1"
                    ) {
                        panel.setIssue(currentIssueSelected);
                        panel.setVisible();
                        button3.removeClass("top_view");
                        button3.addClass("top_view_selected");
                    } else if (panel.getVisibility().display === "none") {
                        panel.setIssue(currentIssueSelected);
                        panel.setVisible();
                        button3.removeClass("top_view");
                        button3.addClass("top_view_selected");
                    } else if (
                        panel.getVisibility().display === "block" &&
                        panel.getVisibility().zIndex === "0"
                    ) {
                        panel.setIssue(currentIssueSelected);
                    }
                }
            }
        };
        button3.removeClass("top_view_selected");
        button3.addClass("top_view");
        button3.setToolTip("Mostrar planta");

        var issues_combo_button = new Autodesk.Viewing.UI.ComboButton(
            "issues_combo_button"
        );
        issues_combo_button.setIcon("issues_combo_button");

        issues_combo_button.onMouseOver = function (e) {
            issues_combo_button.setIcon("issues_combo_button_selected");
        };
        issues_combo_button.onMouseOut = function (e) {
            issues_combo_button.setIcon("issues_combo_button");
        };
        var utils_combo_button = new Autodesk.Viewing.UI.ComboButton(
            "utils_combo_button"
        );
        utils_combo_button.setIcon("utils_combo_button");

        utils_combo_button.onMouseOver = function (e) {
            utils_combo_button.setIcon("utils_combo_button_selected");
        };
        utils_combo_button.onMouseOut = function (e) {
            utils_combo_button.setIcon("utils_combo_button");
        };

        this.subToolbar = new Autodesk.Viewing.UI.ControlGroup(
            "my-custom-toolbar"
        );
        this.subToolbar2 = new Autodesk.Viewing.UI.ControlGroup(
            "my-custom-toolbar2"
        );
        if (mainViewer.model.is3d()) {
            utils_combo_button.addControl(button3);
        }
        this.subToolbar.addControl(issues_combo_button);
        // SubToolbar
        toolbar.addControl(this.subToolbar);
        if (mainViewer.model.is3d()) {
            this.subToolbar2.addControl(utils_combo_button);
            toolbar.addControl(this.subToolbar2);
        }
    };

    Autodesk.Viewing.theExtensionManager.registerExtension(
        "ToolbarExtension",
        ToolbarExtension
    );
};

const handleViewerWidth = () => {
    //...
};

return (
    <div
        style={{
            width: handleViewerWidth(),
            height: "100%",
            position: "absolute",
            left: `${
                isTreeActive || isIssuesListActive || isBlueprintsListActive
                    ? "23%"
                    : "3%"
            }`,
        }}
        id="mainViewerDiv"
    />
)}

In the above example you can see that I use the context variable currentIssueSelected inside button3 onClick and it’s always undefined, what I already tried:

  1. Receive the currentIssueValue by a props in viewer component function Viewer({currentIssueSel}){...};
  2. Make a global function and assign it to the onClick;

Any suggestions?

Application crashes in production and the error is bizarre

I have a serious problem in application. After entering the app, it crashes. I have logs in the console:

2.ccabb150.chunk.js:2 Uncaught (in promise) TypeError: undefined is not a function
    at Array.some (<anonymous>)
    at 2.ccabb150.chunk.js:2:463493
    at n.value (2.ccabb150.chunk.js:2:464613)
    at vs (2.ccabb150.chunk.js:2:1181680)
    at Rl (2.ccabb150.chunk.js:2:1198469)
    at t.unstable_runWithPriority (2.ccabb150.chunk.js:2:1223762)
    at Yo (2.ccabb150.chunk.js:2:1140287)
    at Al (2.ccabb150.chunk.js:2:1195204)
    at bl (2.ccabb150.chunk.js:2:1191290)
    at 2.ccabb150.chunk.js:2:1140510

When I click on the “chunk” link, I get the marked fragment:

enter image description here

I did like everything to find the issue, but still it fails. Have anyone spotted such issue?

How to get Javascript Variable Content in to a Velocity variable?

I am using Polarion, which uses Velocity Template and thus javascript and html. A lot of the details don’t really matter but I use

#set($currentId = "this.id")
console.log($currentId)
activityBox.innerHTML += ${currentId};

Which logs and correctly appends the right Id of the div im on right now.
However if I try to invoke a function from my Java API it doesn’t properly evaluate the variable $currentId

#set($currentWorkitem = $trackerProject.getWorkItem($!{currentId}))
console.log("$currentWorkitem")

it does call the function, but with the wrong argument. It uses “this.id” instead of the actual Id.

I know this most likely has something to do with the order in which velocity and javascript are evaluated, but I don’t know if I can fix this. How can I properly put the value of a javascript expression inside my velocity variable?

How can I convert a class that has a super call to a function?

I have the following:

import { Immutable, ImmutableStore, useStorePersistence } from 'signalstory'

export class RegistrationStore extends ImmutableStore<TRegistrationState> {
   constructor() {
      super({
         name: 'RegistrationStore',
         mutationProducerFn:
            produce as unknown as MutationFn<TRegistrationState>,
         // enableLogging: !environment.production,
         initialState: new RegistrationState(),
         plugins: [
            useStorePersistence({
               persistenceKey: 'RegistrationStore',
               persistenceStorage: localStorage,
            }),
            ...environment.defaultStorePlugins(),
         ],
      })
   }

   store: Immutable<TRegistrationState> = this.state()
}

How could I convert it into a function?

Error accessing media devices:Error Secure random number generation is not supported by this browser. Use Chrome, Firefox or Internet Explorer 11

I’m facing an issue while implementing WebRTC functionality in my application’s local development environment. I’m using self-signed certificates but continuously encountering a ‘Secure random number generation’ error in WebRTC.

The specific error message I’m encountering is: “Error accessing media devices: Error: Secure random number generation is not supported by this browser. Use Chrome, Firefox or Internet Explorer 11.”

Here’s a high-level overview of what I’ve attempted:

  • Implemented self-signed certificates for local development purposes.
  • Configured my server and client to communicate using these certificates.
  • Updated dependencies and libraries, including simple-peer, socket.io-client, etc., to their latest versions.
  • Ensured compatibility with commonly supported browsers like Chrome and Firefox.

Despite these efforts, the issue persists, preventing successful access to media devices, and resulting in the aforementioned error message.

Could there be specific configurations or settings required for WebRTC to function correctly with self-signed certificates in a local development environment? Are there any known workarounds or additional steps necessary to address the ‘Secure random number generation’ error in WebRTC?

Any insights or suggestions on resolving this issue would be highly appreciated. Thank you!

 const startMedia = async () => {
try {
    const mediaStream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
    if (videoRef.current) {
        setStream(mediaStream);
        socket.on('me', (id) => setMe(id));
        videoRef.current.srcObject = mediaStream;
    }
    if (socket) {
        const peer = new SimplePeer({
            initiator: true,
            trickle: false,
            stream: mediaStream,
        });

        peer.on('signal', (data) => {
            console.log('Sending signal to the peer:', data);
            socket.emit('signal', data);
        });
    }
} catch (error) {
    console.error('Error accessing media devices:', error);
}

};

effect of .toString() wile protecting firebase database from injection attacks in particular of http and database change trigger functions

i am using firebase functions for a wile now and many times i pass some data wile converting it to string by using .toString() between database and function . of course database also consist users input data and is allow to enter any type of character. so wile processing the data from .toString() is sufficient measure to protect from injection .

i will appreciate any deep explanation of behind the seen of working of firebase functions .

Rails Error: ActionController::UnknownFormat is missing a template for this request format and variant

I have a form in index page and I want that the action will be executed by Ajax, to display the result in the Index page.
This is my form in the index Page:

        <%= form_with model: @shopping, :url => {:action => "searchByDates"}, remote: true do |form| %>
        <div class="form-group">
            <%= form.label :date_start %>
            <%= form.date_field :date_start, attribute: 'date' %>
            <%= form.label :date_end %>
            <%= form.date_field :date_end, attribute: 'date' %>
        </div>
        <div class="form-group">
            <%= form.submit "Cerca", class: 'btn btn-primary' %>
        </div>
    <% end %>

This is my controller action:

  def searchByDates
    @date_start = params[:date_start]
    @date_end = params[:date_end]
    @shoppings = Shopping.where(:date_shopping => @date_start..@date_end)
    respond_to do |format|
      format.html
      format.js
    end
  end

And this is my searchByDates.js.erb, in the folder of the view

$('#shoppingTable').html("<%= j render partial: 'shoppinglists' %>");

I have added the route in the routes.rb filepost 'shoppings/searchByDates'

What am I missing? Thanks

Fetch API cannot load blob:944201ef-4497-4a3b-8fd1-a2e84dfc5ea3?type=Text. URL scheme “blob” is not supported

   const blobUrl = 'blob:944201ef-4497-4a3b-8fd1-a2e84dfc5ea3?type=Text';
   const replacedBlobUrl = blobUrl.replace('blob:', 'blob:https//somewebsite.com');
    
   fetch(replacedBlobUrl)
  .then(response => response.blob()) // Fetch the Blob data
  .then(blobData => {
    const fileReader = new FileReader();

    fileReader.onload = function(event) {
      const blobText = event.target.result;
      // 'blobText' contains the text data from the Blob URL
      console.log(blobText);

      // Perform further parsing or operations with the parsed data here
    };

    fileReader.readAsText(blobData); // Read the Blob data as text
  })

I have a file that is saved as blob URL.
I’m getting the error as the title says, I don’t know what I should do?

Custom build eraser brush in fabric js

How to use Custom build in reactjs?
I want to include eraser brush of fabric JS due to which I need to have the custom build as EraserBrush is not present in default build.

I have downloaded the custom build file from http://fabricjs.com/build/ and replaced it with the files under dist folder of fabric under node_modules. But it doesn’t seem to be working. What am I missing here?

JQuery AJAX request stuck pending indefinetely

I am trying to use jQuery.ajax({}) to run a PHP file. All my ajax requests will not execute and just remain pending forever.

I have looked at many different solutions but none have worked.

    let account= [{email: null, pass: null, accountType: null}]
    function logIn() {
    account.email = document.getElementById("emailInput").value;
        account.pass = document.getElementById("passwordinput").value;
    if(account.email.substring(0,1) === '1'){
        account.accountType = "student";
    } else if (account.email === ''/* admin email*/) {
        account.accountType = "super";
    } else {
        account.accountType = "teacher";
    }

    $.ajax({
        url:"logIn.php",
        type: "POST",
        data: {
            email: account.email,
            password: account.pass,
            accountType : account.accountType
        },
        success: function (data) {
            //do something
        }
    });

above my code just grabs user input from <input> fields in HTML. then figures out an accountType and tries to run the ajax file. When I debug the program the ajax statement does nothing at all. the php file doesn’t even run one line. I don’t know what is stopping the requests from working. This happens on Firefox and Chrome.

PHP file for reference:

<?php

$conn = mysqli_connect("localhost", "root", "root", "mentorDB");
if($conn->connect_error) {
    die('Connection failed: ' . $conn->connect_error);
}
$email = $_POST['email'];
$password = $_POST['password'];
$accType = $_POST['accountType'];

if ($accType == 'student') {
    $query = "SELECT `student_email`, `user_pass` FROM `students` WHERE `student_email` LIKE ? AND `user_pass` LIKE ?";
    $stmt = $conn->prepare($query);

    if ($stmt === false) {
        die('Error preparing query: ' . $conn->error);
    }
    $stmt->bind_param("ss", $email, $password);
    $stmt->execute();
    $result = $stmt->get_result();

    if ($result->num_rows > 0) {
        //Fetch result rows as associative arrays
        while ($row = $result->fetch_assoc()) {
            $data[] = $row;
        }
    }
    header('Content-Type: application/json');
    echo json_encode($data);

    $conn->close();
} elseif ($accType == 'teacher') {
    $query = "SELECT `teacher_email`, `user_pass` FROM `teachers` WHERE `teacher_email` LIKE ? AND `user_pass` LIKE ?";
    $stmt = $conn->prepare($query);
    if ($stmt === false) {
        die('Error preparing query: ' . $conn->error);
    }

    $stmt->bind_param("ss", $email, $password);
    $stmt->execute();
    $result = $stmt->get_result();

    if ($result->num_rows > 0) {
        //Fetch result rows as associative arrays
        while ($row = $result->fetch_assoc()) {
            $data[] = $row;
        }
    }

    header('Content-Type: application/json');
    echo json_encode($data);
}

Here is what the network console looks like:
pending network request

Mostly just wondering if there is something in my JS code that is making the ajax request stay pending forever.

Sorry if this code is no good I’m in high school and it’s all new to me.

h() render function in Vue returning [object Object]

I’m trying to display icon when condition is passed and for that I’m using theme icon

Script Code
<script setup>
import { h } from 'vue'
const props = defineProps({
  itemDetail: Object
});

const passedIcon = h('i', {class: 'bx bxs-check-circle'});
const failedIcon = h('i', {class: 'bx bxs-cross-circle'});
</script>
Template Code
<template>
 <tr>
  <td>Zip check</td>
  <td>
   {{ props.itemDetail.status == 'pass' ? 'Passed ' + passedIcon : 'Failed ' + failedIcon }}
  </td>
 </tr>
</template>

But It’s returning

Passed [object Object]

or 

Failed [object Object]

I had tried with h() render function but passed directly through .innerHTML which works fine but How can I achieve to directly call as html with h() render function in the template?

Generate thumbnail from url showing passthrough error (pdf-thumbnail)

  async function generatePdfThumbnail(pdfUrl, taskId) {
    try {
        // Download the PDF file
        const response = await axios.get(pdfUrl, { responseType: 'arraybuffer' });
        const pdfBuffer = Buffer.from(response.data);
        
        pdfThumbnail(pdfBuffer, {
            resize: {
              width: 200,   
              height: 200,  
            }
          })
            .then(data => {
                console.log(data);

            })
            .catch(err => console.log(err))

        return null
    } catch (error) {
       console.error('Error generating PDF thumbnail:', error.message);
       return null
    }
    }

console.log(data);
prints some passthrough error. like below:

PassThrough {
  _events: {
    close: [Function: bound onceWrapper] { listener: [Function: onclose] },
    error: [Function: onerror],
    prefinish: [Function: prefinish],
    finish: [Function: bound onceWrapper] { listener: [Function: onfinish] },
    drain: undefined,
    data: undefined,
    end: undefined,
    readable: undefined,
    unpipe: [Function: onunpipe]
  },
  _readableState: ReadableState {
    highWaterMark: 16384,
    buffer: [],
    bufferIndex: 0,
    length: 0,
    pipes: [],
    awaitDrainWriters: null,
    [Symbol(kState)]: 1048844
  },
  _writableState: WritableState {
    highWaterMark: 16384,
    length: 0,
    corked: 0,
    onwrite: [Function: bound onwrite],
    writelen: 0,
    bufferedIndex: 0,
    pendingcb: 0,
    [Symbol(kState)]: 17580812,
    [Symbol(kBufferedValue)]: null
  },
  allowHalfOpen: true,
  _maxListeners: undefined,
  _eventsCount: 5,
  [Symbol(shapeMode)]: true,
  [Symbol(kCapture)]: false,
  [Symbol(kCallback)]: null
}

i am trying to generate pdf thumbnail from pdf Url but it shows some passthrough error iam using pdf-thumbnail npm package. i am using this package but it is not working. if i use generate it shows pdfThumbnail.generate is not a function

Unable to see the Terminal in VS Code [closed]

Visual studio code on windows 8/Windows Swerver 2012 will soon stop receiving updates. Consider upgrading your windows version.and unable to see terminal in VS Code.

I am using windoes 10 but still I am getting this message and unable to see terminal in VS Code. I have uinstall VSCode and installed latest VSCode but still same issue comming.

Can any one help me on this ?