I wanna create an html page with all combinations of colours [duplicate]

My html is

<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="script.js"></script>
<link rel="stylesheet" href="style2.css">
<title>Document</title> </head> <body>
<p>C</p> </body> </html>

My css is

p{
height: 0.5%;
width: 0.5%;
background-color: darkblue; } body{
height: 100%;
width: 100%; }

My script is

for(let i=0;i<=255;i++)
for(let j=0;j<=255;j++)
for(let k=0;k<=255;k++){
const html = <p>C</p>;
document.querySelector(‘body’).insertAdjacentHTML(‘afterbegin’, html);
document.querySelector.style.backgroundColor=rgb(i,j,k);
}

Error:

Uncaught TypeError: Cannot read properties of null (reading
‘insertAdjacentHTML’)

JavaScript hover event on a vendor specific pseudo-elements

I have the following html input tag.

$("input[type='range']::-webkit-slider-thumb").on('hover', function () {
    //...
});
input[type="range"] {
    height: 0.5rem;
    box-shadow: 0 0 0.25rem gray;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    border: 0;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 100%;
    background: #7CB5EC;
    box-shadow: 0 0 0.375rem gray;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    -webkit-appearance: none;
    appearance: none;
    border: 0;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 100%;
    background: #7CB5EC;
    box-shadow: 0 0 0.375rem gray;
    cursor: pointer;
}
<input id="my-range" type="range" min="0" max="100">

I would like to get hover events via JavaScript whenever the user hovers only on the thumb.

I tried to do it like above but it doesn’t trigger the event. Any help is appreciated.

Thanks in advance.

How to use regex to find in between words and spaces?

I’m so frustrated and lost. I would really appreciate your help here.
I’m trying to fix an issue in Katex and Guppy keyboard. I’m trying to generate a regex to find between the word matrix and find the slash that has spaces before and after and replace it with a double slash. The problem I have here is it keeps selecting all slashes between matrix


 left(begin{matrix}    sqrt[ 5  ]{ 6  phantom{tiny{!}}}        dfrac{ 55  }{ 66  }       end{matrix}right)

I want to ignore sqrt because the slash doesn’t have a couple of spaces on both sides

to something like this

left(begin{matrix}    sqrt[ 5  ]{ 6  phantom{tiny{!}}}     \   dfrac{ 55  }{ 66  }       end{matrix}right)

Here is my current half working code

const regex = /matrix(.*?)\(.*?)matrix/g;
equation = equation.replace(regex, 'matrix$1\\$2matrix');

Image Overlay Around the Mouse Cursor in JavaScript

I want to implement the following in HTML/JavaScript but don’t really know where to start or even if there is already an existing function in one toolkit for this:

I have one image (e.g. a png) which is visible and a second image of the same size which is not visible. However, if I move the mouse pointer over the first image, the corresponding part from the second image shall be shown around the mouse cursor. for example, if I move the mouse at position 100,100 on the first image, the section from 50,50 to 150,150 of the second image should be overlaid on the first image at position 50,50 to 150,150. I hope this is understandable.
Can you give me a cue how could I grep the part of the second image and display it at the mouse position?

i can overlay the image over an image but dont know what to do next or how can i adjust my cursor so the second image shall be shown around the mouse cursor.

JS Array of object, filter by existing items in same array

I’m trying to filter this array, condition: if programParent property exists in another object id, that object must be ignored. This is what i coded for now, i need some help. Thanks in advance.

let programs = [
    { id: '23', name: 'a', programParent: '111' },
    { id: '24', name: 'a', programParent: '112' },
    { id: '25', name: 'a', programParent: '113' },
    { id: '26', name: 'a', programParent: '24' },
    { id: '27', name: 'a', programParent: '25' },
    { id: '28', name: 'a', programParent: '111' },
    { id: '29', name: 'a', programParent: '28' }
]


let options = programs.filter(x => programs.some(y => y !== x.programParent))
console.log(options)


expected = [
    { id: '23', name: 'a', programParent: '111' },
    { id: '24', name: 'a', programParent: '112' },
    { id: '25', name: 'a', programParent: '113' },
    { id: '28', name: 'a', programParent: '111' }
]

How can I sort an unordered list by the list items’ ids with vanilla JavaScript?

