theming – Preprocessed var not being passed to twig template

I created a custom theme called wdocs as a sub theme of d8w3css. I made a template to override the menu template for the user account menu, calling it menu–account.html.twig. For my theme, I added the function wdocs_preprocess_menu__account() to my wdocs.theme file, and introduced a new variable with $variables(‘tollfree_number’) = ‘555-1212’; So far so good; in phpStorm I can set a breakpoint there are do see it is getting set in $variables. In my twig, I have some text, followed by {{ tollfree_number }}. The text gets displayed, but not the variable.

The problem is the twig calls a macro; I can access the var outside of the macro, but not within it. Googling suggested I pass context when calling the macro, so I changed the call to
{{ menus.menu_links(items, attributes, 0, menu_name, _context) }}

I also tried “context” (no underscore). And also tried dereferencing it with {{ _context(‘tollfree_number’) }}, but nothing seems to help. Where am I going wrong?

magento2.4 – How to move media and var directory to a volume instead of main server disk space?

I have a small server: 4 vcpu cores, 8 gb ram and 40 gb ssd. And i attached to it a volume that’s 1TB in size (i know it is not enough in terms of cpu/ram but i will upgrade to a much better server soon).

Here is how it looks when i run df -h

root@ubuntu-edit:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            953M     0  953M   0% /dev
tmpfs           194M  776K  194M   1% /run
/dev/sda1        38G  1.8G   35G   5% /      <------------ server's ssd space
tmpfs           970M     0  970M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           970M     0  970M   0% /sys/fs/cgroup
/dev/sda15       61M  7.8M   53M  13% /boot/efi
/dev/sdb       1007G   77M  956G   1% /mnt/volume-edit <------- volume's space
tmpfs          194M     0  194M   0% /run/user/0

Question is: how do i move the media(including images) directory, var directory and all other directories that tend to get pretty big to the volume and upload images and make the caching directly to that new location instead of keeping everything on the main server?

Is that even a thing?

Kubernetes + kustomize: How to use ‘var’ in configMapGenerator?

In my kustomization.yaml I have:

configMapGenerator:
  - name: nginx-config
    files:
      - nginx.conf
vars:
  - name: PHP_FPM
    objref:
      kind: Service
      name: app-service
      apiVersion: v1
    fieldref:
      fieldpath: metadata.name

