Why does this pattern cause problems for Regexr? [closed]

I’ve been working on a YouTube ID parsing regex (because none of the available ones are complete) on RegExr.com and I found a pattern that works great. However, when the page first loads, it ALWAYS throws an error.

Exec Error: The expression took longer than 250ms to execute.

The pattern doesn’t take longer than 250ms though. If I make ANY edit to the pattern (e.g. add a space and then remove it), it runs quickly, and perfectly does what I need it to.

A couple of other weird things occur in the execution reporting though.

  1. The UI says “41 matches (0.0ms)”. O.0ms?!
  2. When I hover that same element, there is a message: “No matches found in 1609 characters”.

So, the pattern is effective, but something about it is really throwing the Regexr execution reporting. Any ideas? Is there something wrong with the pattern itself?

Here is the pattern:

/(?:https?://|//)?(?:www.|m.|music.)?(?:youtube.com|youtu.be){1}(/live/|/v/|/embed/|/watch?v=|/w+?v=|/)([w-]+)??.*/gi

Please see the linked page for the demo to see the functionality I described.

reCaptcha Enterprises “Permission denied for: recaptchaenterprise.assessments.create”

I’m setting up a reCaptcha for a client with an Enterprise Google Cloud account.
I used an API Key, which is the easiest based on my client files configuration.
Everything works well until I call the https://recaptchaenterprise.googleapis.com/v1/projects/ url.

I get this error as my curl response :

{
  "error": {
    "code": 403,
    "message": "Permission denied for: recaptchaenterprise.assessments.create. Please ensure you have sufficient permissions: https://cloud.google.com/iam/docs/granting-changing-revoking-access",
    "status": "PERMISSION_DENIED"
  }
}

Here’s my code :


$verify_url = "https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments?key=API_KEY";
$data = [
    "event" => [
        'expectedAction' => 'CONTACT_FORM',
        "token" => $recaptcha_token,
        'siteKey' => $google_site_key
    ]
];

$ch = curl_init($verify_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

$response = curl_exec($ch);
curl_close($ch);

$response_data = json_decode($response);

I tried setting up a Service Account with “reCAPTCHA Enterprise Agent”
access rights but nothing works (and I don’t understand how the API Key is supposed to be linked to the Service Account).
I removed all restrictions from the API Key to test but it does not work.

Fedex API – SATURDAY_DELIVERY

Im having some trouble getting my SATURDAY_DELIVERY tag to work.

I can get the Saturday delivery from the rates and quotes api, so I know the addresses I’m using allow Saturday delivery.

Any help will be greatly appreciated.

I keep getting the following error:

[{"code":"ORGORDEST.SPECIALSERVICES.NOTALLOWED","message":"This special service type is not allowed for the origin/destination pair. Please update and try again","parameterList":[{"key":"SPECIAL_SERVICE_TYPE","value":"SATURDAY_DELIVERY"}]}

I’m wondering if someone else has come across this – Am I doing something wrong here? Iv tried mutiple different payloads with different addresses, iv tried sandbox API, Prod API, tried real addresses, different pickupType, different packagingTypes etc..

Here’s my sample payload

$payload = [
    "accountNumber" => [
        "value" => "*******"
    ],
    "labelResponseOptions" => "URL_ONLY",
    "requestedShipment" => [
        "shipDateStamp" => "2025-06-13", // Friday
        "pickupType" => "DROPOFF_AT_FEDEX_LOCATION",
        "serviceType" => "PRIORITY_OVERNIGHT",
        "packagingType" => "FEDEX_BOX", // Required for SATURDAY_DELIVERY in many areas

        "shipper" => [
            "contact" => [
                "personName" => "John Doe",
                "phoneNumber" => "5555555555",
                "companyName" => "Test Sender Inc"
            ],
            "address" => [
                "streetLines" => ["123 Main Street"],
                "city" => "Memphis",
                "stateOrProvinceCode" => "TN",
                "postalCode" => "38116",
                "countryCode" => "US"
            ]
        ],

        "recipients" => [[
            "contact" => [
                "personName" => "Jane Smith",
                "phoneNumber" => "5555551234",
                "companyName" => "Test Receiver LLC"
            ],
            "address" => [
                "streetLines" => ["100 California Street"],
                "city" => "San Francisco",
                "stateOrProvinceCode" => "CA",
                "postalCode" => "94111",
                "countryCode" => "US",
                "residential" => true
            ]
        ]],

        "shippingChargesPayment" => [
            "paymentType" => "SENDER",
            "payor" => [
                "responsibleParty" => [
                    "accountNumber" => [
                        "value" => "*******"
                    ]
                ]
            ]
        ],

        "requestedPackageLineItems" => [[
            "weight" => [
                "units" => "LB",
                "value" => 2
            ]
        ]],

        "shipmentSpecialServices" => [
            "specialServiceTypes" => ["SATURDAY_DELIVERY"]
        ],

        "labelSpecification" => [
            "labelStockType" => "PAPER_4X6",
            "imageType" => "PDF"
        ]
    ]
];

Need to move Variation Description from original location to woocommerce_single_product_summary location in woodmart theme

I want move Variable Product Description from original location to woocommerce_single_product_summary location but I never success still using many methods i got code from the web

add_action( 'woocommerce_single_product_summary', 'variable_product_description_on_selection' );
function variable_product_description_on_selection() {

    global $product;
    
    if ( ! $product->is_type( 'variable' ) ) return;
    
    echo '<div class="variation-description"></div>';
    
    wc_enqueue_js( "
      $(document).on('found_variation', 'form.cart', function( event, variation ) { 
         $('.variation-description').html(variation.variation_description); 
      });

" );

}

but its making copy.
please help me to move variation description woocommerce_single_product_summary

need to move location variation description.

Sending Laravel form with dynamically added fields with AJAX, Undefined parameters

I have a form in Laravel where I use Ajax to dynamically create options in the selects, based on previous filled information. I am very new to Ajax, so maybe I understand the concept wrong.

Below the first select, just based on a “regular” query.

<select id="selectCompany" name="companyId">
  @foreach($companies as $company)
     <option value="{{ $company->id }}">{{ $company->name }}</option>
  @endforeach
</select>

Based on the first selected value, I use Ajax to select options for the next selection field.

$(document).ready(function () {
  $('#step1').on('click', function (fetchLocations) {
    $.ajax({
      type: 'GET',
      url: '/get/info/',
      dataType: 'json',
      data: {
        companyId: $('#selectCompany option:selected').val()
      },
      success: function (response) {
        $('#selectLocations').empty();
        $.each(response.locations, function (key, value) {
          $('#selectLocations').append('<option value=' + key.id + '>' + value.title + '</option>');
        });
      },
      error: function (ts) {
        alert(ts.responseText);
      }
    });
  });

I add the options to the following select

<select id="selectLocations" name="locationId">
</select>

Now I want to submit the form via normal Laravel route, unfortunately the value send from the second select is “Undefined”. How can I fix this?

Laravel Request parameters:

Laravel Request parameters

How to prevent duplicate news articles with similar meanings in Laravel web scraping project? [closed]

I’m building a Laravel application that aggregates news from multiple websites using DomCrawler. The system is scraping duplicate content where articles have the same meaning but different wording.

What I’ve tried:

  • Basic cosine similarity with TF-IDF vectors
  • Attempted using sentence-transformers (installation failed)
  • Exact string matching with hashes

Current setup:

  • Laravel 10
  • PHP 8.2
  • guzzlehttp/guzzle for HTTP requests
  • symfony/dom-crawler for parsing

Error with sentence-transformers:

How can I implement effective semantic deduplication in a PHP/Laravel environment? Are there native PHP solutions or reliable API services for this purpose?

Eloquent model producing infinite loops with any queries

I have a Model with a protected $withCount property, and it always gets into an infinite loop. If remove that property, the model will return data. The project I am working in has another Model using $withCount and it returns the child object count fine. I’ve combed through the working model and compared it with mine, and as far as I can tell I have set everything up correctly. Any idea (or hints to chase down) why this would always get an infinite loop?

<?php

namespace AppModels;


use DateTime;
use IlluminateDatabaseEloquentModel;
use IlluminateDatabaseEloquentRelationsHasMany;
use IlluminateDatabaseEloquentRelationsBelongsTo;
use IlluminateDatabaseEloquentSoftDeletes;

/**
 * @property Team team
 * @property string name
 * @property string notes
 * @property HasMany<ShiftAssignment> shiftAssignments
 * @property DateTime created_at
 * @property DateTime modified_at
 * @property DateTime deleted_at
 *
 * @method static where(string $string, mixed $id)
 */
class Calendar extends Model
{
    use SoftDeletes;

    /**
     * @return BelongsTo<Team> Get the team for the Calendar
     */
    public function team(): BelongsTo {
        return $this->belongsTo(Team::class);
    }

    /**
     * @return HasMany Get all the relationships for the calendar.
     */
    public function shiftAssignments(): HasMany {
        return $this->hasMany(ShiftAssignment::class);
    }

    /**
     * If we want any relationship counts to be return automatically, add them here.
     */
    protected $withCount = [
        'shift_assignments'
    ];

    /**
     * Get the attributes that should be cast.
     *
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'created_at' => 'datetime:Y-m-dTh:i:sZ',
            'modified_at' => 'datetime:Y-m-dTh:i:sZ',
            'deleted_at' => 'datetime:Y-m-dTh:i:sZ',
        ];
    }
}

These both produce an infinite loops:

Calendar::with('team_id', $team->id);
Calendar::all();

Laravel 8 different responses when filtering models and collections

I’m sure there is an obvious explanation here, but I’m getting weirdly different responses when filtering collections.

    $c=Media::all()->collect();
    
    // first set of commands
    $filtered=Media::all()->filter(function($item,$k){ 
      return in_array("mp4",$item->extensions->toArray();
    })->count(); // 97
    $cFiltered=$c->filter(function($item,$k){
      return in_array("mp4",$item->extensions->toArray();
    })->count(); // 96    
    Media::all()->count()==$c->count(); // true
    $ct=Media::all()->count(); // 173

    // Now - additional weirdness
    // same commands but changed filtered variable name
    
    $newFiltered=Media::all()->filter(function($item,$k){ 
      return in_array("mp4",$item->extensions->toArray();
    })->count(); // 100
    $newCFiltered=$c->filter(function($item,$k){
      return in_array("mp4",$item->extensions->toArray();
    })->count(); // 83
    Media::all()->count()==$c->count(); // true
    Media::all()->count()==$ct; // true

These were run back to back with essentially no time passing. The only difference between the first set of results and the second set is that I changed the variable names.

I’m not a Laravel developer in general and I can’t make sense of this.
Can anyone explain what’s happening here?

note: This is Laravel 8 with php-7.4. I’m executing the code in the artisan tinker shell.

Not displaying the webpage instead it display the script in the folder

I am working on Xampp localhost. Ihave my script installed but when i try to access the webpage for example http://localhost/myscripfolder inside htdocs, it display all the folders and files inside the project folder

Index of /mywebsite

I am expecting to be able to access the website through the url localhost/myscriptfolder.

but it doenot work.

Instead, It diplay all the folders and files inside the main project folder

Nginx throws 404 when trying to access the service

When i am trying to connect one of my services i get
404 Not Found nginx.
I’ve configured dockerfile and docker-compose well, but have some issues on nginx configs side

the project structure is

./backend/subscription_service
./backend/subscription_service/Dockerfile
./nginx/nginx.conf
./docker-compose.yaml

Nginx log:

2025/06/08 09:24:32 [error] 22#22: *2 open() "/etc/nginx/html/index.php" failed (2: No such file or directory), client: 172.18.0.1, server: localhost, request: "POST /subscription/subscriptions/ HTTP/1.1", host: "localhost"
172.18.0.1 - - [08/Jun/2025:09:24:32 +0000] "POST /subscription/subscriptions/ HTTP/1.1" 404 153 "-" "PostmanRuntime/7.44.0" "-"

Nginx

server {
    listen 80;
    server_name localhost;

location /subscription {
        alias /var/www/html/public;
        index index.php index.html index.htm;

        try_files $uri $uri/ /subscription/index.php?$query_string;

        location ~ .php$ {
            include fastcgi_params;
            fastcgi_pass subscription_service:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $request_filename;
        }

        location ~* .(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
            expires max;
            log_not_found off;
        }
    }
}

Dockerfile

...
WORKDIR /var/www/html
COPY . /var/www/html

...

EXPOSE 9000

docker-compose.yaml

  subscription_service:
    build:
      context: ./backend/subscription_service
      dockerfile: Dockerfile
    container_name: subscription_service
    depends_on:
      - subscription_db
    volumes:
      - ./backend/subscription_service:/var/www/html
      - ./backend/subscription_service/bootstrap/cache:/var/www/html/bootstrap/cache
      - ./backend/subscription_service/storage:/var/www/html/storage
...
  nginx:
    image: nginx:alpine
    container_name: nginx
    ports:
      - "80:80"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
      - ./backend/subscription_service:/var/www/html:ro
    depends_on:
      - subscription_service

the project is laravel.
index.php is located in ./backend/subscription_service/public folder

Nginx on aapanel blocks CORS headers from PHP script

I am trying to make a cross-domain API request from https://andiamo.elenmorcreative.com to https://andiamo-backend.elenmorcreative.com.

I have configured Laravel and CORS correctly, but it always fails. To prove the problem is on the server, I created a simple public/test.php file that only contains the header(“Access-Control-Allow-Origin: https://andiamo.elenmorcreative.com”);.

However, when I called test.php from the frontend domain, I still got a CORS error, which means the header was not sent. This proves there is something in the Nginx/aapanel configuration that is blocking it.

Here is my current Nginx configuration. Please help to find which setting might be causing this.

server {
    listen 80;
    listen 443 ssl http2;
    server_name andiamo-backend.elenmorcreative.com;
    root /www/wwwroot/andiamo-backend.elenmorcreative.com/andiamo-backend/public;

    # Konfigurasi SSL (JANGAN DIUBAH)
    ssl_certificate /www/server/panel/vhost/cert/andiamo-backend.elenmorcreative.com/fullchain.pem;
    ssl_certificate_key /www/server/panel/vhost/cert/andiamo-backend.elenmorcreative.com/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers off;

    # Pengaturan Umum
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
    index index.php;
    charset utf-8;

    # Pengalihan ke HTTPS
    if ($scheme != "https") {
        return 301 https://$host$request_uri;
    }
    
    # Aturan Rewrite Standar untuk Laravel
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    # Penanganan Error Page
    error_page 404 /index.php;

    # Blok PHP yang Bersih dan Standar
    location ~ .php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass unix:/tmp/php-cgi-83.sock; # Sesuaikan dengan versi PHP Anda
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        internal;
    }
    
    # Blokir akses ke file sensitif
    location ~ /.(?!well-known).* {
        deny all;
    }

    # Logging
    access_log /www/wwwlogs/andiamo-backend.elenmorcreative.com.log;
    error_log /www/wwwlogs/andiamo-backend.elenmorcreative.com.error.log;
}

look for help on community forums that are more specific to aapanel and Nginx.