I have a list of meeting days, e.g. Monday morning, Monday afternoon, Monday evening, Tuesday morning and so on which are then displayed on a website’s front end as an unordered list.
Because the text is not alphabetical I want to sort the items using IDs I have created for each based on their item aliases with an added prefix. E.g. the “monday-morning” alias is now “aa-monday-morning” and that in turn is used to create id="aa-monday-morning"
Each of the list items has the class “sort” and sits in a ul with the id “meetings”.
[I do realise that if they’d been set up in the correct order in the first place, I wouldn’t have a problem, but it’s too late, now as there are 100+ items tagged with those list items].

I understand that I need to select all the items with the class name “sort” and then convert them to an array before sorting them by their ids, but I am really struggling.

I started with some code I copied from somewhere but it doesn’t seem to do anything and I’m not sure why.

let List = document.getElementById("meetings");
let listItems = List.getElementsByClassName('sort');
    sortList = Array.prototype.slice.call(listItems);
    if(listItems && listItems.length){
        listItems.sort(sortList);
        while (List.hasChildNodes()) {
            List.removeChild(List.lastChild);
        }
        while(listItems.length){
            var newList = listItems.shift();
            List.appendChild(newList);
        }
    }
function sortList(a, b){
    var aid = (a.id);
    var bid = (b.id);
    return aid - bid;
}
<ul id="meetings" class="sidebar">
<li id="aa-monday-morning" class="sort">Monday morning</li>
<li id="ba-tuesday-morning" class="sort">Tuesday morning</li>
<li id="bc-tuesday-evening" class="sort">Tuesday evening</li>
<li id="cc-wednesday-evening" class="sort">Wednesday evening</li>
<li id="dc-thursday-evening" class="sort">Thursday evening</li>
<li id="fb-friday-afternoon" class="sort">Friday afternoon</li>
<li id="ca-wednesday-morning" class="sort">Wednesday morning</li>
<li id="bb-tuesday-afternoon" class="sort">Tuesday afternoon</li>
<li id="cb-wednesday-afternoon" class="sort">Wednesday afternoon</li>
<li id="ac-monday-evening" class="sort">Monday evening</li>
<li id="ab-monday-afternoon" class="sort">Monday afternoon</li>
</ul>

The end result should be:

    <ul id="meetings" class="sidebar">
    <li id="aa-monday-morning" class="sort">Monday morning</li>
    <li id="ab-monday-afternoon" class="sort">Monday afternoon</li>
    <li id="ac-monday-evening" class="sort">Monday evening</li>
    <li id="ba-tuesday-morning" class="sort">Tuesday morning</li>
    <li id="bb-tuesday-afternoon" class="sort">Tuesday afternoon</li>
    <li id="bc-tuesday-evening" class="sort">Tuesday evening</li>
    <li id="ca-wednesday-morning" class="sort">Wednesday morning</li>
    <li id="cb-wednesday-afternoon" class="sort">Wednesday afternoon</li>
    <li id="cc-wednesday-evening" class="sort">Wednesday evening</li>
    <li id="dc-thursday-evening" class="sort">Thursday evening</li>
    <li id="fb-friday-afternoon" class="sort">Friday afternoon</li>
    </ul>

Thank you for reading.

Redirecting to next url with additional parameters using LoginView

I have a detail page /spaces/<int:pk>/ where an unauthenticated user can enter form data.

Upon submitting the form, this data is appended to the url like:

/spaces/<int:pk>/?product_id=1&start_date=2022-12-23&duration=1

The user is then prompted to login or register to continue. Upon clicking login, the detail page url is appended as a next parameter to the login url.

/login/?next=/spaces/1/?product_id=14&start_date=2022-12-23&duration=1

However, after logging in and redirecting back to the detail page, the url looks like:

/spaces/1/?product_id=14

This is because the url is split with & when parsed, so the start_date and duration are considered as separate parameters.

The only solution i can think of is to override LoginView.get_redirect_url and append each parameter from self.request.GET separately, but I’m not sure that is the best approach here.

My goal is to preserve the initial input data so that the user does not have to input it again after logging in and landing back on the space detail page. For conversion reasons, I do not want to force the user to login before entering the initial form data.

IntegrationError: Invalid value for stripe.confirmPayment(): Getting error in React Stripe

I have integrated a stripe @stripe/react-stripe-js: ^1.8.1 into my project. Stripe form working fine it popup a payment form but when I enter the payment information in the form and press the submit button, these errors return. it returns this errorsIntegrationError: Invalid value for stripe.confirmPayment():. I’ve tried but I was not able to resolve this issue. Could someone please help me how to resolve this issue?

