вторник, 13 июля 2021 г.

Cannot access protected property при вызове в том же классе.

 Php 7.0 и Netbeans 11. При дебаге, а потом и после него возникает ошибка "Cannot access protected property" при чтении свойства из его же класса. Выяснил, что этот баг происходит когда есть какое-либо Expression в Netbeans (возможно expression с не существующем свойством/переменной на текущем шаге.). Убираешь Expressions и ошибка уходит .

вторник, 14 августа 2018 г.

Ubuntu 18.04. VMware Player update kernel problem.

If updating kernel is failed in VMware Player, try to use this command to see all errors in code:

       sudo vmware-modconfig --console --install-all

Now you can see all errors are marked in red. To fix them you need to go to the source folder:

       cd /usr/lib/vmware/modules/source

Here is archived sources of VMvare modules and we need to fix them.

In my case, all problems was related with files from vmmon.tar archive, so first I duplicate it:

       sudo cp vmmon.tar vmmon_old.tar

Then I extract it by:

      sudo tar xf vmmon.tar

Then I apply patches from here, then from here (find you error in 308 cases), and finally from here on extracted files. You can manually changed the extracted source files by gedit for example.

After change source files, its need to update an existing source archive (in my case it's vmmon.tar) by:

      sudo tar cf vmmon.tar vmmon-only

Then try again:

      sudo vmware-modconfig --console --install-all

If process gone successfully, you can clean the extracted source files:

      sudo rm -rf vmmon-only

And remove duplicate:

      sudo rm -f vmmon_old.tar

By materials:
1
2
3
4



      

Ubuntu 18.04. Fixing duplicate of the Bookmark folders and the corresponding mounted disks in the Places menu.

The folders in the home folder are good categorized. And I like put files to the corresponding folders in the Home folder: Documents, Downloads, Pictures...
I want that these folders are independent from reinstallation ubuntu, so I created corresponding disks and mounting them in system installation process.

But the Places menu in Ubuntu 18.04 have duplication of Home folders and corresponding mounted disks.

To fix this you need, in Disks program, click on Document disk and add to the mounted options this:

      x-gvfs-hide

After this Document folder and mounted Document disk will not duplicated in the Places menu.

воскресенье, 4 мая 2014 г.

HTTP-authentication in request.

Когда мешает HTTP-authentication. Достаточно в запросе добавить заголовок (в примере используется зендовская модель запроса):

$this->setHeaders("Authorization", "Basic ".base64_encode('user:password'));
 И в заголовках получится что-то наподобие:
  Authorization: Basic ZWx1c3VhcmlvOnlsYWNsYXZl

четверг, 13 февраля 2014 г.

JS Submit ALERT/CONFIRM. Selenium

   Для написания теста на selenium, столкнулся с необходимостью, подверждения confirm'a. Тк в драйвере селениума нет стандартного решения для подверждения конфирма, то пришлось пойти таким путем:
        $this->getSession()->executeScript("window.confirm = function() {return true;};");
        $this->getSession()->executeScript("document.getElementsByClassName('form-buttons')[1].getElementsByTagName('button')[2].click();");

    Вот это window.confirm = function() {return true;};  переписывает стандартную функцию confirm, на функцию которая всегда возвращает true, вместо окошка confirm.
    Аналогично, можно сдлеать и с alert, но в selenium'e для него имеется такое решение:
        $this->getSession()->getDriver()->getWebDriverSession()->accept_alert();

Позже решил что прошлый код не безопасен и переписал его на:
        $this->getSession()->executeScript("window.confirm = function() {return true;};");
        $this->getSession()->executeScript("
        var order_buttons = document.getElementsByClassName('form-buttons')[0].getElementsByTagName('button');
        for(var i=0; i<order_buttons.length; i++){
            if(order_buttons[i].title == 'Cancel'){
                order_buttons[i].click();
            }
        }
        ");

четверг, 23 января 2014 г.

Сессия в PHP. Введение

Прежде чем начать изучать сессии нужно установить следующие полезности в firefox.

- http://www.bitstorm.org/extensions/view-cookies/ - позволяет быстро просмотрtть cookie текущей страницы через Ctrl-I, вкладка cookie;
- https://addons.mozilla.org/en-US/firefox/addon/closen-forget/?src=search быстро удаляет историю(+ печеньки) выбранной страницы.
Сессии и cookies предназначены для хранения сведений о пользователях при переходах между несколькими страницами. Данные сессии хранятся во временных файлах на сервере. Файлы с cookies хранятся на компьютере пользователя, и по запросу отсылаются на сервер.