What if I clean cache on safari ? Passkey

What should be if I create passkey on apple device on safari with webauthn navigator.credentials.create(). Then I see a one passkey on device. If I clear cache in safari and try again. It force me to create another passkey again. And after that i Have two passkeys on device. Should be like this ?why?

I tried to log with passkey after I clear the safari cache on apple device

How to identify third party cookie in javascript [duplicate]

I am writing a code to identify which third party cookies might get affected after chrome third party cookie phaseout.

Is there a way to get the third party cookies in javascript?
What and all attributes should I consider to say that cookie will be affected by chrome third party cookie phaseout??

I might probably have to consider sameSite attribute and what else?

Quill moves custom attribute

I’m using Quill (v.2.0.0) with quill-better-table (v.1.2.10) in my Angular 13 project.

I’m trying to add a custom attribute to the table tag, something like

<table class="quill-better-table" custom-attribute="test" style="width: 100px;">

Everything seems ok and the correct string corresponding to the inner html of quill is saved in my database, and also includes my custom attribute in the table tag. However, when I reload the content (reading, therefore), Quill cuts or moves my attribute to the col tag, whatever the Scope I set:

<table class="quill-better-table" style="width: 100px;">
        <colgroup>
            <col width="100" custom-attribute="test">
        </colgroup>
...

There is my Quill configuration:

const Parchment = Quill.import('parchment');
const customAttribute = new Parchment.Attributor('custom-attribute', 'custom-attribute', {
    scope: Parchment.Scope.BLOCK,
    whitelist: ['test']
});
Quill.register(customAttribute);
Quill.register({
    'modules/better-table': QuillBetterTable
}, true);
this.quill = new Quill('#editor-container', {
    readOnly: this.editDisabled,
    modules: {
      toolbar: '#toolbar',
      table: false,
      'better-table': {},
      keyboard: {
        bindings: QuillBetterTable.keyboardBindings
      }
    },
    theme: 'snow'
});

Here I add the table and attribute to it:

let tableModule: any = this.quill.getModule('better-table');
tableModule.insertTable(2, 2);
let table = tableModule.getTable();
table[0].domNode.setAttribute('custom-attribute', 'test');

I expect Quill to read the attribute correctly, without cutting or moving it

Display buttons from checkbox

I have a databse with different gym exercises, im trying to make a leaderboard for each one, and i want something like a checkbox form that takes all the exercises from my databse and adds them as check buttons, and as you check them, i want them to apear the the navbar as options to click.

I´m doing it manually but i wat it to be dynamic and i have no idea how to do it
I´m using bootstrap5 and this is what i have now, I´d be thankful for any tips or sugestions

 <div class="collapse navbar-collapse justify-content-center" id="navbarCategories">
                                <ul class="navbar-nav" id="navbar">
                                    <li class="nav-item"><a href="#squats" class="nav-link" style="color: #c5c6c8;">Squats</a></li>
                                    <li class="nav-item"><a href="#deadlifts" class="nav-link" style="color: #c5c6c8;">Deadlifts</a></li>
                                    <li class="nav-item"><a href="#benchpress" class="nav-link" style="color: #c5c6c8;">Bench Press</a></li>
                                    <li class="nav-item"><a href="#overheadpress" class="nav-link" style="color: #c5c6c8;">Overhead Press</a></li>
                                    <div class="dropdown">
                                        <button class="nav-link btn btn-primry dropdown-toggle"data-bs-toggle="dropdown" style="color: #c5c6c8;">Add favorite</button></li>
                                        <ul class="dropdown-menu">
                                        <form id="checkform">
                                            <input type="checkbox" id="benchpress" name="benchpress" value="Bench Press">
                                            <label for="benchpress">Bench Press</label><br>
                                            <input type="checkbox" id="deadlift" name="deadlift" value="Deadlifts">
                                            <label for="deadlift">Deadlifts</label><br>
                                            <input type="checkbox" id="overheadpress" name="overheadpress" value="Overhead Press">
                                            <label for="overheadpress">Overhead Press</label><br><br>
                                            <input type="submit" value="Submit">
                                        </form>
                                        </ul>       
                                    </div>
                                </ul>
                            </div>

Applying global styles in Next.js 14

I am having issues implementing the style jsx global property with the new the Next.js. In the previous ones you needed to add it into the _app.js file but since this doesn’t exist anymore, I figured it is meant to be added in to the layout.tsx file that represents each page but when I do it, I get the following error

'client-only' cannot be imported from a Server Component module. It should only be used from a Client Component.

This is my code