import { CardElement, useElements, useStripe } from "@stripe/react-stripe-js";
import PropTypes from "prop-types";
import React, { useState } from "react";
import "./style.css";

const CARD_OPTIONS = {
  iconStyle: "solid",
  style: {
    base: {
      iconColor: "#dfe1e7",
      color: "#000",
      fontWeight: 500,
      fontFamily: "Roboto, Open Sans, Segoe UI, sans-serif",
      borderColor: "#000",
      fontSize: "16px",
      fontSmoothing: "antialiased",
      ":-webkit-autofill": { color: "#dfe1e7" },
      "::placeholder": { color: "#c6c6c6" },
    },
    invalid: {
      iconColor: "#000",
      color: "#000",
    },
  },
};

export function CheckOutForm(props) {
  const [success, setSuccess] = useState(false);
  const stripe = useStripe();
  const elements = useElements();
  console.log("@@ props", elements, props);

  const handleSubmit = async (event) => {
    event.preventDefault();

    const result = await stripe.confirmPayment({
      elements,
      confirmParams: {
        return_url: "https://example.com/order/123/complete",
      },
    });

    if (result.error) {
      console.log(result.error.message);
    } else {
      setSuccess(true);
    }
  };

  return (
    <>
      {!success ? (
        <form className="container" onSubmit={handleSubmit}>
          <fieldset className="FormGroup">
            <div className="FormRow">
              <CardElement options={CARD_OPTIONS} />
            </div>
          </fieldset>
          <button className="SubmitButton">Pay</button>
        </form>
      ) : (
        <div>
          <h2>
            You just bought a sweet spatula congrats this is the best decision
            of you are life
          </h2>
        </div>
      )}
    </>
  );
}

CheckOutForm.prototypes = {
  props: PropTypes.object,
  paymentInformation: PropTypes.string,
};

How to combine ggshield and Husky for pre-commit git hook?

I want to combine ggshield(by GitGuardian) and Husky into one pre-commit hook, but the result is that only one of them works.

I tried run pre-commit install in repo and after this run husky install in repo. In that case when i tryed to make commit with test errors Husky work but ggshield don’t work.

Also after that i tried run git config --unset-all core.hooksPath for unset git hooks in repo, and run husky install in repo, and after this run pre-commit install and received an error: Cowardly refusing to install hooks with 'core.hooksPath' set.

After this i run git config --unset-all core.hooksPath and then run pre-commit install then ggshield will work. But as soon as I run the husky install command, Husky starts working and ggshield stops working.

It turns out that only one of the git hooks can work at a time? Or is there some way to combine them?

Is there a way to reverse engineer a compiled JS file? [duplicate]

I have a file that was given to me that was minified and compiled using webpack modules. I don’t know anything about those so I’m not sure how to go about editing the JS file without understanding what all the variables do.

I am trying to make all the navigation links unclickable and found the script where it creates the links but if I were to remove it or edit it, it edits all links including non nav ones. I am sure there are other area that creates the nav links itself but I can’t find it as I am not understanding what is being done with all the alphabet variables they have going on in this 131k line file.

Below code creates the data link and aria-current for the a tag

