How do I change the rendering order for the SurfaceView element, so It won’t be rendered first on Android?

I am currently building an application that shows media files using expo-video, VideoView, these items has two states, a preview and an open state. When a video is opened the background is rendered on top of the video. This problem only occurs on android, on ios the video is rendered as intended. My goal is to have a little transparent black background behind the opened video.

<Modal
  visible={modalVisible}
  transparent
  animationType="fade"
  onRequestClose={closeModal}
>
  <View style={styles.openMediaBG}>
    <TouchableOpacity
      style={styles.closeButtonStyle}
      onPress={closeModal}
    >
      <Ionicons name="close" size={30} color="white" />
    </TouchableOpacity>

    <View style={styles.mediaContainer}>
      {isVideo && modalVideoPlayer ? (
        <TouchableOpacity
          style={styles.videoTouchable}
          onPress={handleVideoTap}
          activeOpacity={1}
        >
          <VideoView
            player={modalVideoPlayer}
            style={styles.modalVideo}
            allowsPictureInPicture={false}
            nativeControls={true}
            showsTimecodes={false}
            requiresLinearPlayback={false}
            contentFit="contain"
          />
        </TouchableOpacity>
      ) : (
        <Image
          source={typeof selectedMedia.uri === "string"
            ? { uri: selectedMedia.uri }
            : selectedMedia.uri
          }
          style={styles.modalImage}
          resizeMode="contain"
        />
      )}
    </View>

    <Text style={styles.timestampStyle}>
      {selectedMedia.timestamp
        ? new Date(selectedMedia.timestamp).toLocaleDateString()
        : "Unknown date"
      }
    </Text>
  </View>
</Modal>

I know this is caused by surfaceView being rendered differently on android, it is being rendered first then everything else gets rendered after. On expo’s documentation site textureView mentioned as a solution for rendering issues, so I have tried it, but with that the video wasn’t appearing at all. I have also tried some alternatives like rendering two VideoView, but one had a style that made it fully black, this gave the video a black background but cannot be made transparent and I fear this is a hardware heavy solution. Besides these approaches I couldn’t find more possible solutions.

How to replace a patterned string efficiently with PHP e.g. ((1)), ((2)) for footnotes

A website I have taken over uses footnotes in the form ((1)), ((2))((40)) etc. in the database. I am trying to programmatically replace these strings on the front-end templates with the following HTML on the fly, ideally using PHP, though I suppose a JavaScript / jQuery solution could work.

Replace ((1)) with:

<a href="#footnote-1" class="footnote-link"><sup>[1]</sup></a>

The number in brackets needs to be included both in the link target e.g. #footnote-1 but also in the superscript text e.g. <sup>[1]</sup>. Currently I am running through this with string replace. As follows:

$content = str_replace('((1))', '<a href="#footnote-1" class="footnote-link"><sup>[1]</sup></a>', $content);        
$content = str_replace('((2))', '<a href="#footnote-2" class="footnote-link"><sup>[2]</sup></a>', $content);
$content = str_replace('((3))', '<a href="#footnote-3" class="footnote-link"><sup>[3]</sup></a>', $content);

etc. x 40 

As we have up to forty footnotes this seems pretty inefficient, as the $content blocks of text can be long articles of thousands of words, and many may not have anything near 40 footnotes.

Is there a more efficient way to do this? Perhaps breaking out of the loop if the previous footnote doesn’t exist. I tried to look at RegEx but I am always baffled by the syntax and didn’t get very far. Any tips greatly appreciated.

KaTeX not formatting caret (^) for superscripts in mathematical expressions

I’m building a Q&A chat widget that uses marked.js for Markdown rendering and KaTeX for mathematical expressions. While most LaTeX expressions render properly, the caret (^) character for superscripts is not being formatted and displays as plain text.

Current Behavior:

Superscripts using ^ (like b^2, a^2, x^2) display as raw text instead of formatted superscripts. Most mathematical notation works fine

Example API Response:

json
{
    "success": true,
    "data": {
        "answer": "In the context of mathematics... the expression \( (a + b)^2 \) expands to: \[ a^2 + 2ab + b^2 \] ... Formulas can represent quadratic equations (e.g., \( ax^2 + bx + c = 0 \))."
    }
}

In this response, \( (a + b)^2 \) should render as (a+b)² but the caret remains unformatted.

Relevant Code:

HTML setup:

html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
JavaScript rendering:

javascript
function renderMath(element) {
  if (window.renderMathInElement) {
    renderMathInElement(element, {
      delimiters: [
        {left: '$$', right: '$$', display: true},
        {left: '$', right: '$', display: false},
        {left: '\[', right: '\]', display: true},
        {left: '\(', right: '\)', display: false},
        {left: '[ ', right: ' ]', display: true},
        {left: '[', right: ']', display: true}
      ],
      throwOnError: false,
      ignoredTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'],
      processEscapes: true
    });
  }
}

function appendMessage(text, from) {
  const wrap = document.createElement("div");
  wrap.className = `message ${from}`;
  const bubble = document.createElement("div");
  
  if (from === "model") {
    bubble.className = "bubble";
    bubble.innerHTML = marked.parse(text);
    
    setTimeout(() => {
      renderMath(bubble);
    }, 10);
  } else {
    bubble.textContent = text;
  }
  
  wrap.appendChild(bubble);
  messagesEl.appendChild(wrap);
}

Expected Behavior:

  • b^2 should render as b² with proper superscript formatting
  • x^2 should render as x²
  • (a + b)^2 should render as (a+b)²
  • All caret-based superscripts and all mathematical expressions should be properly formatted.

I have not tested with other mathematical expressions like frac, etc. How can I ensure caret-based superscripts and all mathematical expressions are properly formatted?

How to hide / show slides?

I am trying to add a sideload add-in doing some automation in powerpoint.
I couldn’t find a command or property in the powerpoint office add-in to hide/show slides.

Does anyone know how to hide / show slides via javascript in powerpoint?

The command via VBA is:

ActivePresentation.Slides(1).SlideShowTransition.Hidden = True / False

Command via Javascript: ???

But there exists a method to delete slides:
slide.delete() exists, but no slide.hide()

Thanks, Florian

How to change model to export from filament resource to exporter class

I have an application that uses filament 3.2 and in this application I have a resource called “Students”, within this resource I am calling a “TablesActionsExportBulkAction” that calls a custom exporter.

The problem is that my resource comes from the “Students” model and what I need to export is an entity called “Courses” which is another table and has a one to many relationship with students, so a course can have many students and a student can only belong to one course.

                TablesActionsExportBulkAction::make('export_courses')
                ->label('Courses export')
                ->icon('heroicon-o-document-arrow-down')
                ->color('success')
                ->modifyQueryUsing(function (Builder $query)
                {
                    $initalQuery = $query->pluck('id')->toArray();
                    $newQuery = Courses::query()
                        ->whereIn('student_id', $initalQuery)
                        ->with(['student', 'user']);
                    return $newQuery;
                })
                ->exporter(CoursesExporter::class),

But by default exporter takes the “Students” model that comes from the resource, and if I try to change it inside the exporter it doesn’t work:

protected static ?string $model = Courses::class;

I also tried to change the query inside the exporter using the “modifyQuery” method but it doesn’t work either, it gets an error when I try to export:

    public static function modifyQuery(Builder $query): Builder
{
    $initalQuery = $query->pluck('id')->toArray();
    $newQuery = Courses::query()
        ->whereIn('student_id', $initalQuery)
        ->with(['student', 'user']);
    return $newQuery;
}

Is there a way to do this natively with filament? Or maybe there’s a way to do this with a custom action or something?
I thank those who know and can respond!!

I’m using filament 3.2, php 8.2 and laravel 11.45.0

PHP LDAP sessions (how to preserve password for subsequent bind calls)

I’m struggling to figure out how to add ldap authentication to a webapp that I am writing to manage entries in the LDAP server itself.

I want users to be able to log into the webapp with their LDAP credentials and most importantly, bind with their credentials for subsequent LDAP queries.

The part that is tripping me up the most is this:

You’re supposed to bind when needed, and unbind when you are done. So while I can create a $_SESSION["username"] object, I’ve seen no examples of a $_SESSION["password"] object for subsequent LDAP bind calls. That being said, how do I incorporate start_session() and use ldap_bind (Which requires the password) correctly if not by creating a $_SESSION["password"] object?

Example class I am working on:

<?php
session_start();

class LdapAuthenticator {
    private $ldapConnection;
    private string $ldapUri;

    public function __construct(string $uri) {
        $this->ldapUri = $uri;
        $ldap_error_message = ldap_error($this->ldapConnection);
        if($this->ldapConnection === false) {
            throw new Exception($ldap_error_message);
        }
    }

    public function connect(): bool {
        $this->ldapConnection = ldap_connect($this->ldapUri);
        if ($this->ldapConnection) {
            ldap_set_option($this->ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3);
            ldap_set_option($this->ldapConnection, LDAP_OPT_REFERRALS, 0);
            return true;
        }
        return false;
    }

