8 – How do I debug/kint Simple XML Sitemap link array?

I am trying to find how I can debug/kint a variable/array from the Simple XML Sitemap?

I worked through the documentation here: https://www.drupal.org/docs/8/modules/simple-xml-sitemap/api-and-extending-the-module#s-api-hooks to find the hook I need.

My goal is to unset any links that have node/ to remove published, but un-aliased nodes of included content types.

The array key ('path') looks to be the unaliased URL and the below code removes all links except the home page. I am unsure how I can kint($link) in this function so I can see what other array keys are available to see what else I may use for comparison.

function HOOK_simple_sitemap_links_alter(array &$links, $sitemap_variant) {

  foreach ($links as $key => $link) {
    if (strpos($link('meta')('path'), 'node/') !== FALSE) {

Is there a way to kint() these sitemap arrays? Or maybe some documentation that shows the structure of these arrays?

algorithms – Time efficient way to find pairs in an array whose sum equals a specific number?

Given an array of integers, we want to find how many explicit pairs can be made such that their sum is divisible by 60. The pairs do not need to be non-unique.

For example (29, 20, 30, 100, 30, 121, 160, 31, 20) has 6 pairs -> (29, 31) (20, 100) (20, 160) (30, 30) (100, 20) (160, 20)

The obvious and immediate thing is to make a nested for loop

 for (int i = 0; i < pairs.Count - 1; i++)
            for (int n = i + 1; n < pairs.Count; n++)
                    if ((pairs(i) + pairs(n)) % 60 == 0)

but that’s too slow. The above also doesn’t factor in duplicates like if the array had the number “30” as four elements, which is equal to a divergent series of (n-1)(n)/2 = (4-1)(4)/2 = 6.

How can we improve the performance?

My initial though is to make a dictionary/hashmap, but I am unsure how to iterate through that in a performant way.

python – How do I update an array that contains a dictionary with key/value pairs?

I am iterating over an object that has multiple key/value pairs and I’d like to create an array of each time it iterates while updating specific values where the keys are found. I have the logic for looking for specific keys, but I’m drawing a blank on how to get an array of dictionaries.

data = [{'source_id': source_id,
         'order_items_code': order_items_code,
         'color': color,
         'print_sku': print_sku,
         'monogram_type': monogram_type,
         'letters': letters,
         'shadow': shadow,
         'front': front,
         'stripes': stripes

php – Como ler array com mais de um compl

Galera to apanhando aqui, queria uma ajuda rápida, tentei quase tudo

como faço pra eler um array assim com php:


php – Inside Array – “unidentified index” error with “prepare was called incorrectly” despite not calling the prepared statement with wordpress

I know that there is a very old answer that details unidentified index but using the methods there I can not figure out how to make isset work with the code I have. It is below but doesnt solve the issue.

Plus it my error is paired with the PREPARE error AND the fact that my understanding is that answer with ISSET is NOT a safe way anymore to prevent SQL injections. Someone please correct me if I am wrong. As per request I have also included the entire error message.

I am getting a couple of errors with the code below and am not sure why it thinks this isnt prepared properly. Can anyone shed light on this for me? Thanks.

for each line that has a $POST, it is telling me that the “Notice: Undefined index”

     if (!empty($_POST)) {
        global $wpdb;
        $table = "mytablenameplaceholder";
            if(isset($_POST('name')) && isset($_POST('emailaddress'))){
  $number1 = $_POST('name'); 
  $message = $_POST('emailaddress'); 
  $message = urlencode($message); 
        $data = array(
            'name' => $_POST('name'),
            'emailaddress'    => $_POST('emailaddress'),
            'phonenumber'    => $_POST('phonenumber')
        $format = array(
        $success=$wpdb->insert( $table, $data, $format );
            echo 'data has been saved' ; 
    } else {
    <form action="" method="post" >
        <input type="text"  id="name" name="name" value="John">
        <input type="text" name="email">
        <input type="text" name="phonenumber">
        <input type="submit">

I am also receiving a “Notice: wpdb::prepare was called incorrectly.” notice despite not having a prepare statement currently in the code. I know I need to add it.

enter image description here

python – How do I graph an array of objects in MatPlotLib and create different colored cells and characters based on the internal variables of the objects?

I have an numpy array of 0s and objects from a class I created in Python. I want to use MatPlotLib to display them. Since MatPlotLib only takes floats, I would have to convert the objects to floats. The catch is this: the objects can have multiple internal variables with different. I want to represent that in the graph using multiple colors and numbers/characters inside the cells. Something like this:
enter image description here

But with characters inside the cells as well, similar to this:
enter image description here
Is there any way to do that in MatPlotLib?

javascript – Operações com números em array

Comecei a estudar programação recentemente e agora estou aprendendo mais sobre arrays, mas estou estudando com material que acho pela internet então nem sempre é dos melhores ou consegue tirar todas as dúvidas. Como essa…. Escrevi esse código usando node.js pra verificar se um número é primo e adicionar na lista e ele funciona bem pra números menores que 100.

var primeNum = (2, 3, 5, 7);

for (var i = 7; i < 1000; i++){
    if ((i % 2 !== 0) && (i % 3 !== 0) && (i % 5 !== 0) && (i % 7 !==0)){


O problema é que deixa passar números como 121 (11×11) e alguns outros. A questão é que eu coloquei como condição as divisões só por 2, 3, 5 e 7. Teria como eu reescrever a condição de verificação de um jeito onde ele vai usar os números que já estão na lista? Por que aí quando chegasse no 121, por exemplo, ia acabar verificando com o 11 e ele não entraria.

c++ – im making a dynamically allocated array of structures called restaurant that has dynamically allocated arrays of floats and strings for reviews,

im making a dynamically allocated array of structures called restaurant that has dynamically allocated arrays of floats and strings for reviews, but the code isn’t reading my text file correctly and my compiler is creating a separate main file with question marks. I don’t know what went wrong, also sry for bad formatting

#include <fstream>
using namespace std;

const int SIZE = 3, REV = 3;

struct restaurant
    string name;
    int zip;
    float *reviews;
    string *comments;

        if (reviews) delete () reviews;
        if (comments) delete () comments;

void outputRestaurant(restaurant&);

int main() {

    ifstream fin("input.txt");
    restaurant *restaurants = new restaurant (SIZE);
    for (int i = 0; i < SIZE; i++)
        getline(fin, (restaurants+i)->name);
        fin >> (restaurants+i)->zip;
        (restaurants+i)->reviews = new float (REV);
        (restaurants+i)->comments = new string (REV);
        for (int j = 0; j < REV; j++)
           fin >> *((restaurants+i)->reviews+j);
           getline(fin, *((restaurants+i)->comments+j));

    for (int i = 0; i < SIZE; i++)

void outputRestaurant(restaurant &a)
    cout << "Restaurant summary:" << endl;
    cout << "t> Name: "<< a.name << endl;
    cout << "t> Zip: "<< a.zip << endl;
    for(int i = 0; i < SIZE; i++)
        cout << "t> Review #"<< i+1 << ": "<< (*(a.reviews+i));
        cout << " : " << (*(a.comments + i)) << endl;

this is the text file

Lori's Diner
Fantastic dining.
It was OK; lots of waiting.
Bugs in the food but 2 stars.
Mel's Diner
Loved the silverware.
Glorious luxury dining.
Couldn't find Mel.
Luke's Diner
The force was strong here
Dug the cantina vibe
Couldn't find Princess Leia.

PHP API REST with Value Objects – How to log ALL exceptions to a Error array and render it to user?

I am developing an PHP API REST using Value Objects. I have some value objects as like: ID, Date, Name, etc. When they fail in their construction due to a invalid format or something it throws a InvalidArgumentException.

How can I “collect” all the Exceptions and when the script stops send them in an “error” array in the json response?

The problem is that i think that make hundred of try catch for each value object is not the best way, and I can not find the way to catch multiple exceptions in a try block.

Value Object that may throw an InvalidArgumentException

I have this poor elegant solution:

$errors = ();

try {
    $authorID = new ID('dd');
} catch(Exception $e) {
    $errors() = $e->getMessage();

try {
    $authorID = new ID('ff');
} catch(Exception $e) {
    $errors() = $e->getMessage();

Also if the VO are created succesfully, i want to create an object with them, example:

$Insertable = new Insertable($authorID);

How can do this?

If i have multiple ValueObjects that may throw Exceptions, how can I catch them all and make a response with these exceptions as “error” array?


javascript – Como fazer cada elemento de um array de números multiplicar cada um dos seus dígitos dentro de uma substring?

Vim de Python e estou tentando criar uma função cujo objetivo é calcular o maior produto para uma substring contínua de dígitos de comprimento N.
Ex: para o input ‘102181952’, o produto maior para uma série de 3 dígitos é 90 (9 * 5 * 2)

Eu tentei criar dois loops com for (array(i)(j)) igual em Python, porém não obtive sucesso. O máximo que consegui até agora foi, ao menos, criar um array de substrings. Tentei usar map e reduce, porém não obtive êxito, muito provavelmente porquê não sei manusear bem as funções, embora eu tenha lido os documents e pesquisado extensivamente por aqui em inglês e português.

Até agora o que eu consegui fazer, e acho que nem servirá de nada foi simplesmente:

// Ainda não coloquei dentro de uma function(numero, tamanho) 
// para fins de monitoramento.

var numero = '123456789';
var tamanho = 3;
var listaNumeros = ( );

for (var i = 0; i < numero.length; i += tamanho) {
    listaNumeros.push(numero.substr(i, tamanho));

console.log(listaNumeros); // ( '123', '456', '789' )

Alguém poderia ao menos me apontar a direção correta para a solução? Eu simplesmente estou em branco, não consigo pensar em mais nada. Muito obrigado!