function A(e) {
                var t = e.b, n = e.children, o = e.dark, a = e.isCurrentLesson, s = e.isTooltipEnabled, u = e.lessonId, c = e.onClick, l = e.onHideProgressTooltip, f = e.onNavigate, h = e.onShowProgressTooltip, v = e.restriction, y = e.showProgressDelay, b = e.style, _ = (0, 
                g.Tn)(), w = _.color, N = _.navigationStyle, A = N === T.Nu.IMAGE, P = N === T.Nu.ACCENT, L = N === T.Nu.ACCENT && (0, 
                x.LI)(w), I = N === T.Nu.TINT, M = (0, k.Zj)(), R = (0, d.useCallback)(function(e) {
                    c(e), a ? (e.preventDefault(), (0, m.lk)()) : f(u);
                }, [ u, a, c, f ]), D = (0, d.useState)(!1), j = (0, i.Z)(D, 2), Z = j[0], B = j[1], F = (0, 
                d.useCallback)(function() {
                    Z || (null != y ? setTimeout(h, y) : h());
                }, [ Z, y, h ]), q = (0, d.useCallback)(function(e) {
                    (0, E.$o)(e) && l();
                }, [ l ]), U = (0, d.useCallback)(function() {
                    B(!0);
                }, []), z = (0, d.useCallback)(function() {
                    B(!1);
                }, []), H = null != (null == v ? void 0 : v.type), V = t("link", {
                    "accent-full": P,
                    "accent-full-dark": L,
                    "accent-tint": I,
                    active: a,
                    dark: o,
                    image: A,
                    light: !o,
                    restricted: H
                }).toString();
                return H ? C.createElement(O, (0, r.Z)({}, e, {
                    className: V,
                    style: b
                })) : C.createElement(p.OL, {
                    "aria-current": "page",
                    className: V.toString(),
                    "data-link": "lesson-link-item course-links",
                    onBlur: s ? l : void 0,
                    onClick: R,
                    onFocus: s ? F : void 0,
                    onKeyDown: s ? q : void 0,
                    onMouseDown: s ? U : void 0,
                    onMouseUp: s ? z : void 0,
                    style: b,
                    tabIndex: M ? -1 : void 0,
                    to: (0, S.Jv)(u)
                }, n);
            }

Below code creates the a href

73727: function(e, t, n) {
            "use strict";
            n.d(t, {
                OL: function() {
                    return y;
                },
                rU: function() {
                    return m;
                }
            });
            var r = n(16550), i = n(94578), o = n(67294), a = n(68466), s = (n(45697), n(87462)), u = n(63366), c = n(2177);
            o.Component;
            o.Component;
            var l = function(e, t) {
                return "function" == typeof e ? e(t) : e;
            }, d = function(e, t) {
                return "string" == typeof e ? (0, a.ob)(e, null, null, t) : e;
            }, f = function(e) {
                return e;
            }, p = o.forwardRef;
            void 0 === p && (p = f);
            var h = p(function(e, t) {
                var n = e.innerRef, r = e.navigate, i = e.onClick, a = (0, u.Z)(e, [ "innerRef", "navigate", "onClick" ]), c = a.target, l = (0, 
                s.Z)({}, a, {
                    onClick: function(e) {
                        try {
                            i && i(e);
                        } catch (t) {
                            throw e.preventDefault(), t;
                        }
                        e.defaultPrevented || 0 !== e.button || c && "_self" !== c || function(e) {
                            return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
                        }(e) || (e.preventDefault(), r());
                    }
                });
                return l.ref = f !== p && t || n, o.createElement("a", l);
            });
            var m = p(function(e, t) {
                var n = e.component, i = void 0 === n ? h : n, a = e.replace, m = e.to, v = e.innerRef, g = (0, 
                u.Z)(e, [ "component", "replace", "to", "innerRef" ]);
                return o.createElement(r.s6.Consumer, null, function(e) {
                    e || (0, c.Z)(!1);
                    var n = e.history, r = d(l(m, e.location), e.location), u = r ? n.createHref(r) : "", h = (0, 
                    s.Z)({}, g, {
                        href: u,
                        navigate: function() {
                            var t = l(m, e.location);
                            (a ? n.replace : n.push)(t);
                        }
                    });
                    return f !== p ? h.ref = t || v : h.innerRef = v, o.createElement(i, h);
                });
            }), v = function(e) {
                return e;
            }, g = o.forwardRef;
            void 0 === g && (g = v);
            var y = g(function(e, t) {
                var n = e["aria-current"], i = void 0 === n ? "page" : n, a = e.activeClassName, f = void 0 === a ? "active" : a, p = e.activeStyle, h = e.className, y = e.exact, b = e.isActive, _ = e.location, w = e.sensitive, E = e.strict, k = e.style, x = e.to, S = e.innerRef, T = (0, 
                u.Z)(e, [ "aria-current", "activeClassName", "activeStyle", "className", "exact", "isActive", "location", "sensitive", "strict", "style", "to", "innerRef" ]);
                return o.createElement(r.s6.Consumer, null, function(e) {
                    e || (0, c.Z)(!1);
                    var n = _ || e.location, a = d(l(x, n), n), u = a.pathname, C = u && u.replace(/([.+*?=^!:${}()[]|/\])/g, "\$1"), N = C ? (0, 
                    r.LX)(n.pathname, {
                        path: C,
                        exact: y,
                        sensitive: w,
                        strict: E
                    }) : null, O = !!(b ? b(N, n) : N), A = O ? function() {
                        for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++) t[n] = arguments[n];
                        return t.filter(function(e) {
                            return e;
                        }).join(" ");
                    }(h, f) : h, P = O ? (0, s.Z)({}, k, {}, p) : k, L = (0, s.Z)({
                        "aria-current": O && i || null,
                        className: A,
                        style: P,
                        to: a
                    }, T);
                    return v !== g ? L.ref = t || S : L.innerRef = S, o.createElement(m, L);
                });
            });
        },