And then in nginx.conf I have:

    location = /index.php {
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass $(PHP_FPM):9000;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /app/index.php;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

When I run kustomize the var isn’t replaced:

❯ kustomize build kubernetes/overlays/staging | grep fastcgi_pass
2020/06/07 18:25:05 well-defined vars that were never replaced: PHP_FPM
            fastcgi_pass $(PHP_FPM):9000;

How can I get my service name into nginx.conf?

Como atualizar uma var em tela javascript

Então comecei a estudar JavaScript a cerca de uma semana, e estou tendo alguns problemas na hora de criar uma aplicação para estudar a linguagem. Criei uma variável chamada points e disse que o valor inicial dela é 100, toda vez que eu clicar em adicionar ela acrescenta 10 pontos a essa váriavel e toda vez que eu clicar no botão deletar ela subtrai 10 pontos dessa variável, coloquei um alert mostrando isso, e está funcionando, porém a variável em tela não atualiza. Como faço pra essa variável toda vez que for adicionado ou subtraído pontos ela atualizar na tela, e não somente no alert que criei? Se puderem também me dar dicas de como posso aprender JavaScript mais rápido, agradeço.

var listElement = document.querySelector('#app ul');
var inputElement = document.querySelector('#app input');
var btnElement = document.querySelector('#app button');
var pointsElement = document.querySelector('.pointsTodo');
var deleteEvent = document.querySelector('#delete');

var todos = JSON.parse(localStorage.getItem('listTodos')) || ();
var points = 100;

function renderTodos() {
    listElement.innerHTML = '';

    for (todo of todos) {
        var todoElement = document.createElement('li');
        var todoText = document.createTextNode(todo);

        var deleteElement = document.createElement('a');
        deleteElement.setAttribute('href', '#');
        var pos = todos.indexOf(todo);
        deleteElement.setAttribute('onclick', 'deleteTodo('+ pos +')');
        deleteElement.setAttribute('id', 'delete');
        var deleteImg = document.createElement('img');
        deleteImg.setAttribute('src', '/svg/remove.svg')
        deleteElement.appendChild(deleteImg);

        var confirmElement = document.createElement('a');
        confirmElement.setAttribute('href', '#');
        var pos = todos.indexOf(todo);
        confirmElement.setAttribute('onclick', 'confirmTodo('+ pos +')');
        confirmElement.setAttribute('id', 'confirm');
        var confirmImg = document.createElement('img');
        confirmImg.setAttribute('src', '/svg/confirm.svg')
        confirmElement.appendChild(confirmImg);

        todoElement.appendChild(todoText);
        todoElement.appendChild(deleteElement);
        todoElement.appendChild(confirmElement);

        listElement.appendChild(todoElement);    
    }
}

renderTodos();

function addTodo() {
    var todoText = inputElement.value;

    todos.push(todoText);
    inputElement.value = ('');
    renderTodos();
    saveToStorage();
}

btnElement.onclick = addTodo;

function deleteTodo(pos) {
    todos.splice(pos, 1);
    this.points-=10;
    alert('Você desistiu da tarefa :( ' + points);
    renderTodos();
    saveToStorage();
}

function confirmTodo(pos) {
    todos.splice(pos, 1);
    this.points+=10;
    alert(`Parabéns, você concluiu a tarefa :) ${points}`);
    renderTodos();
    saveToStorage();
}

function saveToStorage() {
    localStorage.setItem('listTodos', JSON.stringify(todos));
}

function pointsTodo() {
    var createPoints = document.createTextNode(points);
    pointsElement.appendChild(createPoints);
    renderTodos();
    saveToStorage();
    return points;
}

pointsTodo();

c ++ superclass sets up a separate thread with callback from the subclass. I am not initializing for subclass member var

If you have a class with a subclass, it has a virtual callback that the subclass implements.

In the upper class I set up a thread to call the callback during creation. The recall accesses members of the subclass. As a result, the callback receives an "uninitialized variable" error.

I understand why, does anyone know of a fairly common pattern that enables this use?

class A{

A(){ make_a_new_thread(callbackfunction); }

virtual void callbackfunction();

};

class B : public A
{

int x;

B() : x(1) { }

virtual void callbackfunction(){ 
   int z = x+1;
}

};

Is that just bad design or is there a pattern to meet this requirement? I didn't write it, I have to fix it.

Thank you so much!

CentOS 6 rsyslog continuous stream of entries that fill / var / log / messages

After running yum update on one of my boxes, I get a continuous stream of entries in / var / log / messages and fill up the hard drive. I couldn't see where the events were coming from

Linux host1 2.6.32-754.28.1.el6.x86_64 #1 SMP Wed Mar 11 18:38:45 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Protocol section

Apr 27 21:05:45 127.0.0.1 2020-04-27 21:05:45,537 (Thread-0) WARN  EventLog.confd- UserSessNotification(STOP, user=(name=admin, usid=981303, addr=127.0.0.1, prot=1), db=DB_NONE)
Apr 27 21:05:45 127.0.0.1 2020-04-27 21:05:45,537 (Thread-0) WARN  EventLog.confd- AuditNotification(logno=107, user=admin, usid=981303, msg="Logged out from maapi ctx=mappi (end_user_session)")
Apr 27 21:06:18 127.0.0.1 2020-04-27 21:06:18,587 (Thread-0) WARN  EventLog.confd- AuditNotification(logno=105, user=admin, usid=981305, msg="assigned to groups: admin")
Apr 27 21:06:18 127.0.0.1 2020-04-27 21:06:18,587 (Thread-0) WARN  EventLog.confd- UserSessNotification(START, user=(name=admin, usid=981305, addr=127.0.0.1, prot=1), db=DB_NONE)
Apr 27 21:06:18 127.0.0.1 2020-04-27 21:06:18,587 (Thread-0) WARN  EventLog.confd- AuditNotification(logno=105, user=admin, usid=981305, msg="assigned to groups: admin")
Apr 27 21:06:18 127.0.0.1 2020-04-27 21:06:18,587 (Thread-0) WARN  EventLog.confd- UserSessNotification(START, user=(name=admin, usid=981305, addr=127.0.0.1, prot=1), db=DB_NONE)
Apr 27 21:06:18 127.0.0.1 2020-04-27 21:06:18,589 (Thread-0) WARN  EventLog.confd- UserSessNotification(STOP, user=(name=admin, usid=981305, addr=127.0.0.1, prot=1), db=DB_NONE)
Apr 27 21:06:18 127.0.0.1 2020-04-27 21:06:18,590 (Thread-0) WARN  EventLog.confd- AuditNotification(logno=107, user=admin, usid=981305, msg="Logged out from maapi ctx=mappi (end_user_session)")
Apr 27 21:06:18 127.0.0.1 2020-04-27 21:06:18,589 (Thread-0) WARN  EventLog.confd- UserSessNotification(STOP, user=(name=admin, usid=981305, addr=127.0.0.1, prot=1), db=DB_NONE)
Apr 27 21:06:18 127.0.0.1 2020-04-27 21:06:18,590 (Thread-0) WARN  EventLog.confd- AuditNotification(logno=107, user=admin, usid=981305, msg="Logged out from maapi ctx=mappi (end_user_session)")
Apr 27 21:06:51 127.0.0.1 2020-04-27 21:06:51,636 (Thread-0) WARN  EventLog.confd- AuditNotification(logno=105, user=admin, usid=981306, msg="assigned to groups: admin")
Apr 27 21:06:51 127.0.0.1 2020-04-27 21:06:51,636 (Thread-0) WARN  EventLog.confd- UserSessNotification(START, user=(name=admin, usid=981306, addr=127.0.0.1, prot=1), db=DB_NONE)

Can anyone recognize these entries and how can I suppress them?

I checked in my rsyslog.conf and the system definitely doesn't log kernel messages.