export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en">
      <style jsx global>
        {`
                    :root {
                        --title: ${header.style.fontFamily};
                        --content: ${paragraph.style.fontFamily};
                        --primary: ${colors.primary};
                        --primary-dark: ${colors.primaryDark};
                        --secondary: ${colors.secondary};
                        --secondary-dark: ${colors.secondaryDark};
            --background: ${colors.background};
            --paragraph: ${colors.paragraph};
                `}
      </style>
      <body>
        <StyledJsxRegistry>{children}</StyledJsxRegistry>
      </body>
    </html>
  );
}

Uploading deeply nested folders

I am using JavaScript with react and I am trying to upload files and folders.

  const [files, setFiles] = useState([]);

  const handleDropFile = (event) => {
    event.preventDefault();
    const items = event.dataTransfer.items;
    const fileList = [];
    for (let i = 0; i < items.length; i++) {
      const entry = items[i].webkitGetAsEntry();
      if (entry.isFile) {
        fileList.push(new Promise((resolve) => entry.file(resolve)));
      } else if (entry.isDirectory) {
        fileList.push(traverseDirectory(entry, entry.name + "/"));
      }
    }
    Promise.all(fileList).then((files) => {
      console.log(files, files.flat())
      setFiles(files.flat());
    });
  };
  const traverseDirectory = (directory, currentPath) => {
    return new Promise((resolve) => {
      const reader = directory.createReader();
      const fileList = [];
      const readEntries = () => {
        reader.readEntries((entries) => {
          entries.forEach((entry) => {
            if (entry.isFile) {
              fileList.push(
                new Promise((resolve) =>
                  entry.file((file) => {
                    // Modify the file name here before resolving
                    const modifiedFile = new File(
                      [file],
                      currentPath + file.name,
                      { type: file.type }
                    );
                    resolve(modifiedFile);
                  })
                )
              );
            } else if (entry.isDirectory) {
              fileList.push(
                traverseDirectory(entry, currentPath + "/" + entry.name)
              );
            }
          });
          if (entries.length > 0) {
            readEntries();
          } else {
            resolve(Promise.all(fileList));
          }
        });
      };
<div onDrop={handleDropFile} >

However for folders that hold other folders I am I have encountered this error:
The files array will have arrays of files when it should only have file objects even tough I have called flat on it.

This is what console.log(files, files.flat()) prints:

[File, Array(2), Array(2), File]
[File, File, File, Array(1), File, File]

I suspect the problem comes from deeply nested promises but I am a beginner and I cannot solve the issue.

How to check for value 0 in @if template flow syntax

I have a problem with @if in the Angular template flow syntax.

A value is available in an RxJs Observable. So the async pipe helps and the value is assigned to a variable.

@if (currentPageNumber$ | async; as currentPageNumber) {
// currentPageNumber is number

For value 0 the if statement is not valid. So I exclude only null values… but now the value of currentPageNumber is boolean.

@if ((currentPageNumber$ | async) !== null; as currentPageNumber) {
// currentPageNumber is boolean

How can I check against null but keep my variable with the value of the stream?

How to fill datepicker input field in chrome headless mode?

I am working on a project which is built on top of React MUI component and the issue I am facing is the datepicker field. This input field is an input with type=’tel’, MUI by default sets this for Datepicker fields. Our team of developers tried to change the input to input type=’text’ but MUI somehow overwrites it. I am writing UI automation tests in Selenium Python and I am facing an issue with filling this input with send_keys(method).

  • I have tried every workaround in the web, but I couldn’t understand why its not working.
  • I have tried to click and then insert, use Datepicker calendar to click by date, month, year and its not possible to perform click operation because in headless mode datepicker icon is not shown.
  • I have tried using Javascript to set the value of the input and it didnt work as well.
  • I have tried adding all necessary chrome arguments and a custom user agent:
    chrome_options.add_argument('--enable-javascript')
    chrome_options.add_argument(f"--window-position={2000},{0}")
    chrome_options.add_argument('--enable-javascript')
    chrome_options.add_argument("--nogpu")
    chrome_options.add_argument("--incognito")
    chrome_options.add_argument("--no-sandbox")
    chrome_options.add_argument('--disable-gpu')
    chrome_options.add_argument('--window-size=1920,1080')
    chrome_options.add_argument('--start-maximized')
    chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
    chrome_options.add_experimental_option("useAutomationExtension", False)
    chrome_options.add_argument('--disable-blink-features=AutomationControlled')
    chrome_options.add_argument('--headless')
    

I ran out of options, as I don’t know what to do next

i found this source code for caeser cipher wheel online. it is written in js and css. i want it in flutter [closed]

i found this source code for caeser cipher wheel online. it is written in js and css. i want it in flutter. who can help?!

https://github.com/rheh/HTML5-canvas-projects/tree/master/caesar_cipher

change(javascript css html) to flutter dart.

Please help!
I succeeded in running it as is(javascript) however i need it to write it in flutter to include it in my mobile app development project.

Javascript – how to convert two integers into a float? [closed]

I have a web app where I need to convert two integers into a float number. The user is requested two integer tags (WordOne and WordTwo). I have created a javascript function and what I have tried so far is:

function WordsToReal (WordOne, WordTwo) {

var w1=0, w2=0, hex1, hex2, ascii1, ascii2, ascii12;
let str;
w1 = $getTag(WordOne); //here I get the value for tag WordOne
w2 = $getTag(WordTwo); //here I get the value for tag WordTwo

//conversion words from int to hex:
hex1=w1.toString(16);
hex2=w2.toString(16);

//conversion from hex to ascii
ascii1=Buffer.from('' + hex1, 'hex');
ascii2=Buffer.from('' + hex2, 'hex');

//concatenate ascii values
str = '' + ascii1 + ascii2;

//conversion from string to int and then to float
return Number(str)/10;
console.log("Number(str): " + Number(str)/10);
}

If, for example, w1=12337 (in hex:3031) and w2=14641 (in hex: 3931). 30 in ascii is 0, 31 in ascii is 1, 39 in ascii is 9 and 31 in ascii is 1. The result I get is 19.1 which is correct.

My problem is that for greater w1 and w2 values, I get other result instead of what should I get.

For example, w1=17358 (in hex: 43CE) and w2=63971 (in hex: F9E3). 43 in ascii is C, the other hex values (CE, F( and E3) converted in ascii are some symbols. The float number for these two integers should be 239.4 or something very similar.

My question is if there’s another method of converting two integers into float or my method could be changed to get what I want?

Need to change command in PHP correctly [closed]

I am trying to remove information about days and time for UPS Shipping, which I have for our online shop.
this is command which need to be changed to get read from information about days and time.

$shipcostarray[] = array( "method" => "ups_ap", "name" => translate( "UPS Access Point" ) . $ups_ap_info, "cost" => $ups_ap_price, "days" => $rate['GUARANTEED_DAYS'], "time" => $rate['GUARANTEED_TIME'] );

When I am removing “days” or “days” and => or “days” => [‘GUARANTEED_DAYS’] “time” => [‘GUARANTEED_TIME’]

the whole site disappears.
I know I am removing the command wrong, but how it should look like?

This is how it look like and red lines shows what I want to remove.

Image

I try to correct command but I did it wrong.

Error 500 when i try to add informations in DB table “users” with registration form

I have a problem (HTTP error 500) to add informations users into my db.
i tried to add information user in my sql DB
I don’t know why my code doesn’t work.

This is my code of the file traitement.php :

<?php
// Connexion à la base de données (assurez-vous d'avoir les informations de connexion correctes)
$servername = "servername";
$username = "username";
$password = "password";
$dbname = "dbname";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
    die("La connexion à la base de données a échoué : " . $conn->connect_error);
}

// Récupération des données du formulaire
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$email = $_POST['email'];
$mot_de_passe = $_POST['mot_de_passe']; // Hashage du mot de passe

// Insertion des données dans la base de données
$sql = "INSERT INTO users (nom, prenom, email, mot_de_passe) VALUES ('$nom', '$prenom', '$email', '$mot_de_passe')";

if ($conn->query($sql) === TRUE) {
    echo "Inscription réussie !";
} else {
    echo "Erreur lors de l'inscription : " . $conn->error;
}

$conn->close();
?>

Unable to access user id through guard after login in laravel

I have this route define in web.php

web.php

Route::group(['prefix' => 'user'], function () {
        Route::get('login', [FrontendController::class ,'showLoginForm'])->name('user.login-show');
        Route::post('login', 'AppHttpControllersLoginController@login')->name('login.post');
}

this is my login controller

    <?php
    
    namespace AppHttpControllers;
    use Auth;
    use AppUser;
    use AppHttpControllersController;
    use IlluminateHttpRequest;
    use IlluminateFoundationAuthAuthenticatesUsers;
    use IlluminateSupportFacadesHash;
    use DarryldecodeCartFacadesCart;
    
    
    class LoginController extends Controller
    {
        use AuthenticatesUsers;
        //
        protected $redirectTo = '/user/dashboard';
    
        public function __construct()
        {
            $this->middleware('guest:web')->except('logout');
        }
    
        public function showLoginForm()
        { 
            return view('pages.login');
        }
    
        public function login(Request $request)
        {
            $this->validate($request, [
                'email'   => 'required|email',
                'password' => 'required|min:6',
                'remember_me'=>'nullable'
            ]);
            $request->merge(['user_type'=>'0']);
            if (Auth::guard('web')->attempt([
                'email' => $request->email,
                'password' => $request->password,'user_type' => $request->user_type
            ], $request->input('remember_me'))) {
                $userID = Auth::guard('web')->user()->id;
                return redirect()->intended(route('web.dashboard'));
            }
            else{
                return back()->withErrors(['message'=>'Username or Password is Invalid'])->withInput($request->all());
            }
        }

    public function logout(Request $request)
    {
        Auth::guard('web')->logout();
        $request->session()->invalidate();
         
    }

    public function dashboard()
    {

    }
}

config/auth.php

 'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
        'api' => [
            'driver' => 'token',
            'provider' => 'users',
            'hash' => false,
        ],
        'admin' => [
            'driver' => 'session',
            'provider' => 'admin',
        ],

RedirectedIfAuthenticated Middleware:

public function handle(Request $request, Closure $next, ...$guards)
{
    $guards = empty($guards) ? [null] : $guards;

    foreach ($guards as $guard) {
        if (Auth::guard($guard)->check()) {
            return redirect(RouteServiceProvider::HOME);
        }
    }

    return $next($request);
}

if i try to log in i’m then in login controller able to get user id through this code able to get user id using this code Auth::guard('web')->user()->id; but after this login function code is executed then not able to get user id in other methods or controller, it returns Attempt to read property "id" on null because user is null & i’m able to access login page even if i’m logged in. I have two guards one for admin other one for user

Any solution to fix this login issue, Thanks

Uncaught PHPMailerPHPMailerException

I am using Xampp Server to do a send a message to an email.
I am using the PHP Mailer to do this

I ran into an error and i am not sure how to fix it , I would love some assistance if you have any

<html> 
<head>
  <title> Sending Email Using PHP </title>    
</head>
<body>
    
    <form method="post" action="">
        
        Please enter the email address <input type="email" name="to" placeholder="********@gmail.com">
        <br>
        
        Kindly enter the subject <input type="text" name="subject" placeholder = "Requesting all information">
        <br>
        
        Kindly enter the message <textarea name="message"> </textarea>
        <br><br>
        
        <input type="submit" value="Send">
    </form>
   
    <?php
    use PHPMailerPHPMailerException;
    use PHPMailerPHPMailerPHPMailer;
    use PHPMailerPHPMailerSMTP;
    
    require 'PHPMailer/src/Exception.php';
    require 'PHPMailer/src/PHPMailer.php';
    require 'PHPMailer/src/SMTP.php';
    require 'information.php'; //credentials for emails
    
    if($_SERVER["REQUEST_METHOD"] == "POST"){
    $to = $_POST["to"];
    $subject = $_POST["subject"];
    $message = $_POST["message"];
   
    
    $mail = new PHPMailer (true);
    $mail -> Subject = $subject;
    $mail -> Body = $message;
    $mail -> addAddress ($to);
    $mail -> AltBody = $message;
    $mail -> setFrom (SEND_FROM, SEND_FROM_NAME);
    $mail -> addReplyTo (REPLY_TO, REPLY_TO_NAME);
    $mail -> Host = MAILHOST;
    $mail -> Username = USERNAME;
    $mail -> Password = PASSWORD;
    $mail -> Port = 587;
    $mail -> isSMTP ();
    $mail -> SMTPAuth = true;
    $mail -> SMTPSecure = PHPMailer:: ENCRYPTION_STARTTLS;
    $mail -> IsHTML (true);
    $mail -> send ();
        
    if ($mail == true){
        
        echo "Message sent successfully";
    }
    
    else {
        
        echo "Message could not be sent";
    }
    }
    ?>
    </body>
</html>

This is the credentials for the emails called information.php

<?php

define ('MAILHOST', "smtp.gmail.com");
define ('USERNAME', "*******@gmail.com");
define ('SEND_FROM', "*******[email protected]");
define ('SEND_FROM_NAME', "**** *****");
define ('REPLY_TO', "student email");
define ('REPLY_TO_NAME', "*******");
define ('PASSWORD', "**%^&%*");

?>

The error was

Warning: Undefined array key “to” in (file name) on line 40

Fatal error: Uncaught PHPMailerPHPMailerException: Invalid address:
(to): in 1100 Stack trace: #0 :
PHPMailerPHPMailerPHPMailer->addOrEnqueueAnAddress(‘to’, NULL, ”)
#1(49): PHPMailerPHPMailerPHPMailer->addAddress(NULL) #2 {main} thrown in on line 1100

trying to access array offset on value $row=$reult->fetch_assoc(); [duplicate]

trying to access array offset on value in $row = $result->fetch_assoc();

$row = $result->fetch_assoc();  
echo "<tr><td>Name: </td><td>".$row['CustomerName']."</td></tr>";    
echo "<tr><td>No.Number: </td><td>".$row['CustomerIC']."</td></tr>";    
echo "<tr><td>E-mail: </td><td>".$row['CustomerEmail']."</td></tr>";    
echo "<tr><td>Mobile Number: </td><td>".$row['CustomerPhone']