I tried to beautify and unminify the minified file so it’s easier to read.

I was able to find how the navigation is created up to the a tag but am unable to edit the area where it creates the actual link which I believe to be the code above.

Is there a way to decompile the compiled JS file? I don’t know enough about JS or using webpack to figure out how to reverse engineer this.

How to print top 5 frequently occurring words from a substring

I have some project, with finding the bad words from user. How can i find an a top 5 frequently encountered words from the array of “bad words” in user input string?

I try to do it, but this code doesn’t work how i want

const containsAny = (str, substrings) => {
    for (var i = 0; i != substrings.length; i++) {
       var substring = substrings[i];
       if (str.indexOf(substring) != - 1) {
         return substring;
       }
    }
    return null; 
 }

 var result = containsAny(textWords, listOfBadWords);
 console.log("String was found in substring " + result);

i would like to make it like: word – number of times of use

Node JS – Schedule MySQL back-up and send it by e-mail using Google Cloud

I am trying to build a NodeJS script to save a mySQL database, send it to me by e-mail as an attachement (the file is about 1MB), and I want to schedule the whole thing to run once a week. So far my script runs perfectly when run locally. I’ve set up the scheduling to run once every minute as a testing purpose.

I am struggling when trying to make it run on google cloud. The deployment went without issue, but then I only see in the logs Saving Database... so the scheduling part works fine, but I don’t see the Dump File OK so I am assuming there is something wrong with mysqldump, but no error message. I didn’t do anything specific with GCS, should I have ?

Thanks

require("dotenv").config();
const mysqldump = require("mysqldump");
const fs = require("fs");
var nodemailer = require("nodemailer");
var cron = require("node-cron");

async function saveDatabase() {
  console.error("Saving Database...");

  // dump the result straight to a file
  await mysqldump({
    connection: {
      host: process.env.MYSQL_HOST,
      user: process.env.MYSQL_USER,
      password: process.env.MYSQL_PWD,
      database: process.env.MYSQL_DB,
    },
    dumpToFile: "./dump.sql",
  });

  console.error("Dump File OK");

  // mail server config and authentication
  var transporter = nodemailer.createTransport({
    host: "smtp.hostinger.com",
    port: 465,
    secure: true,
    auth: {
      user: process.env.MAIL_ADDRESS,
      pass: process.env.MAIL_PWD,
    },
  });

  console.error("Mail Server OK");

  // mail options
  var mailOptions = {
    from: process.env.MAIL_ADDRESS,
    to: "************@gmail.com",
    subject: "Sauvegarde Base de Données",
    text: "Base de donnée sauvegardée.",
    attachments: [
      {
        path: "./dump.sql",
      },
    ],
  };

  // send the e-mail
  transporter.sendMail(mailOptions, function (error, info) {
    if (error) {
      console.error(error);
    } else {
      console.error("E-mail sent");
    }
  });
}

cron.schedule("* * * * *", () => saveDatabase());

What NScriptType: ServerScript to use in NetSuite field value update script

I am looking to update a numeric field for multiple records with arithmetic, not just overriding the current value with a new one. To do this, I plan on uploading a file with the identifier of the item and the new value being added. Parse the file and use custom searches to find the corresponding records, then loading, updating and saving the proper record. However, how to run the script is where I get confused.

I have created previous scripts beforeLoad scripts which run on entering the edit view of an item, but I have not used any server side scripts yet (I read that when accessing files from the filing cabinet, you must use a server side script).

Any information about server script types and when to use them would be appreciated. Thank you.

Error spawn unknown error in NodeJS while hitting an api

I am trying to hit an api which will send an email. The api works fine on my work mates system. But on my system it gives the following error-
enter image description here

I have tried to find the solution but none of them worked. I am actually using windows 11 OS.
What can I do to solve this problem. The database used at backend is MongoDB and framework is ExpressJS.