Select2. Изменение поля при выборе значения.

Задача состоит в следующем: при выборе номера телефона клиента необходимо в другом поле изменять значение.

 

HTML:

<form action="" name="record">
  <select class="form-control select2" name="client-phone" data-placeholder="Телефон" style="width: 100%;" tabindex="-1" aria-hidden="true">
    <option value=""></option>
    <option value="1">+7 (555) 555-5555</option>
    <option value="2">+7 (651) 651-6516</option>
    <option value="3">+7 (516) 565-1651</option>
  </select>
  <p>или ФИО</p>
  <select class="form-control select2" name="client" data-placeholder="ФИО" style="width: 100%;" tabindex="-1" aria-hidden="true">
    <option value=""></option>
    <option value="1">ФИО 1</option>
    <option value="2">ФИО 2</option>
    <option value="3">ФИО 3</option>
  </select>
</form>

 

JS:

$('form[name="record"] [name=client-phone]').on('select2:select', function(evt) {
  selectClient('client', evt.params.data.id);
});

$('form[name="record"] [name=client]').on('select2:select', function(evt) {
  selectClient('client-phone', evt.params.data.id);
});

function selectClient(name, id) {
  $('form[name="record"] [name="' + name + '"]').select2('val', id);
}
$(".select2").select2();

 


 

В функцию selectClient передаем имя поля которое необходимо изменить и id выбранного значения.

Результат:

https://jsfiddle.net/yqhaw8fd/

XAMPP. Ошибка при включении Apache.

11:42:21  [main]  Initializing Control Panel
11:42:21  [main]  Windows Version:  Pro  64-bit
11:42:21  [main]  XAMPP Version: 5.6.21
11:42:21  [main]  Control Panel Version: 3.2.2  [ Compiled: Nov 12th 2015 ]
11:42:21  [main]  You are not running with administrator rights! This will work for
11:42:21  [main]  most application stuff but whenever you do something with services
11:42:21  [main]  there will be a security dialogue or things will break! So think
11:42:21  [main]  about running this application with administrator rights!
11:42:21  [main]  XAMPP Installation Directory: «c:\xampp\»
11:42:21  [main]  Checking for prerequisites
11:42:22  [main]  All prerequisites found
11:42:22  [main]  Initializing Modules
11:42:22  [Apache]  Problem detected!
11:42:22  [Apache]  Port 80 in use by «Unable to open process» with PID 4!
11:42:22  [Apache]  Apache WILL NOT start without the configured ports free!
11:42:22  [Apache]  You need to uninstall/disable/reconfigure the blocking application
11:42:22  [Apache]  or reconfigure Apache and the Control Panel to listen on a different port
11:42:22  [main]  Enabling autostart for module «Apache»
11:42:22  [main]  Enabling autostart for module «MySQL»
11:42:22  [main]  Enabling autostart for module «Mercury»
11:42:22  [main]  Starting Check-Timer
11:42:22  [main]  Control Panel Ready
11:42:22  [Apache]  Autostart active: starting…
11:42:22  [Apache]  Problem detected!
11:42:22  [Apache]  Port 80 in use by «Unable to open process» with PID 4!
11:42:22  [Apache]  Apache WILL NOT start without the configured ports free!
11:42:22  [Apache]  You need to uninstall/disable/reconfigure the blocking application
11:42:22  [Apache]  or reconfigure Apache and the Control Panel to listen on a different port
11:42:22  [Apache]  Attempting to start Apache app…
11:42:23  [mysql]  Autostart active: starting…
11:42:23  [mysql]  Attempting to start MySQL app…
11:42:24  [mercury]  Autostart active: starting…
11:42:24  [mercury]  Attempting to start Mercury app…
11:42:24  [Apache]  Status change detected: running
11:42:24  [mysql]  Status change detected: running
11:42:24  [mercury]  Status change detected: running
11:42:27  [Apache]  Status change detected: stopped
11:42:27  [Apache]  Error: Apache shutdown unexpectedly.
11:42:27  [Apache]  This may be due to a blocked port, missing dependencies,
11:42:27  [Apache]  improper privileges, a crash, or a shutdown by another method.
11:42:27  [Apache]  Press the Logs button to view error logs and check
11:42:27  [Apache]  the Windows Event Viewer for more clues
11:42:27  [Apache]  If you need more help, copy and post this
11:42:27  [Apache]  entire log window on the forums

 

Проблема из-за того что 80 порт занят.

Решение открыть командную строку от администратора и ввести команду:

net stop http

это остановит приложения с портом 80.

Запоминание позиций jQuery UI Sortable

Структура html