    public function bind(string $bind_dn, string $bind_pw): bool {
        if (!isset($this->ldapConnection)) {
            throw new Exception("LDAP connection not established. Call connect() first.");
        }
        $ldap_error_message = ldap_error($this->ldapConnection);
        if (!empty($ldap_error_message) && $ldap_error_message !== "Success") {
            if(ldap_get_option($this->ldapConnection, LDAP_OPT_DIAGNOSTIC_MESSAGE, $extended_error)) {
                throw new Exception("$ldap_error_message - $extended_error");
            } else {
                throw new Exception("$ldap_error_message");
            }
        }
        return ldap_bind($this->ldapConnection, $bind_dn, $bind_pw);
    }
                
    public function authenticate(string $username, string $password) {
        // Attempt to bind with user credentials
        if ($this->bind($username, $password) "uid={$username},{$this->baseDn}", $password) {
            $_SESSION['ldap_username'] = $username;
            // Optionally retrieve and store other user details
            return true;
        }
        return false;
    }

    public function isLoggedIn() {
        return isset($_SESSION['ldap_username']);
    }

    public function close(): void {
        if (isset($this->ldapConnection)) {
            ldap_unbind($this->ldapConnection);
        }
    }

    public function getError(): string {
        if (isset($this->ldapConnection)) {
            return ldap_error($this->ldapConnection);
        }
        return "No LDAP connection.";
    }

    public function search(string $filter, string $settings) {
        $search_result = ldap_search($this->ldapConnection, $settings, $filter);

        $ldap_error_message = ldap_error($this->ldapConnection);
        if (!empty($ldap_error_message) && $ldap_error_message !== "Success") {
            if(ldap_get_option($this->ldapConnection, LDAP_OPT_DIAGNOSTIC_MESSAGE, $extended_error)) {
                throw new Exception("$ldap_error_message - $extended_error");
            } else {
                throw new Exception("$ldap_error_message");
            }
        }
                return ldap_get_entries($this->ldapConnection, $search_result);
    }
    
}    
?>

Example page code I am trying to piece together:

<?
try {
    $host = "ldaps://ldap.example.com";
    $baseDn = "dc=example,dc=com";
    $ldap = new LdapAuthenticator($host);

    if ($ldap->connect()) {
        if (!$ldap->bind($_POST["username"], $_POST['password'])) {
            $htmlerror = $ldap->getError();
        } else {
            $htmlerror = $ldap->getError();
            // Proceed with other LDAP operations (search, modify, etc.)
            $entries = $ldap->search("(&(objectClass=nsPerson)(objectClass=posixAccount))", $baseDn);
        }
        $ldap->close();
    } else {
        echo "Failed to connect to LDAP server.n";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "n";
}

if (isset($_POST['username']) && isset($_POST['password'])) {
    if ($ldapSession->authenticate($_POST['username'], $_POST['password'])) {
        header("Location: protected_page.php");
        exit();
    } else {
        echo "Invalid credentials.";
    }
}

if ($ldapSession->isLoggedIn()) {
    echo "Welcome, " . $_SESSION['ldap_username'] . "!";
} else {
    // Display login form
}
?>

How to programmatically show out-of-stock products at the end of product listings in Shopware 6?

I am working on a Shopware 6 project and I want to change the product listing behavior on category pages (and search results).

Requirement:
Regardless of which sorting option a customer selects (price ascending, relevance, name, etc.), all out-of-stock products should always be shown at the end of the product listing.

What I’ve tried so far:

Subscribed to ProductListingCriteriaEvent and added an extra sorting:

$criteria->addSorting(new FieldSorting(‘stock’, FieldSorting::DESCENDING));

Breaking a table row (tr) into two pages in mpdf or any other libraries

I am trying to break a table row (tr) into two pages if the content doesn’t fill the page,

Now it is breaking the whole into the next page which results in blank space in the first page above the footer

I am using the WriteHTML to generate pdf content

 foreach ($product_details as $prod_det) {
            $rate = format_currency($prod_det->qpd_rate);
            $amount = format_currency($prod_det->qpd_amount);
            $disc = number_format($prod_det->qpd_discount, 2);

            $pdf_data .= '
            <tr nobr="false">
                <td align="center" width="8%" style="padding: 2px; vertical-align: top;">' . $k . '</td>
                <td align="left" width="45%" style="padding: 2px;" vertical-align: top;>' . $prod_det->product_details . '</td>
                <td align="center" style="padding: 2px; vertical-align: top;" >' . $prod_det->qpd_quantity . '</td>
                <td align="center" style="padding: 2px; vertical-align: top;" >' . $prod_det->qpd_unit . '</td>
                <td align="right" style="padding: 2px; vertical-align: top;" >' . $rate . '</td>
                <td align="center" style="padding: 2px; color:red; vertical-align: top;" ><i>' . $disc . '</i></td>
                <td align="right" style="padding: 2px; vertical-align: top">' . $amount . '</td>
            </tr>
            ';
            $k++;
        }


 $mpdf = new MpdfMpdf([
            'margin_top' => 68,
            'margin_bottom' => 0,
            'margin_left' => 5,
            'margin_right' => 5,
            'defaultfooterline' => 0,
            'setAutoTopMargin'   => 'stretch',
            'setAutoBottomMargin'   => 'stretch',
            'keep_table_proportions' => false,
        ]);

 $mpdf->simpleTables = true;
        $mpdf->use_kwt = true;  // Keep-with-table
        $mpdf->packTableData = true;  // Better table handling
        $mpdf->shrink_tables_to_fit = 0;  // Don't shrink tables

        $mpdf->SetAutoPageBreak(true);

        $mpdf->SetTitle($title);


 $main_table = '<style>
                th, td { padding: 4px; font-size: 12px; }
                p { font-size: 12px; margin-bottom: 13px; } 
                table {
                page-break-inside: auto;
                }
                tr {
                    page-break-inside: auto;
                    page-break-after: auto;
                }
                td {
                    page-break-inside: auto;
                }
            </style>
            <table width="100%" style="page-break-inside:auto;border-collapse: collapse; margin-top: 10px;border-top:1px solid;line-height:18px;" autosize="1">
                <thead>
                    <tr>
                        <th align="center" width="8%" style="border-bottom:1px solid;">Item No</th>
                        <th align="center" width="45%" style="border-bottom:1px solid;">Description</th>
                        <th align="center" style="border-bottom:1px solid;">Qty</th>
                        <th align="center" style="border-bottom:1px solid;">Unit</th>
                        <th align="center" style="border-bottom:1px solid;">Rate</th>
                        <th align="center" style="border-bottom:1px solid;">Disc%</th>
                        <th align="center" style="border-bottom:1px solid;">Amount</th>
                    </tr>
                </thead>
                <tbody>
                ' . $pdf_data . '
                </tbody>
            </table>
            
            ';

$mpdf->WriteHTML($main_table);

//Other code

tried using page-break-inside: auto style inside table,tr,tbody, putting the row inside a whole tbody, in a whole table

See the blank space after the 9th row, the 10th is pushed to the next page, I want to take the space available and then push the remaining content to the next page

Custom password hasher cakephp 3.8

I’m throwing a message in a bottle for those who are fairly proficient with Cakephp 3.8. I admit I’m a little rusty after a few years of hiatus from development

I’ll explain my problem:
I have a basic module that allows user registration and login. So far, so good. My problem comes at the login stage, as I’m using a custom hash of the $password+$key type. The $key is automatically generated during registration and then stored in the users table with the other information.

I’d like to know if there is a way to retrieve this value without using manual checks in order to keep my code perfectly clean and functional.

Currently, I can enter any password, and $user returns true as long as the email address exists in the table.

src/Controller/Users/Usercontroller.php

public function register() {
     $userTable = TableRegistry::getTableLocator()->get('Users');
     $user = $this->Users->newEntity($this->request->getData(), ['validate' => 'UserStep1']);
     $user->type = $this->request->getSession()->read('account-type');
     $user->salt = sha1(md5($this->request->getSession()->read('salt')));
     $user->password = $hash->hash($this->request->getData('password'),$this->request->getSession()->read('salt'));

     if ($userTable->save($user)) {
     return true;
     }
}


public function login() {
        if($this->request->is('post')) {
            $user = $this->Auth->identify();
            if($user) {
                $this->Auth->setUser($user);
                $this->redirect($this->redirect($this->Auth->redirectUrl()));
                $this->Flash->response('Connecté', [
                    'key'   => 'response',
                    'params'    => [
                        'status'    => 'success'
                    ]
                ]);
            } else {
                $this->Flash->response('Identifiant ou mot de passe incorrect', [
                    'key'   => 'response',
                    'params'    => [
                        'status'    => 'error'
                    ]
                ]);
            }
        }
    }

src/Auth/CustomPasswordHasher.php

namespace Appauth;

use CakeAuthAbstractPasswordHasher;

class CustomPasswordHasher extends AbstractPasswordHasher {

    public function hash($password, $securestring = null) {
        $encode=  sha1(md5('stringmasked'). md5(sha1($password)).sha1(sha1(md5($securestring))));

        return $encode;
    }
    public function check($password, $salt)
    {
        $encode = sha1(md5('stringmasked').md5(sha1($password)).sha1(($salt)));

        return $encode;
    }
}


src/Controller/AppController.php

$this->loadComponent('Auth', [
            'authenticate'  => [
                'Form'  => [
                    'fields'    => ['username'  => 'email'],
                    'passwordHasher'    => ['className' => 'Custom']
                ]
            ]
        ]);
        $this->Auth->allow();

I admit that I’m a bit stuck on this problem, I don’t really know where the problem comes from

Thanks

Puppeter: Error: Execution context was destroyed, most likely because of a navigation

I’m having a problem with this code. I’m using Puppeter, and it seems to be throwing the error: “Error: Execution context was destroyed, most likely because of a navigation.” Why could this happen? I’m attaching a fragment of my code where it seems to be failing.

export async function goTo(page: Page, target1: string, target2: string) {
    await common.click(page, '#nav-item-welcome');
    await common.waitTillHTMLRendered(page);

    await common.click(page, target1, { clickType: 'puppeteer' }); // clicktype puppeter or jquery
    await common.waitTillHTMLRendered(page);

    await common.click(page, target2, { clickType: 'puppeteer' });
    await common.waitTillHTMLRendered(page);
}

How can I simplify this dual filtering (by status & priority) logic in React using JavaScript array methods?

I’m building a small React app to manage tasks.
Each task has a status (true/false) and a priority (low/medium/high).

I have two filter buttons — one for status and one for priority — and I’m using the below handlers to update the displayed list (taskArray) based on what the user selects.

Here’s my working code:

const handleStatus = (e: React.MouseEvent<HTMLElement>) => {
    const label = e.currentTarget.innerText;
    setStatusLabel(label);
    setStatusActive(e.currentTarget.id);

    const priorityArray =
      priorityLabel === "All"
        ? allTasks
        : allTasks.filter((x) => x.priority === priorityLabel);

    if (label === "All") {
      setTaskArray(priorityArray);
    } else if (label === "Active") {
      setTaskArray(priorityArray.filter((x) => !x.status));
    } else if (label === "Complete") {
      setTaskArray(priorityArray.filter((x) => x.status));
    }
  };

  const handlePriority = (e: React.MouseEvent<HTMLElement>) => {
    const label = e.currentTarget.innerText;
    setPriorityLabel(label);
    setPriorityActive(e.currentTarget.id);

    const statusArray =
      statusLabel === "All"
        ? allTasks
        : statusLabel === "Active"
        ? allTasks.filter((x) => !x.status)
        : allTasks.filter((x) => x.status);

    setTaskArray(
      label === "All"
        ? statusArray
        : statusArray.filter((x) => x.priority === label)
    );
  };

It works, but I feel there might be a more concise or reusable way to achieve this using JavaScript array methods — maybe by combining both filters into one function or chaining them more elegantly.

Question:

How can I simplify or refactor this code to handle both filters more efficiently (while keeping readability)?

Using EXIF library to extract metadata from jpg media files causes an error that is not properly handled by try-catch

I’m writing a small JavaScript program that scans through the contents of a folder where hundreds or thousands of image files are stored, extracts some data items from each image file (like timestamp + GPS coordinates) and writes a text file with a JSON array of the form:

[{"File":"20250912_131538.jpg","Timestamp":"2025-09-12T13:15:22","GPS_Latitude":23.4544454,"GPS_Longitude":78.345428354},
 {"File":"20250912_131538.jpg","Timestamp":"2025-09-12T13:15:22","GPS_Latitude":23.4544411,"GPS_Longitude":78.345428301},
 ...
]

Everything works OK (meaning, tens of files are properly processed) till an error within the EXIF functionality causes the process to halt.

I tried placing the EXIF invocation within a try-catch block but the program still halts.

Since one of the possible reasons is asynchronous invocation, I added to printouts as follows:

try {
    console.log("----- Before invoking EXIF...")

    l_EXIF_Returned_Value = EXIF.getData(l_Thumb, function() {

    console.log("----- After invoking EXIF...")

    [rest of the code...]

Within the console:

----- Before invoking EXIF...
exif.js:742  Uncaught RangeError: Offset is outside the bounds of the DataView
...

So, the invocation is synchronic and still it appears that the exception is not caught by the try-catch structure.

Does anyone ever encountered such behavior (try-catch not working?

Any suggestion will be most appreciated.

Stacking on ansible centos [closed]

Swapping is like the OS moving things into the spare storage room when the main room RAM gets too full. It’s a memory management technique where the OS temporarily moves an entire process or some of its pages from main memory to a dedicated area on the secondary storage the hard drive, usually called swap space.