<div class="row" id="sortBlock">
       <section class="col-md-4 connectedSortable">
           // содержимое секции
       </section>
       <section class="col-md-4 connectedSortable">
           // содержимое секции           
       </section>
       <section class="col-md-4 connectedSortable">
           // содержимое секции
       </section>
       <section class="col-md-4 connectedSortable">
           // содержимое секции
       </section>
       <section class="col-md-4 connectedSortable">
           // содержимое секции
       </section>
       <section class="col-md-4 connectedSortable">
          // содержимое секции
       </section>
   </div>

 

 

<script> 
   $(".connectedSortable .box-header, .connectedSortable .nav-tabs-custom").css("cursor", "move");
    var root = $('#sortBlock');
    var pathname = window.location.pathname;
    var c = cookies.get(pathname);

    $('> *', root).each(function (index) {
        this.id = 'item-' + index;
    });

    root.sortable({
//        placeholder: "sort-highlight",
        connectWith: ".connectedSortable",
        handle: ".box-header, .nav-tabs",
        forcePlaceholderSize: true,
        'update': function (event, ui) {
            var order = $(this).sortable('serialize');
            cookies.set(pathname, {pathname, order});
        }
    });

    if (c) {
        $.each(c.order.split('&'), function () {
            var id = this.replace('[]=', '-');
            $('#' + id).appendTo(root);
        });
    }
</script>

 

Для использования кук был использован плагин.

Первосточник: Хранитель заметок

Полезные команды управления BigBlueButton

Ниже, выкладываю несколько полезных команд управления BigBlueButton.

sudo bbb-conf —version Показать версию установленного BigBlueButton.

sudo bbb-conf —check   Проверка конфигурационных файлов.

sudo bbb-conf —start   Запуск BigBlueButton.

sudo bbb-conf —stop   Остановка BigBlueButton.

sudo bbb-conf —restart   Перзапуск BigBlueButton.

sudo bbb-conf —clean   Рестарт и чистка всех log файлов BigBlueButton.

bbb-conf —setsalt <ваш кодСмена security salt. 

Мультизапрос

Существуют задачи в которых нужно выполнить много запросов к сайту и получить контент. Обычная функция file_get_contents() будет очень долго отрабатывать, если в цикле будет 10 запросов.

Данная функция существенно ускоряет скорость обработки запросов. Она принимает массив ссылок. И возвращает содержимое страницы.

function multi_request($urls = null)
    {
        $curly = array();
        $result = array();
        $mh = curl_multi_init();
        foreach ($urls as $id => $url) {
            $curly[$id] = curl_init();
            curl_setopt($curly[$id], CURLOPT_URL, $url);
            curl_setopt($curly[$id], CURLOPT_HEADER, 0);
            curl_setopt($curly[$id], CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curly[$id], CURLOPT_TIMEOUT, 30);
            curl_setopt($curly[$id], CURLOPT_FOLLOWLOCATION, true);
            curl_setopt($curly[$id], CURLOPT_SSL_VERIFYPEER, 0);
            curl_setopt($curly[$id], CURLOPT_SSL_VERIFYHOST, 0);
            curl_setopt($curly[$id], CURLOPT_USERAGENT, "Mozilla/5.0(Windows;U;WindowsNT5.1;ru;rv:1.9.0.4)Gecko/2008102920AdCentriaIM/1.7Firefox/3.0.4");
            //curl_setopt($curly[$id], CURLOPT_COOKIEJAR,'cookies.txt');
            //curl_setopt($curly[$id], CURLOPT_COOKIEFILE,'cookies.txt');
            curl_multi_add_handle($mh, $curly[$id]);
        }
        $running = null;
        do {
            curl_multi_exec($mh, $running);
        } while ($running > 0);
        
        foreach ($curly as $id => $c) {
            $result[$id] = curl_multi_getcontent($c);
            curl_multi_remove_handle($mh, $c);
        }
        curl_multi_close($mh);
        return $result;
    }

 

Как очистить кеш шаблонов в Laravel?

Добавив данный код в роутинг, можно будет отправлять post запрос для очистки кеша.

Route::post('/clear-cache', ['middleware' => ['auth', 'role:admin'], function () {
    $cachedViewsDirectory = app('path.storage') . '/framework/views/';
    if ($handle = opendir($cachedViewsDirectory)) {
        while (false !== ($entry = readdir($handle))) {
            if (strstr($entry, '..')) {
                continue;
            }
            @unlink($cachedViewsDirectory . $entry);
        }
        closedir($handle);
    }
    return 1;
}]);

 


									

Исправление ошибки при запуске команды db:seed

Содержимое ошибки

C:\xampp\php\php.exe artisan db:seed
[Illuminate\Database\QueryException]                                         
SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xC  
A\xF3\xF0\xFC\xE5\xF0...' for column 'name' at row 1 (SQL: insert into `cat  
egory` (`name`, `updated_at`, `created_at`) values ("���������� ������", 20  
16-09-14 14:49:44, 2016-09-14 14:49:44))

 

Чтобы исправить нужно изменить кодировку файла DatabaseSeeder.php с windows-1251 на utf-8